* [PATCH] mm/show_mem.c: report alloc tags in human readable units
@ 2024-09-06 0:53 Kent Overstreet
2024-09-06 3:32 ` Suren Baghdasaryan
0 siblings, 1 reply; 4+ messages in thread
From: Kent Overstreet @ 2024-09-06 0:53 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, linux-mm, Kent Overstreet, Suren Baghdasaryan
We already do this when reporting slab info - more consistent and more
readable.
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
---
mm/show_mem.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/mm/show_mem.c b/mm/show_mem.c
index 691e1b457d04..1b448e1ebd09 100644
--- a/mm/show_mem.c
+++ b/mm/show_mem.c
@@ -459,15 +459,18 @@ void __show_mem(unsigned int filter, nodemask_t *nodemask, int max_zone_idx)
struct codetag *ct = tags[i].ct;
struct alloc_tag *tag = ct_to_alloc_tag(ct);
struct alloc_tag_counters counter = alloc_tag_read(tag);
+ char bytes[10];
+
+ string_get_size(counter.bytes, 1, STRING_UNITS_2, bytes, sizeof(bytes));
/* Same as alloc_tag_to_text() but w/o intermediate buffer */
if (ct->modname)
- pr_notice("%12lli %8llu %s:%u [%s] func:%s\n",
- counter.bytes, counter.calls, ct->filename,
+ pr_notice("%12s %8llu %s:%u [%s] func:%s\n",
+ bytes, counter.calls, ct->filename,
ct->lineno, ct->modname, ct->function);
else
- pr_notice("%12lli %8llu %s:%u func:%s\n",
- counter.bytes, counter.calls, ct->filename,
+ pr_notice("%12s %8llu %s:%u func:%s\n",
+ bytes, counter.calls, ct->filename,
ct->lineno, ct->function);
}
}
--
2.45.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm/show_mem.c: report alloc tags in human readable units
2024-09-06 0:53 [PATCH] mm/show_mem.c: report alloc tags in human readable units Kent Overstreet
@ 2024-09-06 3:32 ` Suren Baghdasaryan
2024-09-06 3:52 ` Kent Overstreet
0 siblings, 1 reply; 4+ messages in thread
From: Suren Baghdasaryan @ 2024-09-06 3:32 UTC (permalink / raw)
To: Kent Overstreet; +Cc: akpm, linux-kernel, linux-mm
On Thu, Sep 5, 2024 at 5:53 PM Kent Overstreet
<kent.overstreet@linux.dev> wrote:
>
> We already do this when reporting slab info - more consistent and more
> readable.
Hi Kent,
I remember we discussed this before and agreed upon Pasha's suggestion
that if needed one could do:
# sort -g /proc/allocinfo|tail|numfmt --to=iec
2.8M 22648 fs/kernfs/dir.c:615 func:__kernfs_new_node
3.8M 953 mm/memory.c:4214 func:alloc_anon_folio
4.0M 1010 drivers/staging/ctagmod/ctagmod.c:20 [ctagmod]
func:ctagmod_start
4.1M 4 net/netfilter/nf_conntrack_core.c:2567
func:nf_ct_alloc_hashtable
6.0M 1532 mm/filemap.c:1919 func:__filemap_get_folio
8.8M 2785 kernel/fork.c:307 func:alloc_thread_stack_node
13M 234 block/blk-mq.c:3421 func:blk_mq_alloc_rqs
14M 3520 mm/mm_init.c:2530 func:alloc_large_system_hash
15M 3656 mm/readahead.c:247 func:page_cache_ra_unbounded
55M 4887 mm/slub.c:2259 func:alloc_slab_page
122M 31168 mm/page_ext.c:270 func:alloc_page_ext
That's even documented here:
https://elixir.bootlin.com/linux/v6.10.8/source/Documentation/mm/allocation-profiling.rst#L36
Did something change?
>
> Cc: Suren Baghdasaryan <surenb@google.com>
> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
> ---
> mm/show_mem.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/mm/show_mem.c b/mm/show_mem.c
> index 691e1b457d04..1b448e1ebd09 100644
> --- a/mm/show_mem.c
> +++ b/mm/show_mem.c
> @@ -459,15 +459,18 @@ void __show_mem(unsigned int filter, nodemask_t *nodemask, int max_zone_idx)
> struct codetag *ct = tags[i].ct;
> struct alloc_tag *tag = ct_to_alloc_tag(ct);
> struct alloc_tag_counters counter = alloc_tag_read(tag);
> + char bytes[10];
> +
> + string_get_size(counter.bytes, 1, STRING_UNITS_2, bytes, sizeof(bytes));
>
> /* Same as alloc_tag_to_text() but w/o intermediate buffer */
> if (ct->modname)
> - pr_notice("%12lli %8llu %s:%u [%s] func:%s\n",
> - counter.bytes, counter.calls, ct->filename,
> + pr_notice("%12s %8llu %s:%u [%s] func:%s\n",
> + bytes, counter.calls, ct->filename,
> ct->lineno, ct->modname, ct->function);
> else
> - pr_notice("%12lli %8llu %s:%u func:%s\n",
> - counter.bytes, counter.calls, ct->filename,
> + pr_notice("%12s %8llu %s:%u func:%s\n",
> + bytes, counter.calls, ct->filename,
> ct->lineno, ct->function);
> }
> }
> --
> 2.45.2
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm/show_mem.c: report alloc tags in human readable units
2024-09-06 3:32 ` Suren Baghdasaryan
@ 2024-09-06 3:52 ` Kent Overstreet
2024-09-06 20:10 ` Suren Baghdasaryan
0 siblings, 1 reply; 4+ messages in thread
From: Kent Overstreet @ 2024-09-06 3:52 UTC (permalink / raw)
To: Suren Baghdasaryan; +Cc: akpm, linux-kernel, linux-mm
On Thu, Sep 05, 2024 at 08:32:24PM GMT, Suren Baghdasaryan wrote:
> On Thu, Sep 5, 2024 at 5:53 PM Kent Overstreet
> <kent.overstreet@linux.dev> wrote:
> >
> > We already do this when reporting slab info - more consistent and more
> > readable.
>
> Hi Kent,
> I remember we discussed this before and agreed upon Pasha's suggestion
> that if needed one could do:
>
> # sort -g /proc/allocinfo|tail|numfmt --to=iec
> 2.8M 22648 fs/kernfs/dir.c:615 func:__kernfs_new_node
> 3.8M 953 mm/memory.c:4214 func:alloc_anon_folio
> 4.0M 1010 drivers/staging/ctagmod/ctagmod.c:20 [ctagmod]
> func:ctagmod_start
> 4.1M 4 net/netfilter/nf_conntrack_core.c:2567
> func:nf_ct_alloc_hashtable
> 6.0M 1532 mm/filemap.c:1919 func:__filemap_get_folio
> 8.8M 2785 kernel/fork.c:307 func:alloc_thread_stack_node
> 13M 234 block/blk-mq.c:3421 func:blk_mq_alloc_rqs
> 14M 3520 mm/mm_init.c:2530 func:alloc_large_system_hash
> 15M 3656 mm/readahead.c:247 func:page_cache_ra_unbounded
> 55M 4887 mm/slub.c:2259 func:alloc_slab_page
> 122M 31168 mm/page_ext.c:270 func:alloc_page_ext
>
> That's even documented here:
> https://elixir.bootlin.com/linux/v6.10.8/source/Documentation/mm/allocation-profiling.rst#L36
> Did something change?
That's for /proc/allocinfo, which this patch doesn't change - this is
the oom report.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm/show_mem.c: report alloc tags in human readable units
2024-09-06 3:52 ` Kent Overstreet
@ 2024-09-06 20:10 ` Suren Baghdasaryan
0 siblings, 0 replies; 4+ messages in thread
From: Suren Baghdasaryan @ 2024-09-06 20:10 UTC (permalink / raw)
To: Kent Overstreet; +Cc: akpm, linux-kernel, linux-mm
On Thu, Sep 5, 2024 at 8:52 PM Kent Overstreet
<kent.overstreet@linux.dev> wrote:
>
> On Thu, Sep 05, 2024 at 08:32:24PM GMT, Suren Baghdasaryan wrote:
> > On Thu, Sep 5, 2024 at 5:53 PM Kent Overstreet
> > <kent.overstreet@linux.dev> wrote:
> > >
> > > We already do this when reporting slab info - more consistent and more
> > > readable.
> >
> > Hi Kent,
> > I remember we discussed this before and agreed upon Pasha's suggestion
> > that if needed one could do:
> >
> > # sort -g /proc/allocinfo|tail|numfmt --to=iec
> > 2.8M 22648 fs/kernfs/dir.c:615 func:__kernfs_new_node
> > 3.8M 953 mm/memory.c:4214 func:alloc_anon_folio
> > 4.0M 1010 drivers/staging/ctagmod/ctagmod.c:20 [ctagmod]
> > func:ctagmod_start
> > 4.1M 4 net/netfilter/nf_conntrack_core.c:2567
> > func:nf_ct_alloc_hashtable
> > 6.0M 1532 mm/filemap.c:1919 func:__filemap_get_folio
> > 8.8M 2785 kernel/fork.c:307 func:alloc_thread_stack_node
> > 13M 234 block/blk-mq.c:3421 func:blk_mq_alloc_rqs
> > 14M 3520 mm/mm_init.c:2530 func:alloc_large_system_hash
> > 15M 3656 mm/readahead.c:247 func:page_cache_ra_unbounded
> > 55M 4887 mm/slub.c:2259 func:alloc_slab_page
> > 122M 31168 mm/page_ext.c:270 func:alloc_page_ext
> >
> > That's even documented here:
> > https://elixir.bootlin.com/linux/v6.10.8/source/Documentation/mm/allocation-profiling.rst#L36
> > Did something change?
>
> That's for /proc/allocinfo, which this patch doesn't change - this is
> the oom report.
Ah, got it! Looks reasonable to me.
Reviewed-by: Suren Baghdasaryan <surenb@google.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-09-06 20:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-06 0:53 [PATCH] mm/show_mem.c: report alloc tags in human readable units Kent Overstreet
2024-09-06 3:32 ` Suren Baghdasaryan
2024-09-06 3:52 ` Kent Overstreet
2024-09-06 20:10 ` Suren Baghdasaryan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox