1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
19 /********************************************************************20**
21 Name: System Services -- Memory management interface
25 Desc: Implementation of the memory management interface.
29 *********************************************************************21*/
32 /* header include files (.h) */
34 #include "envopt.h" /* environment options */
35 #include "envdep.h" /* environment dependent */
36 #include "envind.h" /* environment independent */
38 #include "gen.h" /* general layer */
39 #include "ssi.h" /* system services */
41 #include "ss_err.h" /* errors */
42 #include "ss_dep.h" /* implementation-specific */
43 #include "ss_queue.h" /* queues */
44 #include "ss_msg.h" /* messaging */
45 #include "ss_mem.h" /* memory management interface */
46 /*ss011.301 : RMI SSI specific includes*/
48 #include "uc_gen.h" /* general */
50 #include "ss_gen.h" /* general */
54 #include "cm_mem.h" /* common memory manager */
58 /* header/extern include files (.x) */
60 #include "gen.x" /* general layer */
61 #include "ssi.x" /* system services */
63 #include "ss_dep.x" /* implementation-specific */
64 #include "ss_queue.x" /* queues */
65 /*ss011.301 : RMI SSI specific includes*/
67 #include "uc_task.x" /* tasking */
68 #include "uc_timer.x" /* timers */
70 #include "ss_task.x" /* tasking */
71 #include "ss_timer.x" /* timers */
73 #include "ss_strm.x" /* STREAMS */
74 #include "ss_msg.x" /* messaging */
75 #include "ss_mem.x" /* memory management interface */
76 #include "ss_drvr.x" /* driver tasks */
77 /*ss011.301 : RMI SSI specific includes*/
78 #ifdef SS_LOCKLESS_MEMORY
81 #include "cm_mem_wl.x" /* common memory manager */
83 #include "cm_mem.x" /* common memory manager */
84 #endif /* SS_LOCKLESS_MEMORY */
86 #include "uc_gen.x" /* general */
88 #include "ss_gen.x" /* general */
104 * Desc: Registers a memory region.
107 * RFAILED - failed, general (optional)
115 PUBLIC S16 SRegDynRegion
117 Region region, /* region ID */
118 SRegInfo *regInfo /* information about the region */
121 PUBLIC S16 SRegDynRegion(region, regInfo)
122 Region region; /* region ID */
123 SRegInfo *regInfo; /* information about the region */
132 #if (ERRCLASS & ERRCLS_INT_PAR)
133 /* validate region ID */
134 if (region >= SS_MAX_REGS)
136 SSLOGERROR(ERRCLS_INT_PAR, ESS028, region, "Invalid region");
140 /* validate region info pointer */
141 if (regInfo == NULLP)
143 SSLOGERROR(ERRCLS_INT_PAR, ESS029, ERRZERO, "Null pointer");
149 /* lock the region table */
150 SS_ACQUIRE_ALL_SEMA(&osCp.regionTblSem, ret);
154 #if (ERRCLASS & ERRCLS_DEBUG)
155 SSLOGERROR(ERRCLS_DEBUG, ESS030, (ErrVal) ret,
156 "Could not lock region table");
163 #if (ERRCLASS & ERRCLS_INT_PAR)
164 /* verify that this region is not registered */
165 if (osCp.dynRegionTbl[region].used == TRUE)
167 SS_RELEASE_ALL_SEMA(&osCp.regionTblSem);
169 SSLOGERROR(ERRCLS_INT_PAR, ESS031, ERRZERO, "Region ID used");
175 /* fill in the region information */
176 osCp.dynRegionTbl[region].used = TRUE;
177 osCp.dynRegionTbl[region].regCb = regInfo->regCb;
178 osCp.dynRegionTbl[region].flags = regInfo->flags;
179 osCp.dynRegionTbl[region].start = regInfo->start;
180 osCp.dynRegionTbl[region].size = regInfo->size;
181 osCp.dynRegionTbl[region].alloc = regInfo->alloc;
182 osCp.dynRegionTbl[region].free = regInfo->free;
183 osCp.dynRegionTbl[region].ctl = regInfo->ctl;
185 osCp.numDynRegions++;
188 /* unlock the region table */
189 SS_RELEASE_ALL_SEMA(&osCp.regionTblSem);
202 * Desc: Registers a memory region.
205 * RFAILED - failed, general (optional)
213 PUBLIC S16 SRegRegion
215 Region region, /* region ID */
216 SRegInfo *regInfo /* information about the region */
219 PUBLIC S16 SRegRegion(region, regInfo)
220 Region region; /* region ID */
221 SRegInfo *regInfo; /* information about the region */
230 #if (ERRCLASS & ERRCLS_INT_PAR)
231 /* validate region ID */
232 if (region >= SS_MAX_REGS)
234 SSLOGERROR(ERRCLS_INT_PAR, ESS028, region, "Invalid region");
238 /* validate region info pointer */
239 if (regInfo == NULLP)
241 SSLOGERROR(ERRCLS_INT_PAR, ESS029, ERRZERO, "Null pointer");
247 /* lock the region table */
248 SS_ACQUIRE_ALL_SEMA(&osCp.regionTblSem, ret);
252 #if (ERRCLASS & ERRCLS_DEBUG)
253 SSLOGERROR(ERRCLS_DEBUG, ESS030, (ErrVal) ret,
254 "Could not lock region table");
261 #if (ERRCLASS & ERRCLS_INT_PAR)
262 /* verify that this region is not registered */
263 if (osCp.regionTbl[region].used == TRUE)
265 SS_RELEASE_ALL_SEMA(&osCp.regionTblSem);
267 SSLOGERROR(ERRCLS_INT_PAR, ESS031, ERRZERO, "Region ID used");
273 /* fill in the region information */
274 osCp.regionTbl[region].used = TRUE;
275 osCp.regionTbl[region].regCb = regInfo->regCb;
276 osCp.regionTbl[region].flags = regInfo->flags;
277 osCp.regionTbl[region].start = regInfo->start;
278 osCp.regionTbl[region].size = regInfo->size;
279 osCp.regionTbl[region].alloc = regInfo->alloc;
280 osCp.regionTbl[region].free = regInfo->free;
281 osCp.regionTbl[region].ctl = regInfo->ctl;
286 /* unlock the region table */
287 SS_RELEASE_ALL_SEMA(&osCp.regionTblSem);
298 * Desc: Deregisters a memory region.
301 * RFAILED - failed, general (optional)
309 PUBLIC S16 SDeregRegion
311 Region region /* region ID */
314 PUBLIC S16 SDeregRegion(region)
315 Region region; /* region ID */
324 #if (ERRCLASS & ERRCLS_INT_PAR)
325 /* validate region ID */
326 if (region >= SS_MAX_REGS)
328 SSLOGERROR(ERRCLS_INT_PAR, ESS032, region, "Invalid region");
334 /* lock the region table */
335 SS_ACQUIRE_ALL_SEMA(&osCp.regionTblSem, ret);
339 #if (ERRCLASS & ERRCLS_DEBUG)
340 SSLOGERROR(ERRCLS_DEBUG, ESS033, (ErrVal) ret,
341 "Could not lock region table");
348 #if (ERRCLASS & ERRCLS_INT_PAR)
349 /* check if this region is registered */
350 if (osCp.regionTbl[region].used == FALSE)
352 SS_RELEASE_ALL_SEMA(&osCp.regionTblSem);
353 SSLOGERROR(ERRCLS_INT_PAR, ESS034, region, "Region not registered");
359 /* empty the information about the region */
360 osCp.regionTbl[region].used = FALSE;
361 osCp.regionTbl[region].start = NULLP;
362 osCp.regionTbl[region].size = 0;
363 osCp.regionTbl[region].regCb = NULLP;
364 osCp.regionTbl[region].flags = 0;
365 osCp.regionTbl[region].alloc = NULLP;
366 osCp.regionTbl[region].free = NULLP;
367 osCp.regionTbl[region].ctl = NULLP;
372 /* unlock the region table */
373 SS_RELEASE_ALL_SEMA(&osCp.regionTblSem);
384 * Desc: Allocates a block of memory of at least the specified
388 * RFAILED - failed, general (optional)
395 /*ss003.301-gaurded under flag SS_FAP*/
397 /* ss001.301: Additions */
398 #ifdef SS_HISTOGRAM_SUPPORT
402 Region region, /* region ID */
403 Size *size, /* size of block required/allocated */
404 U32 flags, /* allocation flags */
405 Data **ptr, /* filled with pointer to block */
411 PUBLIC S16 SAlloc(region, size, flags, ptr, line, fileName, entId)
412 Region region; /* region ID */
413 Size *size; /* size of block required/allocated */
414 U32 flags; /* allocation flags */
415 Data **ptr; /* filled with pointer to block */
421 #ifdef T2K_MEM_LEAK_DBG
424 Region region, /* region ID */
425 Size *size, /* size of block required/allocated */
426 U32 flags, /* allocation flags */
427 Data **ptr, /* filled with pointer to block */
435 Region region, /* region ID */
436 Size *size, /* size of block required/allocated */
437 U32 flags, /* allocation flags */
438 Data **ptr /* filled with pointer to block */
441 PUBLIC S16 SAlloc(region, size, flags, ptr)
442 Region region; /* region ID */
443 Size *size; /* size of block required/allocated */
444 U32 flags; /* allocation flags */
445 Data **ptr; /* filled with pointer to block */
451 /* ss001.301: Additions */
452 #ifdef SS_HISTOGRAM_SUPPORT
454 #endif /* SS_HISTOGRAM_SUPPORT */
460 #if (ERRCLASS & ERRCLS_INT_PAR)
461 /* validate region ID */
462 if (region >= SS_MAX_REGS)
464 SSLOGERROR(ERRCLS_INT_PAR, ESS035, region, "Invalid region");
468 #ifndef XEON_SPECIFIC_CHANGES
469 /* Get the region which is assgined with this thread. The region was
470 * stored in the osCp and is taken with respect to thread ID. This macro
471 * is used only when SS_LOCKLESS_MEMORY flag is used and it overwrites
474 region = SS_GET_THREAD_MEM_REGION();
476 /* ss037.103 Removed the semaphore acquisition for performance enhancement */
478 /* acquire one semaphore, to protect against deregistration */
479 SS_ACQUIRE_SEMA(&osCp.regionTblSem, ret);
483 #if (ERRCLASS & ERRCLS_DEBUG)
484 SSLOGERROR(ERRCLS_DEBUG, ESS036, (ErrVal) ret,
485 "Could not lock region table");
492 #if (ERRCLASS & ERRCLS_INT_PAR)
493 /* verify that this region is present */
494 if (osCp.regionTbl[region].used == FALSE)
496 /* ss037.103 Removed the semaphore operation for performance enhancement */
498 /* ss006.13: addition */
499 if( SS_RELEASE_SEMA(&osCp.regionTblSem) != ROK)
501 #if (ERRCLASS & ERRCLS_DEBUG)
502 SSLOGERROR(ERRCLS_DEBUG, ESS037, ERRZERO,
503 "Could not release the semaphore");
508 SSLOGERROR(ERRCLS_INT_PAR, ESS038, region, "Region not registered");
512 /* ss001.301: Additions */
513 #ifdef SS_HISTOGRAM_SUPPORT
514 SGetHstGrmInfo(&entId, &hstReg);
515 /* call the memory manager, to allocate this memory */
516 /* ss036.103 - addition for passing memType as dynamic */
517 #ifdef SSI_DEBUG_LEVEL1
518 ret = (osCp.regionTbl[region].alloc)
519 (osCp.regionTbl[region].regCb, size, flags, ptr,
520 SS_DYNAMIC_MEM_FLAG, line, fileName, entId, hstReg);
522 ret = (osCp.regionTbl[region].alloc)
523 (osCp.regionTbl[region].regCb, size, flags, ptr, line,
524 fileName, entId, hstReg);
525 #endif /* SSI_DEBUG_LEVEL1 */
529 /* call the memory manager, to allocate this memory */
530 /* ss036.103 - addition for passing memType as dynamic */
531 #ifdef SSI_DEBUG_LEVEL1
532 ret = (osCp.regionTbl[region].alloc)
533 (osCp.regionTbl[region].regCb, size, flags, ptr, SS_DYNAMIC_MEM_FLAG);
535 #ifdef SS_LOCKLESS_MEMORY
536 #ifdef T2K_MEM_LEAK_DBG
537 ret = (osCp.dynRegionTbl[region].alloc)
538 (osCp.dynRegionTbl[region].regCb, size, flags, ptr,file,line);
540 ret = (osCp.dynRegionTbl[region].alloc)
541 (osCp.dynRegionTbl[region].regCb, size, flags, ptr);
544 #ifdef T2K_MEM_LEAK_DBG
545 ret = (osCp.regionTbl[region].alloc)
546 (osCp.regionTbl[region].regCb, size, flags, ptr,file,line);
548 ret = (osCp.regionTbl[region].alloc)
549 (osCp.regionTbl[region].regCb, size, flags, ptr);
551 #endif /* SS_LOCKLESS_MEMORY */
552 #endif /* SSI_DEBUG_LEVEL1 */
554 #endif /* SS_HISTOGRAM_SUPPORT */
556 /* ss037.103 Removed the semaphore operation for performance enhancement */
559 /* release the semaphore we took */
560 /* ss006.13: addition */
561 if( SS_RELEASE_SEMA(&osCp.regionTblSem) != ROK)
563 #if (ERRCLASS & ERRCLS_DEBUG)
564 SSLOGERROR(ERRCLS_DEBUG, ESS039, ERRZERO,
565 "Could not release the semaphore");
570 /* ss036.103 - Addition to handle the memory trampling return value
571 * This in turn can call SRegMemErrHdlr
573 #ifdef SSI_DEBUG_LEVEL1
574 if (ret == RTRAMPLINGNOK)
576 SRegMemErrHdlr( region, *ptr, ret);
578 #endif /* SSI_DEBUG_LEVEL1 */
588 * Desc: Frees a block of memory previously allocated by SAlloc().
591 * RFAILED - failed, general (optional)
598 /* ss001.301: Additions */
599 #ifdef SS_HISTOGRAM_SUPPORT
603 Region region, /* region ID */
604 Data *ptr, /* pointer to the allocated block */
605 Size size, /* size of block */
611 PUBLIC S16 SFree(region, ptr, size, line, fileName, entId)
612 Region region; /* region ID */
613 Data *ptr; /* pointer to the allocated block */
614 Size size; /* size of block */
621 #ifdef T2K_MEM_LEAK_DBG
624 Region region, /* region ID */
625 Data *ptr, /* pointer to the allocated block */
626 Size size, /* size of block */
633 Region region, /* region ID */
634 Data *ptr, /* pointer to the allocated block */
635 Size size /* size of block */
639 PUBLIC S16 SFree(region, ptr, size)
640 Region region; /* region ID */
641 Data *ptr; /* pointer to the allocated block */
642 Size size; /* size of block */
648 /* ss001.301: Additions */
649 #ifdef SS_HISTOGRAM_SUPPORT
651 #endif /* SS_HISTOGRAM_SUPPORT */
656 /* Get the region which is assgined with this thread. The region was
657 * stored in the osCp and is taken with respect to thread ID. This macro
658 * is used only when SS_LOCKLESS_MEMORY flag is used and it overwrites
661 #ifdef XEON_SPECIFIC_CHANGES
664 region = SS_GET_THREAD_MEM_REGION();
667 #if (ERRCLASS & ERRCLS_INT_PAR)
668 /* validate region ID */
669 if (region >= SS_MAX_REGS)
671 SSLOGERROR(ERRCLS_INT_PAR, ESS040, region, "Invalid region");
675 /* ss021.103 - Addition to validate size and ptr */
678 SSLOGERROR(ERRCLS_INT_PAR, ESS041, region, "Invalid size");
683 if (ptr == (Data *)NULLP)
685 SSLOGERROR(ERRCLS_INT_PAR, ESS042, region, "Invalid ptr");
690 /* ss037.103 Removed the semaphore operation for performance enhancement */
693 /* acquire one semaphore, to protect against deregistration */
694 SS_ACQUIRE_SEMA(&osCp.regionTblSem, ret);
698 #if (ERRCLASS & ERRCLS_DEBUG)
699 SSLOGERROR(ERRCLS_DEBUG, ESS043, (ErrVal) ret,
700 "Could not lock region table");
706 #if (ERRCLASS & ERRCLS_INT_PAR)
707 /* verify that this region is around */
708 if (osCp.regionTbl[region].used == FALSE)
711 /* ss006.13: addition */
712 if( SS_RELEASE_SEMA(&osCp.regionTblSem) != ROK)
714 #if (ERRCLASS & ERRCLS_DEBUG)
715 SSLOGERROR(ERRCLS_DEBUG, ESS044, ERRZERO,
716 "Could not release the semaphore");
721 SSLOGERROR(ERRCLS_INT_PAR, ESS045, region, "Region not registered");
726 /* ss001.301: Additions */
727 #ifdef SS_HISTOGRAM_SUPPORT
728 SGetHstGrmInfo(&entId, &hstReg);
730 /* call the memory manager to free this memory */
731 ret = (osCp.regionTbl[region].free)
732 (osCp.regionTbl[region].regCb, ptr, size, line, fileName,
737 /* call the memory manager to free this memory */
738 #ifdef SS_LOCKLESS_MEMORY
739 #ifdef T2K_MEM_LEAK_DBG
740 ret = (osCp.dynRegionTbl[region].free)(osCp.dynRegionTbl[region].regCb, ptr, size,file,line);
742 ret = (osCp.dynRegionTbl[region].free)(osCp.dynRegionTbl[region].regCb, ptr, size);
745 #ifdef T2K_MEM_LEAK_DBG
746 ret = (osCp.regionTbl[region].free)(osCp.regionTbl[region].regCb, ptr, size,file,line);
748 ret = (osCp.regionTbl[region].free)(osCp.regionTbl[region].regCb, ptr, size);
750 #endif /* SS_LOCKLESS_MEMORY */
752 #endif /* SS_HISTOGRAM_SUPPORT */
754 /* ss037.103 Removed the semaphore operation for performance enhancement */
757 /* release the semaphore we took */
758 /* ss006.13: addition */
759 if( SS_RELEASE_SEMA(&osCp.regionTblSem) != ROK)
761 #if (ERRCLASS & ERRCLS_DEBUG)
762 SSLOGERROR(ERRCLS_DEBUG, ESS046, ERRZERO,
763 "Could not release the semaphore");
768 /* ss036.103 - changes to handle double free and trmapling return values
769 * This in turn may invoke SRegMemErrHdlr
771 #ifdef SSI_DEBUG_LEVEL1
772 /* handle the double free error here by calling the OS specific error handling function */
773 if ((ret == RDBLFREE) || (ret == RTRAMPLINGNOK))
775 SRegMemErrHdlr( region, ptr, ret);
777 #endif /* SSI_DEBUG_LEVEL1 */
784 /* ss001.301: Additions */
785 #ifdef SS_HISTOGRAM_SUPPORT
789 * Fun: SHstGrmInfoShow
791 * Desc: This function displays the memory usage information
792 * per Tapa task, which are registerd during initialization.
798 * Notes: A Sample Output from the function
799 * Memory Histogram for the Tapa task = (Entity Id)117
800 * ------Region Id = 0-------
801 * -----------Bucket Id = 0-----------
803 * File Name| Line | Bucket Alloc | Bytes Allocated | Bytes Wasted | Buckets Freed|Bytes Freed|
804 * lhi.c | 413 | 4 | 512 | 224 | 0 | 0 |
805 * hi_acc1.c| 333 | 0 | 0 | 0 | 2 | 256 |
806 * hi_acc1.c| 209 | 13 | 1664 | 728 | 0 | 0 |
812 PUBLIC S16 SHstGrmInfoShow
817 PUBLIC S16 SHstGrmInfoShow(entId)
821 /*ss012.301 : Increased Buffer size to fix segmentation fault*/
822 Txt prntBuf[511]; /* Buffer to print on the console */
823 U16 ret = ROK; /* return value */
824 Ent tapaTsk[SS_MAX_TTSKS]; /* List of tapa task */
825 U32 tskCnt = 0; /* Tapa task Count */
826 U32 regCnt = 0; /* Region count */
827 U32 bktCnt = 0; /* Bucket count in each region */
828 CmHstGrmHashListCp *hashListCp = NULLP; /* Hash List ponter of bucket */
831 CmMemEntries *entry = NULLP;
836 memset(tapaTsk, ENTNC, sizeof(tapaTsk));
840 /* If user is not asking for specific entity id then,
841 * Take Tapa task entity id from the osCp structure and
842 * print the histogram for all tapa task */
843 ret = SGetTapaTskEntIds(tapaTsk);
847 /* If user asked for specific tapa task then print histogram
848 * for those tapa task */
849 for(tskCnt = 0; entId[tskCnt]; tskCnt++)
851 tapaTsk[tskCnt] = entId[tskCnt];
854 for (tskCnt = 0; tapaTsk[tskCnt] != ENTNC; tskCnt++)
856 sprintf(prntBuf, "\n\nMemory Histogram for the Tapa task = (Entity Id)%d\n", tapaTsk[tskCnt]);
858 for (regCnt = 0; regCnt < osCp.numRegions; regCnt++)
861 CmMmRegCb* regCb = (CmMmRegCb*)osCp.regionTbl[regCnt].regCb;
863 sprintf(prntBuf, "------Region Id = %d-------\n", regCb->region);
865 for (bktCnt = 0; bktCnt < regCb->numBkts; bktCnt++)
867 /* ss002.301 - Compilation fixes */
868 /*ss013.301 Fix for compilation warnings 32/64 bit */
870 sprintf(prntBuf, "-----------Bucket Id = %u-----------\n\n", bktCnt);
872 sprintf(prntBuf, "-----------Bucket Id = %lu-----------\n\n", bktCnt);
875 sprintf(prntBuf, "File Name | Line | Bucket Alloc | Bytes Allocated | Bytes Wasted | Buckets Freed|Bytes Freed|\n");
877 hashListCp = &(regCb->bktTbl[bktCnt].hstGrmHashListCp);
878 blkSize = regCb->bktTbl[bktCnt].size;
879 for(binCnt = 0; binCnt < CMM_HIST_MAX_MEM_BIN; binCnt++)
881 for (entCnt = 0; entCnt < hashListCp->hashList[binCnt].numOfEntries; entCnt++)
883 entry = &(hashListCp->hashList[binCnt].entries[entCnt]);
884 if(entry->entId == tapaTsk[tskCnt])
886 /* ss002.301 - Compilation fixes */
887 /*ss013.301 Fix for compilation warnings 32/64 bit */
890 "%-18s|%7u |%13u |%16u |%13u |%13u |%10u |\n",
891 entry->fileName, entry->line, entry->bucketAllocReq,
892 (blkSize*entry->bucketAllocReq), entry->wastedBytes,
893 entry->bucketFreeReq, (blkSize*entry->bucketFreeReq));
896 "%-18s|%7lu |%13lu |%16lu |%13lu |%13lu |%10lu |\n",
897 entry->fileName, entry->line, entry->bucketAllocReq,
898 (blkSize*entry->bucketAllocReq), entry->wastedBytes,
899 entry->bucketFreeReq, (blkSize*entry->bucketFreeReq));
903 }/* end of for. Entry count */
904 } /* End of for. Hash bin count */
907 sprintf(prntBuf, "\n\n----------- Heap blocks -----------\n\n");
909 sprintf(prntBuf, "File Name | Line | Heap Allocs | Bytes Allocated | Bytes Wasted | Heap Frees |Bytes Freed|\n");
911 hashListCp = &(regCb->heapCb.heapHstGrmHashListCp);
912 for(binCnt = 0; binCnt < CMM_HIST_MAX_MEM_BIN; binCnt++)
914 for (entCnt = 0; entCnt < hashListCp->hashList[binCnt].numOfEntries; entCnt++)
916 entry = &(hashListCp->hashList[binCnt].entries[entCnt]);
917 if(entry->entId == tapaTsk[tskCnt])
919 /* ss002.301 - Compilation fixes */
920 /*ss013.301 Fix for compilation warnings 32/64 bit */
923 "%-18s|%7u |%13u |%16u |%13u |%13u |%10u |\n",
924 entry->fileName, entry->line, entry->bucketAllocReq,
925 entry->allocBytes, entry->wastedBytes,
926 entry->bucketFreeReq, entry->freedBytes);
929 "%-18s|%7lu |%13lu |%16lu |%13lu |%13lu |%10lu |\n",
930 entry->fileName, entry->line, entry->bucketAllocReq,
931 entry->allocBytes, entry->wastedBytes,
932 entry->bucketFreeReq, entry->freedBytes);
936 }/* end of for. Entry count */
937 } /* End of for. Hash bin count */
938 }/* End of for. Region Count */
939 } /* End of for (Tapa task)*/
942 /* Print the memory information used at common, sample and ssi files.
943 we considerd common Sample file as invalid entity id. */
944 sprintf(prntBuf, "\n\nMemory Histogram for the Tapa task = (Entity Id = ENTNC)%d\n", ENTNC);
946 for (regCnt = 0; regCnt < osCp.numRegions; regCnt++)
948 CmMmRegCb* regCb = (CmMmRegCb*)osCp.regionTbl[regCnt].regCb;
950 sprintf(prntBuf, "------Region Id = %d-------\n", regCb->region);
952 for (bktCnt = 0; bktCnt < regCb->numBkts; bktCnt++)
954 /* ss002.301 - Compilation fixes */
955 /*ss013.301 Fix for compilation warnings 32/64 bit */
957 sprintf(prntBuf, "-----------Bucket Id = %u-----------\n\n", bktCnt);
959 sprintf(prntBuf, "-----------Bucket Id = %lu-----------\n\n", bktCnt);
962 sprintf(prntBuf, "File Name | Line | Bucket Alloc | Bytes Allocated | Bytes Wasted | Buckets Freed|Bytes Freed|\n");
964 hashListCp = &(regCb->bktTbl[bktCnt].hstGrmHashListCp);
965 blkSize = regCb->bktTbl[bktCnt].size;
966 for(binCnt = 0; binCnt < CMM_HIST_MAX_MEM_BIN; binCnt++)
968 for (entCnt = 0; entCnt < hashListCp->hashList[binCnt].numOfEntries; entCnt++)
970 entry = &(hashListCp->hashList[binCnt].entries[entCnt]);
971 if(entry->entId == tapaTsk[tskCnt])
973 /* ss002.301 - Compilation fixes */
974 /*ss013.301 Fix for compilation warnings 32/64 bit */
976 sprintf(prntBuf, "%-18s|%7u |%13u |%16u |%13u |%13u |%10u |\n",
977 entry->fileName, entry->line, entry->bucketAllocReq, (blkSize*entry->bucketAllocReq),
978 entry->wastedBytes, entry->bucketFreeReq, (blkSize*entry->bucketFreeReq));
980 sprintf(prntBuf, "%-18s|%7lu |%13lu |%16lu |%13lu |%13lu |%10lu |\n",
981 entry->fileName, entry->line, entry->bucketAllocReq, (blkSize*entry->bucketAllocReq),
982 entry->wastedBytes, entry->bucketFreeReq, (blkSize*entry->bucketFreeReq));
986 }/* end of for. Entry count */
987 } /* End of for. Hash bin count */
989 }/* End of for. Bucket Count */
991 sprintf(prntBuf, "\n\n----------- Heap blocks -----------\n\n");
993 sprintf(prntBuf, "File Name | Line | Heap Allocs | Bytes Allocated | Bytes Wasted | Heap Frees |Bytes Freed|\n");
995 hashListCp = &(regCb->heapCb.heapHstGrmHashListCp);
996 for(binCnt = 0; binCnt < CMM_HIST_MAX_MEM_BIN; binCnt++)
998 for (entCnt = 0; entCnt < hashListCp->hashList[binCnt].numOfEntries; entCnt++)
1000 entry = &(hashListCp->hashList[binCnt].entries[entCnt]);
1001 if(entry->entId == tapaTsk[tskCnt])
1003 /* ss002.301 - Compilation fixes */
1004 /*ss013.301 Fix for compilation warnings 32/64 bit */
1007 "%-18s|%7u |%13u |%16u |%13u |%13u |%10u |\n",
1008 entry->fileName, entry->line, entry->bucketAllocReq,
1009 entry->allocBytes, entry->wastedBytes,
1010 entry->bucketFreeReq, entry->freedBytes);
1013 "%-18s|%7lu |%13lu |%16lu |%13lu |%13lu |%10lu |\n",
1014 entry->fileName, entry->line, entry->bucketAllocReq,
1015 entry->allocBytes, entry->wastedBytes,
1016 entry->bucketFreeReq, entry->freedBytes);
1020 }/* end of for. Entry count */
1021 } /* End of for. Hash bin count */
1023 }/* End of for. Region Count */
1028 #endif /* SS_HISTOGRAM_SUPPORT */
1031 /**********************************************************************
1033 **********************************************************************/