// // Clean up memory tracking. // static __inline void MemoryTrackStop( void ) { #if defined(MEM_TRACK_ON) LIST_ITEM *pListItem; if( !pMemTracker ) return; if( QListCount( &pMemTracker->AllocList ) ) { // There are still items in the list. Print them out. MemoryDisplayUsage(1, 0, 0); } else { MsgOut( "\n*** Memory tracker stopped, no leaks detected ***\n" ); MsgOut("IbAccess max allocations=%u bytes=%u\n", max_allocations, max_allocated); } // Free all allocated headers. SpinLockAcquire( &pMemTracker->Lock ); while( (pListItem = QListRemoveHead( &pMemTracker->AllocList )) != NULL ) { SpinLockRelease( &pMemTracker->Lock ); MEMORY_DEALLOCATE_PRIV( PARENT_STRUCT( pListItem, MEM_ALLOC_HDR, ListItem ) ); SpinLockAcquire( &pMemTracker->Lock ); } while( (pListItem = QListRemoveHead( &pMemTracker->FreeHrdList )) != NULL ) { SpinLockRelease( &pMemTracker->Lock ); MEMORY_DEALLOCATE_PRIV( PARENT_STRUCT( pListItem, MEM_ALLOC_HDR, ListItem ) ); SpinLockAcquire( &pMemTracker->Lock ); } SpinLockRelease( &pMemTracker->Lock ); DestroyMemTracker(); #endif // MEM_TRACK_ON }
/* If possible compress a point into a simpler format * This looks for lists which consist of a single entry or * lists which include all the components of a higher level type */ void PointFabricCompress(Point *point) { switch (point->Type) { case POINT_TYPE_NONE: break; case POINT_TYPE_PORT: break; case POINT_TYPE_PORT_LIST: { PortData *portp; LIST_ITERATOR head = ListHead(&point->u.portList); ASSERT(head); ASSERT(ListCount(&point->u.portList) >= 1); portp = (PortData*)ListObj(head); if (ListCount(&point->u.portList) == 1) { /* degenerate case, simplify as a single port */ PointFabricDestroy(point); PointInitSimple(point, POINT_TYPE_PORT, portp); } else if (ListCount(&point->u.portList) == cl_qmap_count(&portp->nodep->Ports)) { /* maybe we can consolidate to a single node */ LIST_ITERATOR i; DLIST *pList = &point->u.portList; for (i=ListHead(pList); portp && i != NULL; i = ListNext(pList, i)) { if (portp->nodep != ((PortData*)ListObj(i))->nodep) portp = NULL; /* not in same node, flag for below */ } if (portp) { /* degenerate case, simplify as a single node */ PointFabricDestroy(point); PointInitSimple(point, POINT_TYPE_NODE, portp->nodep); } #if 0 } else { // the likelihood of this is low for port oriented searches // and it would present just the system image guide in the summary // and may be less obvious to the user than a list of ports /* maybe we can consolidate to a single system */ LIST_ITERATOR i; DLIST *pList = &point->u.portList; for (i=ListHead(pList); portp && i != NULL; i = ListNext(pList, i)) { if (portp->nodep->systemp != ((PortData*)ListObj(i))->nodep->systemp) portp = NULL; /* not in same system, flag for below */ } if (portp) { /* all ports are in same system. is it a complete list? */ /* count ports in the system */ uint32 count = 0; cl_map_item_t *p; for (p=cl_qmap_head(&portp->nodep->systemp->Nodes); p != cl_qmap_end(&portp->nodep->systemp->Nodes); p = cl_qmap_next(p)) { NodeData *nodep = PARENT_STRUCT(p, NodeData, SystemNodesEntry); count += cl_qmap_count(&nodep->Ports); } if (ListCount(&point->u.portList) != count) portp = NULL; /* incomplete list, flag for below */ } if (portp) { /* degenerate case, simplify as a single system */ PointFabricDestroy(point); PointInitSimple(point, POINT_TYPE_SYSTEM, portp->nodep->systemp); } #endif } break; } case POINT_TYPE_NODE: break; case POINT_TYPE_NODE_LIST: { NodeData *nodep; LIST_ITERATOR head = ListHead(&point->u.nodeList); ASSERT(head); ASSERT(ListCount(&point->u.nodeList) >= 1); nodep = (NodeData*)ListObj(head); if (ListCount(&point->u.nodeList) == 1) { /* degenerate case, simplify as a single node */ PointFabricDestroy(point); PointInitSimple(point, POINT_TYPE_NODE, nodep); } else if (ListCount(&point->u.nodeList) == cl_qmap_count(&nodep->systemp->Nodes)) { /* maybe we can consolidate to a single system */ LIST_ITERATOR i; DLIST *pList = &point->u.nodeList; for (i=ListHead(pList); nodep && i != NULL; i = ListNext(pList, i)) { if (nodep->systemp != ((NodeData*)ListObj(i))->systemp) nodep = NULL; /* not in same system, flag for below */ } if (nodep) { /* degenerate case, simplify as a single system */ PointFabricDestroy(point); PointInitSimple(point, POINT_TYPE_SYSTEM, nodep->systemp); } } break; } #if !defined(VXWORKS) || defined(BUILD_DMC) case POINT_TYPE_IOC: break; case POINT_TYPE_IOC_LIST: { IocData *iocp; LIST_ITERATOR head = ListHead(&point->u.iocList); ASSERT(head); ASSERT(ListCount(&point->u.iocList) >= 1); iocp = (IocData*)ListObj(head); if (ListCount(&point->u.iocList) == 1) { /* degenerate case, simplify as a single IOC */ PointFabricDestroy(point); PointInitSimple(point, POINT_TYPE_IOC, iocp); } else if (ListCount(&point->u.iocList) == QListCount(&iocp->ioup->Iocs)) { /* maybe we can consolidate to a single node */ LIST_ITERATOR i; DLIST *pList = &point->u.iocList; for (i=ListHead(pList); iocp && i != NULL; i = ListNext(pList, i)) { if (iocp->ioup != ((IocData*)ListObj(i))->ioup) iocp = NULL; /* not in same iou, flag for below */ } if (iocp) { /* degenerate case, simplify as a single node */ PointFabricDestroy(point); PointInitSimple(point, POINT_TYPE_NODE, iocp->ioup->nodep); } #if 0 } else { // the likelihood of this is low for ioc oriented searches // and it would present just the system image guide in the summary // and may be less obvious to the user than a list of iocs /* maybe we can consolidate to a single system */ LIST_ITERATOR i; DLIST *pList = &point->u.iocList; for (i=ListHead(pList); iocp && i != NULL; i = ListNext(pList, i)) { if (iocp->ioup->nodep->systemp != ((IocData*)ListObj(i))->ioup->nodep->systemp) iocp = NULL; /* not in same system, flag for below */ } if (iocp) { /* all IOCs are in same system. is it a complete list? */ /* count IOCs in the system */ uint32 count = 0; cl_map_item_t *p; for (p=cl_qmap_head(&iocp->ioup->nodep->systemp->Nodes); p != cl_qmap_end(&iocp->ioup->nodep->systemp->Nodes); p = cl_qmap_next(p)) { NodeData *nodep = PARENT_STRUCT(p, NodeData, SystemNodesEntry); if (nodep->ioup) count += QListCount(&nodep->ioup->Iocs); } if (ListCount(&point->u.iocList) != count) iocp = NULL; /* incomplete list, flag for below */ } if (iocp) { /* degenerate case, simplify as a single system */ PointFabricDestroy(point); PointInitSimple(point, POINT_TYPE_SYSTEM, iocp->ioup->nodep->systemp); } #endif } break; } #endif case POINT_TYPE_SYSTEM: break; } }