Re: [PATCH] mm, slub: print CPU id on slab OOM

From: Vlastimil Babka
Date: Sun Aug 11 2024 - 16:14:54 EST


On 8/7/24 1:26 AM, Axel Rasmussen wrote:
> Depending on how remote_node_defrag_ratio is configured, allocations can
> end up in this path as a result of the local node being OOM, despite the
> allocation overall being unconstrained (node == -1).
>
> When we print a warning, printing the current CPU makes that situation
> more clear (i.e., you can immediately see which node's OOM status
> matters for the allocation at hand).
>
> Signed-off-by: Axel Rasmussen <axelrasmussen@xxxxxxxxxx>
> ---
> mm/slub.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/mm/slub.c b/mm/slub.c
> index c9d8a2497fd6..7148047998de 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -3422,7 +3422,8 @@ slab_out_of_memory(struct kmem_cache *s, gfp_t gfpflags, int nid)
> if ((gfpflags & __GFP_NOWARN) || !__ratelimit(&slub_oom_rs))
> return;
>
> - pr_warn("SLUB: Unable to allocate memory on node %d, gfp=%#x(%pGg)\n",
> + pr_warn("SLUB: Unable to allocate memory for CPU %u on node %d, gfp=%#x(%pGg)\n",

BTW, wouldn't "on CPU" be more correct, as "for CPU" might be misleading
that we are somehow constrained to that CPU?

> + preemptible() ? raw_smp_processor_id() : smp_processor_id(),

Also could we just use raw_smp_processor_id() always here? I don't see
this has any advantage or am I missing something?

> nid, gfpflags, &gfpflags);
> pr_warn(" cache: %s, object size: %u, buffer size: %u, default order: %u, min order: %u\n",
> s->name, s->object_size, s->size, oo_order(s->oo),