Skip to contentSkip to conversation

lib: add version into /proc/allocinfo output

PATCH Superseded Suren Baghdasaryan 2 participants 3 messages May 14, 2024

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib: add version into /proc/allocinfo output

Add version string at the beginning of /proc/allocinfo to allow later format changes. Exampe output:

Quoted 1 line

head /proc/allocinfo

allocinfo - version: 1.0

           0        0 init/main.c:1314 func:do_initcalls
           0        0 init/do_mounts.c:353 func:mount_nodev_root
           0        0 init/do_mounts.c:187 func:mount_root_generic
           0        0 init/do_mounts.c:158 func:do_mount_root
           0        0 init/initramfs.c:493 func:unpack_to_rootfs
           0        0 init/initramfs.c:492 func:unpack_to_rootfs
           0        0 init/initramfs.c:491 func:unpack_to_rootfs
         512        1 arch/x86/events/rapl.c:681 func:init_rapl_pmus
         128        1 arch/x86/events/rapl.c:571 func:rapl_cpu_online
---
 Documentation/filesystems/proc.rst |  4 +--
 lib/alloc_tag.c                    | 42 +++++++++++++++++++-----------
 2 files changed, 29 insertions(+), 17 deletions(-)
Documentation/filesystems/proc.rst +2 -2
index 245269dd6e02..97d76adb1ecf 100644
@@ -961,13 +961,13 @@ Provides information about memory allocations at all locations in the code
 base. Each allocation in the code is identified by its source file, line
 number, module (if originates from a loadable module) and the function calling
 the allocation. The number of bytes allocated and number of calls at each
-location are reported.
+location are reported. The first line indicates the version of the file.
 
 Example output.
 
 ::
 
-    > sort -rn /proc/allocinfo
+    > tail -n +2 /proc/allocinfo | sort -rn
    127664128    31168 mm/page_ext.c:270 func:alloc_page_ext
     56373248     4737 mm/slub.c:2259 func:alloc_slab_page
     14880768     3633 mm/readahead.c:247 func:page_cache_ra_unbounded
lib/alloc_tag.c +27 -15

84 lines not on this page · raw message

base-commit: 7e8aafe0636cdcc5c9699ced05ff1f8ffcb937e2

Signature · 1 line
2.45.0.rc1.225.g2a3ae87e7f-goog
#1 lore raw
Quoted 6 lines · Suren Baghdasaryan

Add version string at the beginning of /proc/allocinfo to allow later format changes. Exampe output:

Quoted 1 line

head /proc/allocinfo

allocinfo - version: 1.0

Quoted 9 lines
           0        0 init/main.c:1314 func:do_initcalls
           0        0 init/do_mounts.c:353 func:mount_nodev_root
           0        0 init/do_mounts.c:187 func:mount_root_generic
           0        0 init/do_mounts.c:158 func:do_mount_root
           0        0 init/initramfs.c:493 func:unpack_to_rootfs
           0        0 init/initramfs.c:492 func:unpack_to_rootfs
           0        0 init/initramfs.c:491 func:unpack_to_rootfs
         512        1 arch/x86/events/rapl.c:681 func:init_rapl_pmus
         128        1 arch/x86/events/rapl.c:571 func:rapl_cpu_online

It would be also useful to add a header line:

$ head /proc/allocinfo
allocinfo - version: 1.0
# <size> <calls> <tag>
            0        0 init/main.c:1314 func:do_initcalls
            0        0 init/do_mounts.c:353 func:mount_nodev_root
            0        0 init/do_mounts.c:187 func:mount_root_generic
            0        0 init/do_mounts.c:158 func:do_mount_root
...

This would be the same as in /proc/slabinfo:

$ sudo head /proc/slabinfo
slabinfo - version: 2.1
# name            <active_objs> <num_objs> <objsize> <objperslab>
<pagesperslab> : tunables <limit> <batchcount> <sharedfactor> :
slabdata <active_slabs> <num_slabs> <sharedavail>
pid_3               2730   2730    192   42    2 : tunables    0    0
  0 : slabdata     65     65      0
..

Pasha

#2 lore raw
Quoted 30 lines · Pasha Tatashin
Quoted 6 lines · Suren Baghdasaryan

Add version string at the beginning of /proc/allocinfo to allow later format changes. Exampe output:

Quoted 1 line

head /proc/allocinfo

allocinfo - version: 1.0

Quoted 9 lines
           0        0 init/main.c:1314 func:do_initcalls
           0        0 init/do_mounts.c:353 func:mount_nodev_root
           0        0 init/do_mounts.c:187 func:mount_root_generic
           0        0 init/do_mounts.c:158 func:do_mount_root
           0        0 init/initramfs.c:493 func:unpack_to_rootfs
           0        0 init/initramfs.c:492 func:unpack_to_rootfs
           0        0 init/initramfs.c:491 func:unpack_to_rootfs
         512        1 arch/x86/events/rapl.c:681 func:init_rapl_pmus
         128        1 arch/x86/events/rapl.c:571 func:rapl_cpu_online

It would be also useful to add a header line:

$ head /proc/allocinfo
allocinfo - version: 1.0
# <size> <calls> <tag>
            0        0 init/main.c:1314 func:do_initcalls
            0        0 init/do_mounts.c:353 func:mount_nodev_root
            0        0 init/do_mounts.c:187 func:mount_root_generic
            0        0 init/do_mounts.c:158 func:do_mount_root
...

This would be the same as in /proc/slabinfo:

Quoted 8 lines
$ sudo head /proc/slabinfo
slabinfo - version: 2.1
# name            <active_objs> <num_objs> <objsize> <objperslab>
<pagesperslab> : tunables <limit> <batchcount> <sharedfactor> :
slabdata <active_slabs> <num_slabs> <sharedavail>
pid_3               2730   2730    192   42    2 : tunables    0    0
  0 : slabdata     65     65      0
..

Thanks! Addressed in v2:
https://lore.kernel.org/all/[email protected]/

Quoted 2 lines

Pasha