For readability, move NAME column in "kmem -s" output to the last of line. --- help.c | 136 +++++++++++++++++++++++++++++++-------------------------------- memory.c | 44 +++++---------------- 2 files changed, 78 insertions(+), 102 deletions(-) diff --git a/help.c b/help.c index 83cda7c..a189038 100644 --- a/help.c +++ b/help.c @@ -6692,8 +6692,8 @@ char *help_kmem[] = { " Find all of the combined slab/page structures that are used by", " the kmalloc-8192 slab cache:\n", " %s> kmem -s kmalloc-8192", -" CACHE NAME OBJSIZE ALLOCATED TOTAL SLABS SSIZE", -" ffff880215802e00 kmalloc-8192 8192 65 80 20 32k", +" CACHE OBJSIZE ALLOCATED TOTAL SLABS SSIZE NAME", +" ffff880215802e00 8192 65 80 20 32k kmalloc-8192", " %s> kmem -m slab_cache | grep ffff880215802e00", " ffffea0004117800 ffff880215802e00 ", " ffffea00041ca600 ffff880215802e00 ", @@ -6889,72 +6889,72 @@ char *help_kmem[] = { " ", " Display kmalloc() slab data:\n", " %s> kmem -s", -" CACHE NAME OBJSIZE ALLOCATED TOTAL SLABS SSIZE", -" c02eadc0 kmem_cache 232 58 68 4 4k", -" f79c2888 ip_vs_conn 128 0 0 0 4k", -" f79c2970 tcp_tw_bucket 96 0 0 0 4k", -" f79c2a58 tcp_bind_bucket 32 12 565 5 4k", -" f79c2b40 tcp_open_request 64 0 59 1 4k", -" f79c2c28 inet_peer_cache 64 1 59 1 4k", -" f79c2d10 ip_fib_hash 32 11 339 3 4k", -" f79c2df8 ip_dst_cache 160 8 120 5 4k", -" f79c2ee0 arp_cache 128 1 30 1 4k", -" c8402970 blkdev_requests 96 30208 37800 945 4k", -" c8402a58 nfs_read_data 384 0 0 0 4k", -" c8402b40 nfs_write_data 384 0 0 0 4k", -" c8402c28 nfs_page 96 0 0 0 4k", -" c8402d10 dnotify cache 20 0 0 0 4k", -" c8402df8 file lock cache 92 3 336 8 4k", -" c8402ee0 fasync cache 16 0 0 0 4k", -" c84027a0 uid_cache 32 3 339 3 4k", -" c84026b8 skbuff_head_cache 160 320 624 26 4k", -" c84025d0 sock 832 32 180 20 8k", -" c84024e8 sigqueue 132 0 203 7 4k", -" c8402400 cdev_cache 64 19 472 8 4k", -" c8402318 bdev_cache 64 8 236 4 4k", -" c8402230 mnt_cache 96 11 120 3 4k", -" c8402148 inode_cache 480 817 848 106 4k", -" c8402060 dentry_cache 128 1352 1470 49 4k", -" c8403ee0 filp 96 244 440 11 4k", -" c8403df8 names_cache 4096 0 12 12 4k", -" c8403d10 buffer_head 96 14936 16000 400 4k", -" c8403c28 mm_struct 128 25 240 8 4k", -" c8403b40 vm_area_struct 64 393 1298 22 4k", -" c8403a58 fs_cache 64 30 472 8 4k", -" c8403970 files_cache 416 30 135 15 4k", -" c8403888 signal_act 1312 32 99 33 4k", -" c84037a0 size-131072(DMA) 131072 0 0 0 128k", -" c84036b8 size-131072 131072 1 1 1 128k", -" c84035d0 size-65536(DMA) 65536 0 0 0 64k", -" c84034e8 size-65536 65536 0 0 0 64k", -" c8403400 size-32768(DMA) 32768 0 0 0 32k", -" c8403318 size-32768 32768 0 1 1 32k", -" c8403230 size-16384(DMA) 16384 0 0 0 16k", -" c8403148 size-16384 16384 0 0 0 16k", -" c8403060 size-8192(DMA) 8192 0 0 0 8k", -" c8401ee0 size-8192 8192 1 2 2 8k", -" c8401df8 size-4096(DMA) 4096 0 0 0 4k", -" c8401d10 size-4096 4096 30 30 30 4k", -" c8401c28 size-2048(DMA) 2048 0 0 0 4k", -" c8401b40 size-2048 2048 37 132 66 4k", -" c8401a58 size-1024(DMA) 1024 0 0 0 4k", -" c8401970 size-1024 1024 301 328 82 4k", -" c8401888 size-512(DMA) 512 0 0 0 4k", -" c84017a0 size-512 512 141 168 21 4k", -" c84016b8 size-256(DMA) 256 0 0 0 4k", -" c84015d0 size-256 256 80 435 29 4k", -" c84014e8 size-128(DMA) 128 0 0 0 4k", -" c8401400 size-128 128 508 840 28 4k", -" c8401318 size-64(DMA) 64 0 0 0 4k", -" c8401230 size-64 64 978 1357 23 4k", -" c8401148 size-32(DMA) 32 0 0 0 4k", -" c8401060 size-32 32 1244 1808 16 4k", +" CACHE OBJSIZE ALLOCATED TOTAL SLABS SSIZE NAME", +" c02eadc0 232 58 68 4 4k kmem_cache", +" f79c2888 128 0 0 0 4k ip_vs_conn", +" f79c2970 96 0 0 0 4k tcp_tw_bucket", +" f79c2a58 32 12 565 5 4k tcp_bind_bucket", +" f79c2b40 64 0 59 1 4k tcp_open_request", +" f79c2c28 64 1 59 1 4k inet_peer_cache", +" f79c2d10 32 11 339 3 4k ip_fib_hash", +" f79c2df8 160 8 120 5 4k ip_dst_cache", +" f79c2ee0 128 1 30 1 4k arp_cache", +" c8402970 96 30208 37800 945 4k blkdev_requests", +" c8402a58 384 0 0 0 4k nfs_read_data", +" c8402b40 384 0 0 0 4k nfs_write_data", +" c8402c28 96 0 0 0 4k nfs_page", +" c8402d10 20 0 0 0 4k dnotify cache", +" c8402df8 92 3 336 8 4k file lock cache", +" c8402ee0 16 0 0 0 4k fasync cache", +" c84027a0 32 3 339 3 4k uid_cache", +" c84026b8 160 320 624 26 4k skbuff_head_cache", +" c84025d0 832 32 180 20 8k sock", +" c84024e8 132 0 203 7 4k sigqueue", +" c8402400 64 19 472 8 4k cdev_cache", +" c8402318 64 8 236 4 4k bdev_cache", +" c8402230 96 11 120 3 4k mnt_cache", +" c8402148 480 817 848 106 4k inode_cache", +" c8402060 128 1352 1470 49 4k dentry_cache", +" c8403ee0 96 244 440 11 4k filp", +" c8403df8 4096 0 12 12 4k names_cache", +" c8403d10 96 14936 16000 400 4k buffer_head", +" c8403c28 128 25 240 8 4k mm_struct", +" c8403b40 64 393 1298 22 4k vm_area_struct", +" c8403a58 64 30 472 8 4k fs_cache", +" c8403970 416 30 135 15 4k files_cache", +" c8403888 1312 32 99 33 4k signal_act", +" c84037a0 131072 0 0 0 128k size-131072(DMA)", +" c84036b8 131072 1 1 1 128k size-131072", +" c84035d0 65536 0 0 0 64k size-65536(DMA)", +" c84034e8 65536 0 0 0 64k size-65536", +" c8403400 32768 0 0 0 32k size-32768(DMA)", +" c8403318 32768 0 1 1 32k size-32768", +" c8403230 16384 0 0 0 16k size-16384(DMA)", +" c8403148 16384 0 0 0 16k size-16384", +" c8403060 8192 0 0 0 8k size-8192(DMA)", +" c8401ee0 8192 1 2 2 8k size-8192", +" c8401df8 4096 0 0 0 4k size-4096(DMA)", +" c8401d10 4096 30 30 30 4k size-4096", +" c8401c28 2048 0 0 0 4k size-2048(DMA)", +" c8401b40 2048 37 132 66 4k size-2048", +" c8401a58 1024 0 0 0 4k size-1024(DMA)", +" c8401970 1024 301 328 82 4k size-1024", +" c8401888 512 0 0 0 4k size-512(DMA)", +" c84017a0 512 141 168 21 4k size-512", +" c84016b8 256 0 0 0 4k size-256(DMA)", +" c84015d0 256 80 435 29 4k size-256", +" c84014e8 128 0 0 0 4k size-128(DMA)", +" c8401400 128 508 840 28 4k size-128", +" c8401318 64 0 0 0 4k size-64(DMA)", +" c8401230 64 978 1357 23 4k size-64", +" c8401148 32 0 0 0 4k size-32(DMA)", +" c8401060 32 1244 1808 16 4k size-32", " ", " Display all slab data in the \"arp_cache\" cache:\n", " %s> kmem -S arp_cache", -" CACHE NAME OBJSIZE ALLOCATED TOTAL SLABS SSIZE", -" f79c2ee0 arp_cache 128 1 30 1 4k", +" CACHE OBJSIZE ALLOCATED TOTAL SLABS SSIZE NAME", +" f79c2ee0 128 1 30 1 4k arp_cache", " SLAB MEMORY TOTAL ALLOCATED FREE", " f729d000 f729d0a0 30 1 29", " FREE / [ALLOCATED]", @@ -6991,8 +6991,8 @@ char *help_kmem[] = { " ", " Search the kmalloc() slab subsystem for address c3fbdb60:\n", " %s> kmem -s c3fbdb60", -" CACHE NAME OBJSIZE ALLOCATED TOTAL SLABS SSIZE", -" c8402970 blkdev_requests 96 30208 37800 945 4k", +" CACHE OBJSIZE ALLOCATED TOTAL SLABS SSIZE NAME", +" c8402970 96 30208 37800 945 4k blkdev_requests", " SLAB MEMORY TOTAL ALLOCATED FREE", " c3fbd020 c3fbd0e0 40 40 0", " FREE / [ALLOCATED]", @@ -7000,8 +7000,8 @@ char *help_kmem[] = { " ", " Make a generic search (no flags) for the same address c3fbdb60:\n", " %s> kmem c3fbdb60 ", -" CACHE NAME OBJSIZE ALLOCATED TOTAL SLABS SSIZE", -" c8402970 blkdev_requests 96 30208 37800 945 4k", +" CACHE OBJSIZE ALLOCATED TOTAL SLABS SSIZE NAME", +" c8402970 96 30208 37800 945 4k blkdev_requests", " SLAB MEMORY TOTAL ALLOCATED FREE", " c3fbd020 c3fbd0e0 40 40 0 ", " FREE / [ALLOCATED]", diff --git a/memory.c b/memory.c index 2e48d7b..5bcf09e 100644 --- a/memory.c +++ b/memory.c @@ -9378,7 +9378,7 @@ kmem_cache_init(void) if (!strlen(kmem_cache_hdr)) sprintf(kmem_cache_hdr, - "CACHE%sNAME OBJSIZE ALLOCATED TOTAL SLABS SSIZE\n", + "CACHE%s OBJSIZE ALLOCATED TOTAL SLABS SSIZE NAME\n", space(VADDR_PRLEN > 8 ? 12 : 4)); if (!strlen(free_inuse_hdr)) @@ -9969,54 +9969,30 @@ static void dump_kmem_cache_info(struct meminfo *si) { char b1[BUFSIZE]; - char b2[BUFSIZE]; - int namelen, sizelen, spacelen; ulong objsize, allocated, total; if (si->flags & SLAB_GATHER_FAILURE) error(INFO, "%s: cannot gather relevant slab data\n", si->curname); - fprintf(fp, "%s ", - mkstring(b1, VADDR_PRLEN, LJUST|LONG_HEX, MKSTR(si->cache))); - objsize = (vt->flags & KMALLOC_SLUB) ? si->objsize : si->size; - namelen = strlen(si->curname); - sprintf(b2, "%ld", objsize); - sizelen = strlen(b2); - spacelen = 0; - - if (namelen++ > 18) { - spacelen = 29 - namelen - sizelen; - fprintf(fp, "%s%s%ld ", si->curname, - space(spacelen <= 0 ? 1 : spacelen), objsize); - if (spacelen > 0) - spacelen = 1; - if (si->flags & SLAB_GATHER_FAILURE) - sprintf(b1, "%c%ds ", '%', 9 + spacelen - 1); - else - sprintf(b1, "%c%dld ", '%', 9 + spacelen - 1); - } else { - fprintf(fp, "%-18s %8ld ", si->curname, objsize); - if (si->flags & SLAB_GATHER_FAILURE) - sprintf(b1, "%c%ds ", '%', 9); - else - sprintf(b1, "%c%dld ", '%', 9); - } + fprintf(fp, "%s %8ld ", + mkstring(b1, VADDR_PRLEN, LJUST|LONG_HEX, MKSTR(si->cache)), + objsize); if (si->flags & SLAB_GATHER_FAILURE) { - fprintf(fp, b1, "?"); - fprintf(fp, "%8s %5s %4ldk\n", - "?", "?", si->slabsize/1024); + fprintf(fp, "%9s %8s %5s ", "?", "?", "?"); } else { allocated = (vt->flags & (PERCPU_KMALLOC_V1|PERCPU_KMALLOC_V2)) ? si->inuse - si->cpucached_cache : si->inuse; total = (vt->flags & KMALLOC_SLUB) ? si->inuse + si->free : si->num_slabs * si->c_num; - fprintf(fp, b1, allocated); - fprintf(fp, "%8ld %5ld %4ldk\n", total, - si->num_slabs, si->slabsize/1024); + + fprintf(fp, "%9ld %8ld %5ld ", + allocated, total, si->num_slabs); } + + fprintf(fp, "%4ldk %s\n", si->slabsize/1024, si->curname); } #define DUMP_SLAB_INFO() \ -- 1.8.3.1 -- Crash-utility mailing list Crash-utility@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/crash-utility