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)
117 Region region, /* region ID */
118 SRegInfo *regInfo /* information about the region */
121 S16 SRegDynRegion(region, regInfo)
122 Region region; /* region ID */
123 SRegInfo *regInfo; /* information about the region */
128 #if (ERRCLASS & ERRCLS_INT_PAR)
129 /* validate region ID */
130 if (region >= SS_MAX_REGS)
132 SSLOGERROR(ERRCLS_INT_PAR, ESS028, region, "Invalid region");
136 /* validate region info pointer */
137 if (regInfo == NULLP)
139 SSLOGERROR(ERRCLS_INT_PAR, ESS029, ERRZERO, "Null pointer");
145 /* lock the region table */
146 SS_ACQUIRE_ALL_SEMA(&osCp.regionTblSem, ret);
150 #if (ERRCLASS & ERRCLS_DEBUG)
151 SSLOGERROR(ERRCLS_DEBUG, ESS030, (ErrVal) ret,
152 "Could not lock region table");
159 #if (ERRCLASS & ERRCLS_INT_PAR)
160 /* verify that this region is not registered */
161 if (osCp.dynRegionTbl[region].used == TRUE)
163 SS_RELEASE_ALL_SEMA(&osCp.regionTblSem);
165 SSLOGERROR(ERRCLS_INT_PAR, ESS031, ERRZERO, "Region ID used");
171 /* fill in the region information */
172 osCp.dynRegionTbl[region].used = TRUE;
173 osCp.dynRegionTbl[region].regCb = regInfo->regCb;
174 osCp.dynRegionTbl[region].flags = regInfo->flags;
175 osCp.dynRegionTbl[region].start = regInfo->start;
176 osCp.dynRegionTbl[region].size = regInfo->size;
177 osCp.dynRegionTbl[region].alloc = regInfo->alloc;
178 osCp.dynRegionTbl[region].free = regInfo->free;
179 osCp.dynRegionTbl[region].ctl = regInfo->ctl;
181 osCp.numDynRegions++;
184 /* unlock the region table */
185 SS_RELEASE_ALL_SEMA(&osCp.regionTblSem);
198 * Desc: Registers a memory region.
201 * RFAILED - failed, general (optional)
211 Region region, /* region ID */
212 SRegInfo *regInfo /* information about the region */
215 S16 SRegRegion(region, regInfo)
216 Region region; /* region ID */
217 SRegInfo *regInfo; /* information about the region */
222 #if (ERRCLASS & ERRCLS_INT_PAR)
223 /* validate region ID */
224 if (region >= SS_MAX_REGS)
226 SSLOGERROR(ERRCLS_INT_PAR, ESS028, region, "Invalid region");
230 /* validate region info pointer */
231 if (regInfo == NULLP)
233 SSLOGERROR(ERRCLS_INT_PAR, ESS029, ERRZERO, "Null pointer");
239 /* lock the region table */
240 SS_ACQUIRE_ALL_SEMA(&osCp.regionTblSem, ret);
244 #if (ERRCLASS & ERRCLS_DEBUG)
245 SSLOGERROR(ERRCLS_DEBUG, ESS030, (ErrVal) ret,
246 "Could not lock region table");
253 #if (ERRCLASS & ERRCLS_INT_PAR)
254 /* verify that this region is not registered */
255 if (osCp.regionTbl[region].used == TRUE)
257 SS_RELEASE_ALL_SEMA(&osCp.regionTblSem);
259 SSLOGERROR(ERRCLS_INT_PAR, ESS031, ERRZERO, "Region ID used");
265 /* fill in the region information */
266 osCp.regionTbl[region].used = TRUE;
267 osCp.regionTbl[region].regCb = regInfo->regCb;
268 osCp.regionTbl[region].flags = regInfo->flags;
269 osCp.regionTbl[region].start = regInfo->start;
270 osCp.regionTbl[region].size = regInfo->size;
271 osCp.regionTbl[region].alloc = regInfo->alloc;
272 osCp.regionTbl[region].free = regInfo->free;
273 osCp.regionTbl[region].ctl = regInfo->ctl;
278 /* unlock the region table */
279 SS_RELEASE_ALL_SEMA(&osCp.regionTblSem);
290 * Desc: Deregisters a memory region.
293 * RFAILED - failed, general (optional)
303 Region region /* region ID */
306 S16 SDeregRegion(region)
307 Region region; /* region ID */
312 #if (ERRCLASS & ERRCLS_INT_PAR)
313 /* validate region ID */
314 if (region >= SS_MAX_REGS)
316 SSLOGERROR(ERRCLS_INT_PAR, ESS032, region, "Invalid region");
322 /* lock the region table */
323 SS_ACQUIRE_ALL_SEMA(&osCp.regionTblSem, ret);
327 #if (ERRCLASS & ERRCLS_DEBUG)
328 SSLOGERROR(ERRCLS_DEBUG, ESS033, (ErrVal) ret,
329 "Could not lock region table");
336 #if (ERRCLASS & ERRCLS_INT_PAR)
337 /* check if this region is registered */
338 if (osCp.regionTbl[region].used == FALSE)
340 SS_RELEASE_ALL_SEMA(&osCp.regionTblSem);
341 SSLOGERROR(ERRCLS_INT_PAR, ESS034, region, "Region not registered");
347 /* empty the information about the region */
348 osCp.regionTbl[region].used = FALSE;
349 osCp.regionTbl[region].start = NULLP;
350 osCp.regionTbl[region].size = 0;
351 osCp.regionTbl[region].regCb = NULLP;
352 osCp.regionTbl[region].flags = 0;
353 osCp.regionTbl[region].alloc = NULLP;
354 osCp.regionTbl[region].free = NULLP;
355 osCp.regionTbl[region].ctl = NULLP;
360 /* unlock the region table */
361 SS_RELEASE_ALL_SEMA(&osCp.regionTblSem);
372 * Desc: Allocates a block of memory of at least the specified
376 * RFAILED - failed, general (optional)
383 /*ss003.301-gaurded under flag SS_FAP*/
385 /* ss001.301: Additions */
386 #ifdef SS_HISTOGRAM_SUPPORT
390 Region region, /* region ID */
391 Size *size, /* size of block required/allocated */
392 uint32_t flags, /* allocation flags */
393 Data **ptr, /* filled with pointer to block */
399 S16 SAlloc(region, size, flags, ptr, line, fileName, entId)
400 Region region; /* region ID */
401 Size *size; /* size of block required/allocated */
402 uint32_t flags; /* allocation flags */
403 Data **ptr; /* filled with pointer to block */
409 #ifdef T2K_MEM_LEAK_DBG
412 Region region, /* region ID */
413 Size *size, /* size of block required/allocated */
414 uint32_t flags, /* allocation flags */
415 Data **ptr, /* filled with pointer to block */
423 Region region, /* region ID */
424 Size *size, /* size of block required/allocated */
425 uint32_t flags, /* allocation flags */
426 Data **ptr /* filled with pointer to block */
429 S16 SAlloc(region, size, flags, ptr)
430 Region region; /* region ID */
431 Size *size; /* size of block required/allocated */
432 uint32_t flags; /* allocation flags */
433 Data **ptr; /* filled with pointer to block */
439 /* ss001.301: Additions */
440 #ifdef SS_HISTOGRAM_SUPPORT
442 #endif /* SS_HISTOGRAM_SUPPORT */
447 #if (ERRCLASS & ERRCLS_INT_PAR)
448 /* validate region ID */
449 if (region >= SS_MAX_REGS)
451 SSLOGERROR(ERRCLS_INT_PAR, ESS035, region, "Invalid region");
455 #ifndef XEON_SPECIFIC_CHANGES
456 /* Get the region which is assgined with this thread. The region was
457 * stored in the osCp and is taken with respect to thread ID. This macro
458 * is used only when SS_LOCKLESS_MEMORY flag is used and it overwrites
461 region = SS_GET_THREAD_MEM_REGION();
463 /* ss037.103 Removed the semaphore acquisition for performance enhancement */
465 /* acquire one semaphore, to protect against deregistration */
466 SS_ACQUIRE_SEMA(&osCp.regionTblSem, ret);
470 #if (ERRCLASS & ERRCLS_DEBUG)
471 SSLOGERROR(ERRCLS_DEBUG, ESS036, (ErrVal) ret,
472 "Could not lock region table");
479 #if (ERRCLASS & ERRCLS_INT_PAR)
480 /* verify that this region is present */
481 if (osCp.regionTbl[region].used == FALSE)
483 /* ss037.103 Removed the semaphore operation for performance enhancement */
485 /* ss006.13: addition */
486 if( SS_RELEASE_SEMA(&osCp.regionTblSem) != ROK)
488 #if (ERRCLASS & ERRCLS_DEBUG)
489 SSLOGERROR(ERRCLS_DEBUG, ESS037, ERRZERO,
490 "Could not release the semaphore");
495 SSLOGERROR(ERRCLS_INT_PAR, ESS038, region, "Region not registered");
499 /* ss001.301: Additions */
500 #ifdef SS_HISTOGRAM_SUPPORT
501 SGetHstGrmInfo(&entId, &hstReg);
502 /* call the memory manager, to allocate this memory */
503 /* ss036.103 - addition for passing memType as dynamic */
504 #ifdef SSI_DEBUG_LEVEL1
505 ret = (osCp.regionTbl[region].alloc)
506 (osCp.regionTbl[region].regCb, size, flags, ptr,
507 SS_DYNAMIC_MEM_FLAG, line, fileName, entId, hstReg);
509 ret = (osCp.regionTbl[region].alloc)
510 (osCp.regionTbl[region].regCb, size, flags, ptr, line,
511 fileName, entId, hstReg);
512 #endif /* SSI_DEBUG_LEVEL1 */
516 /* call the memory manager, to allocate this memory */
517 /* ss036.103 - addition for passing memType as dynamic */
518 #ifdef SSI_DEBUG_LEVEL1
519 ret = (osCp.regionTbl[region].alloc)
520 (osCp.regionTbl[region].regCb, size, flags, ptr, SS_DYNAMIC_MEM_FLAG);
522 #ifdef SS_LOCKLESS_MEMORY
523 #ifdef T2K_MEM_LEAK_DBG
524 ret = (osCp.dynRegionTbl[region].alloc)
525 (osCp.dynRegionTbl[region].regCb, size, flags, ptr,file,line);
527 ret = (osCp.dynRegionTbl[region].alloc)
528 (osCp.dynRegionTbl[region].regCb, size, flags, ptr);
531 #ifdef T2K_MEM_LEAK_DBG
532 ret = (osCp.regionTbl[region].alloc)
533 (osCp.regionTbl[region].regCb, size, flags, ptr,file,line);
535 ret = (osCp.regionTbl[region].alloc)
536 (osCp.regionTbl[region].regCb, size, flags, ptr);
538 #endif /* SS_LOCKLESS_MEMORY */
539 #endif /* SSI_DEBUG_LEVEL1 */
541 #endif /* SS_HISTOGRAM_SUPPORT */
543 /* ss037.103 Removed the semaphore operation for performance enhancement */
546 /* release the semaphore we took */
547 /* ss006.13: addition */
548 if( SS_RELEASE_SEMA(&osCp.regionTblSem) != ROK)
550 #if (ERRCLASS & ERRCLS_DEBUG)
551 SSLOGERROR(ERRCLS_DEBUG, ESS039, ERRZERO,
552 "Could not release the semaphore");
557 /* ss036.103 - Addition to handle the memory trampling return value
558 * This in turn can call SRegMemErrHdlr
560 #ifdef SSI_DEBUG_LEVEL1
561 if (ret == RTRAMPLINGNOK)
563 SRegMemErrHdlr( region, *ptr, ret);
565 #endif /* SSI_DEBUG_LEVEL1 */
575 * Desc: Frees a block of memory previously allocated by SAlloc().
578 * RFAILED - failed, general (optional)
585 /* ss001.301: Additions */
586 #ifdef SS_HISTOGRAM_SUPPORT
590 Region region, /* region ID */
591 Data *ptr, /* pointer to the allocated block */
592 Size size, /* size of block */
598 S16 SFree(region, ptr, size, line, fileName, entId)
599 Region region; /* region ID */
600 Data *ptr; /* pointer to the allocated block */
601 Size size; /* size of block */
608 #ifdef T2K_MEM_LEAK_DBG
611 Region region, /* region ID */
612 Data *ptr, /* pointer to the allocated block */
613 Size size, /* size of block */
620 Region region, /* region ID */
621 Data *ptr, /* pointer to the allocated block */
622 Size size /* size of block */
626 S16 SFree(region, ptr, size)
627 Region region; /* region ID */
628 Data *ptr; /* pointer to the allocated block */
629 Size size; /* size of block */
635 /* ss001.301: Additions */
636 #ifdef SS_HISTOGRAM_SUPPORT
638 #endif /* SS_HISTOGRAM_SUPPORT */
642 /* Get the region which is assgined with this thread. The region was
643 * stored in the osCp and is taken with respect to thread ID. This macro
644 * is used only when SS_LOCKLESS_MEMORY flag is used and it overwrites
647 #ifdef XEON_SPECIFIC_CHANGES
650 region = SS_GET_THREAD_MEM_REGION();
653 #if (ERRCLASS & ERRCLS_INT_PAR)
654 /* validate region ID */
655 if (region >= SS_MAX_REGS)
657 SSLOGERROR(ERRCLS_INT_PAR, ESS040, region, "Invalid region");
661 /* ss021.103 - Addition to validate size and ptr */
664 SSLOGERROR(ERRCLS_INT_PAR, ESS041, region, "Invalid size");
669 if (ptr == (Data *)NULLP)
671 SSLOGERROR(ERRCLS_INT_PAR, ESS042, region, "Invalid ptr");
676 /* ss037.103 Removed the semaphore operation for performance enhancement */
679 /* acquire one semaphore, to protect against deregistration */
680 SS_ACQUIRE_SEMA(&osCp.regionTblSem, ret);
684 #if (ERRCLASS & ERRCLS_DEBUG)
685 SSLOGERROR(ERRCLS_DEBUG, ESS043, (ErrVal) ret,
686 "Could not lock region table");
692 #if (ERRCLASS & ERRCLS_INT_PAR)
693 /* verify that this region is around */
694 if (osCp.regionTbl[region].used == FALSE)
697 /* ss006.13: addition */
698 if( SS_RELEASE_SEMA(&osCp.regionTblSem) != ROK)
700 #if (ERRCLASS & ERRCLS_DEBUG)
701 SSLOGERROR(ERRCLS_DEBUG, ESS044, ERRZERO,
702 "Could not release the semaphore");
707 SSLOGERROR(ERRCLS_INT_PAR, ESS045, region, "Region not registered");
712 /* ss001.301: Additions */
713 #ifdef SS_HISTOGRAM_SUPPORT
714 SGetHstGrmInfo(&entId, &hstReg);
716 /* call the memory manager to free this memory */
717 ret = (osCp.regionTbl[region].free)
718 (osCp.regionTbl[region].regCb, ptr, size, line, fileName,
723 /* call the memory manager to free this memory */
724 #ifdef SS_LOCKLESS_MEMORY
725 #ifdef T2K_MEM_LEAK_DBG
726 ret = (osCp.dynRegionTbl[region].free)(osCp.dynRegionTbl[region].regCb, ptr, size,file,line);
728 ret = (osCp.dynRegionTbl[region].free)(osCp.dynRegionTbl[region].regCb, ptr, size);
731 #ifdef T2K_MEM_LEAK_DBG
732 ret = (osCp.regionTbl[region].free)(osCp.regionTbl[region].regCb, ptr, size,file,line);
734 ret = (osCp.regionTbl[region].free)(osCp.regionTbl[region].regCb, ptr, size);
736 #endif /* SS_LOCKLESS_MEMORY */
738 #endif /* SS_HISTOGRAM_SUPPORT */
740 /* ss037.103 Removed the semaphore operation for performance enhancement */
743 /* release the semaphore we took */
744 /* ss006.13: addition */
745 if( SS_RELEASE_SEMA(&osCp.regionTblSem) != ROK)
747 #if (ERRCLASS & ERRCLS_DEBUG)
748 SSLOGERROR(ERRCLS_DEBUG, ESS046, ERRZERO,
749 "Could not release the semaphore");
754 /* ss036.103 - changes to handle double free and trmapling return values
755 * This in turn may invoke SRegMemErrHdlr
757 #ifdef SSI_DEBUG_LEVEL1
758 /* handle the double free error here by calling the OS specific error handling function */
759 if ((ret == RDBLFREE) || (ret == RTRAMPLINGNOK))
761 SRegMemErrHdlr( region, ptr, ret);
763 #endif /* SSI_DEBUG_LEVEL1 */
770 /* ss001.301: Additions */
771 #ifdef SS_HISTOGRAM_SUPPORT
775 * Fun: SHstGrmInfoShow
777 * Desc: This function displays the memory usage information
778 * per Tapa task, which are registerd during initialization.
784 * Notes: A Sample Output from the function
785 * Memory Histogram for the Tapa task = (Entity Id)117
786 * ------Region Id = 0-------
787 * -----------Bucket Id = 0-----------
789 * File Name| Line | Bucket Alloc | Bytes Allocated | Bytes Wasted | Buckets Freed|Bytes Freed|
790 * lhi.c | 413 | 4 | 512 | 224 | 0 | 0 |
791 * hi_acc1.c| 333 | 0 | 0 | 0 | 2 | 256 |
792 * hi_acc1.c| 209 | 13 | 1664 | 728 | 0 | 0 |
803 S16 SHstGrmInfoShow(entId)
807 /*ss012.301 : Increased Buffer size to fix segmentation fault*/
808 Txt prntBuf[511]; /* Buffer to print on the console */
809 uint16_t ret = ROK; /* return value */
810 Ent tapaTsk[SS_MAX_TTSKS]; /* List of tapa task */
811 uint32_t tskCnt = 0; /* Tapa task Count */
812 uint32_t regCnt = 0; /* Region count */
813 uint32_t bktCnt = 0; /* Bucket count in each region */
814 CmHstGrmHashListCp *hashListCp = NULLP; /* Hash List ponter of bucket */
817 CmMemEntries *entry = NULLP;
818 uint32_t blkSize = 0;
821 memset(tapaTsk, ENTNC, sizeof(tapaTsk));
825 /* If user is not asking for specific entity id then,
826 * Take Tapa task entity id from the osCp structure and
827 * print the histogram for all tapa task */
828 ret = SGetTapaTskEntIds(tapaTsk);
832 /* If user asked for specific tapa task then print histogram
833 * for those tapa task */
834 for(tskCnt = 0; entId[tskCnt]; tskCnt++)
836 tapaTsk[tskCnt] = entId[tskCnt];
839 for (tskCnt = 0; tapaTsk[tskCnt] != ENTNC; tskCnt++)
841 sprintf(prntBuf, "\n\nMemory Histogram for the Tapa task = (Entity Id)%d\n", tapaTsk[tskCnt]);
843 for (regCnt = 0; regCnt < osCp.numRegions; regCnt++)
846 CmMmRegCb* regCb = (CmMmRegCb*)osCp.regionTbl[regCnt].regCb;
848 sprintf(prntBuf, "------Region Id = %d-------\n", regCb->region);
850 for (bktCnt = 0; bktCnt < regCb->numBkts; bktCnt++)
852 /* ss002.301 - Compilation fixes */
853 /*ss013.301 Fix for compilation warnings 32/64 bit */
855 sprintf(prntBuf, "-----------Bucket Id = %u-----------\n\n", bktCnt);
857 sprintf(prntBuf, "-----------Bucket Id = %lu-----------\n\n", bktCnt);
860 sprintf(prntBuf, "File Name | Line | Bucket Alloc | Bytes Allocated | Bytes Wasted | Buckets Freed|Bytes Freed|\n");
862 hashListCp = &(regCb->bktTbl[bktCnt].hstGrmHashListCp);
863 blkSize = regCb->bktTbl[bktCnt].size;
864 for(binCnt = 0; binCnt < CMM_HIST_MAX_MEM_BIN; binCnt++)
866 for (entCnt = 0; entCnt < hashListCp->hashList[binCnt].numOfEntries; entCnt++)
868 entry = &(hashListCp->hashList[binCnt].entries[entCnt]);
869 if(entry->entId == tapaTsk[tskCnt])
871 /* ss002.301 - Compilation fixes */
872 /*ss013.301 Fix for compilation warnings 32/64 bit */
875 "%-18s|%7u |%13u |%16u |%13u |%13u |%10u |\n",
876 entry->fileName, entry->line, entry->bucketAllocReq,
877 (blkSize*entry->bucketAllocReq), entry->wastedBytes,
878 entry->bucketFreeReq, (blkSize*entry->bucketFreeReq));
881 "%-18s|%7lu |%13lu |%16lu |%13lu |%13lu |%10lu |\n",
882 entry->fileName, entry->line, entry->bucketAllocReq,
883 (blkSize*entry->bucketAllocReq), entry->wastedBytes,
884 entry->bucketFreeReq, (blkSize*entry->bucketFreeReq));
888 }/* end of for. Entry count */
889 } /* End of for. Hash bin count */
892 sprintf(prntBuf, "\n\n----------- Heap blocks -----------\n\n");
894 sprintf(prntBuf, "File Name | Line | Heap Allocs | Bytes Allocated | Bytes Wasted | Heap Frees |Bytes Freed|\n");
896 hashListCp = &(regCb->heapCb.heapHstGrmHashListCp);
897 for(binCnt = 0; binCnt < CMM_HIST_MAX_MEM_BIN; binCnt++)
899 for (entCnt = 0; entCnt < hashListCp->hashList[binCnt].numOfEntries; entCnt++)
901 entry = &(hashListCp->hashList[binCnt].entries[entCnt]);
902 if(entry->entId == tapaTsk[tskCnt])
904 /* ss002.301 - Compilation fixes */
905 /*ss013.301 Fix for compilation warnings 32/64 bit */
908 "%-18s|%7u |%13u |%16u |%13u |%13u |%10u |\n",
909 entry->fileName, entry->line, entry->bucketAllocReq,
910 entry->allocBytes, entry->wastedBytes,
911 entry->bucketFreeReq, entry->freedBytes);
914 "%-18s|%7lu |%13lu |%16lu |%13lu |%13lu |%10lu |\n",
915 entry->fileName, entry->line, entry->bucketAllocReq,
916 entry->allocBytes, entry->wastedBytes,
917 entry->bucketFreeReq, entry->freedBytes);
921 }/* end of for. Entry count */
922 } /* End of for. Hash bin count */
923 }/* End of for. Region Count */
924 } /* End of for (Tapa task)*/
927 /* Print the memory information used at common, sample and ssi files.
928 we considerd common Sample file as invalid entity id. */
929 sprintf(prntBuf, "\n\nMemory Histogram for the Tapa task = (Entity Id = ENTNC)%d\n", ENTNC);
931 for (regCnt = 0; regCnt < osCp.numRegions; regCnt++)
933 CmMmRegCb* regCb = (CmMmRegCb*)osCp.regionTbl[regCnt].regCb;
935 sprintf(prntBuf, "------Region Id = %d-------\n", regCb->region);
937 for (bktCnt = 0; bktCnt < regCb->numBkts; bktCnt++)
939 /* ss002.301 - Compilation fixes */
940 /*ss013.301 Fix for compilation warnings 32/64 bit */
942 sprintf(prntBuf, "-----------Bucket Id = %u-----------\n\n", bktCnt);
944 sprintf(prntBuf, "-----------Bucket Id = %lu-----------\n\n", bktCnt);
947 sprintf(prntBuf, "File Name | Line | Bucket Alloc | Bytes Allocated | Bytes Wasted | Buckets Freed|Bytes Freed|\n");
949 hashListCp = &(regCb->bktTbl[bktCnt].hstGrmHashListCp);
950 blkSize = regCb->bktTbl[bktCnt].size;
951 for(binCnt = 0; binCnt < CMM_HIST_MAX_MEM_BIN; binCnt++)
953 for (entCnt = 0; entCnt < hashListCp->hashList[binCnt].numOfEntries; entCnt++)
955 entry = &(hashListCp->hashList[binCnt].entries[entCnt]);
956 if(entry->entId == tapaTsk[tskCnt])
958 /* ss002.301 - Compilation fixes */
959 /*ss013.301 Fix for compilation warnings 32/64 bit */
961 sprintf(prntBuf, "%-18s|%7u |%13u |%16u |%13u |%13u |%10u |\n",
962 entry->fileName, entry->line, entry->bucketAllocReq, (blkSize*entry->bucketAllocReq),
963 entry->wastedBytes, entry->bucketFreeReq, (blkSize*entry->bucketFreeReq));
965 sprintf(prntBuf, "%-18s|%7lu |%13lu |%16lu |%13lu |%13lu |%10lu |\n",
966 entry->fileName, entry->line, entry->bucketAllocReq, (blkSize*entry->bucketAllocReq),
967 entry->wastedBytes, entry->bucketFreeReq, (blkSize*entry->bucketFreeReq));
971 }/* end of for. Entry count */
972 } /* End of for. Hash bin count */
974 }/* End of for. Bucket Count */
976 sprintf(prntBuf, "\n\n----------- Heap blocks -----------\n\n");
978 sprintf(prntBuf, "File Name | Line | Heap Allocs | Bytes Allocated | Bytes Wasted | Heap Frees |Bytes Freed|\n");
980 hashListCp = &(regCb->heapCb.heapHstGrmHashListCp);
981 for(binCnt = 0; binCnt < CMM_HIST_MAX_MEM_BIN; binCnt++)
983 for (entCnt = 0; entCnt < hashListCp->hashList[binCnt].numOfEntries; entCnt++)
985 entry = &(hashListCp->hashList[binCnt].entries[entCnt]);
986 if(entry->entId == tapaTsk[tskCnt])
988 /* ss002.301 - Compilation fixes */
989 /*ss013.301 Fix for compilation warnings 32/64 bit */
992 "%-18s|%7u |%13u |%16u |%13u |%13u |%10u |\n",
993 entry->fileName, entry->line, entry->bucketAllocReq,
994 entry->allocBytes, entry->wastedBytes,
995 entry->bucketFreeReq, entry->freedBytes);
998 "%-18s|%7lu |%13lu |%16lu |%13lu |%13lu |%10lu |\n",
999 entry->fileName, entry->line, entry->bucketAllocReq,
1000 entry->allocBytes, entry->wastedBytes,
1001 entry->bucketFreeReq, entry->freedBytes);
1005 }/* end of for. Entry count */
1006 } /* End of for. Hash bin count */
1008 }/* End of for. Region Count */
1013 #endif /* SS_HISTOGRAM_SUPPORT */
1016 /**********************************************************************
1018 **********************************************************************/