From: Suren Baghdasaryan <surenb@google.com>
To: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Usama Arif <usamaarif642@gmail.com>,
Harry Yoo <harry.yoo@oracle.com>,
Andrew Morton <akpm@linux-foundation.org>,
hannes@cmpxchg.org, vlad.wing@gmail.com, linux-mm@kvack.org,
kent.overstreet@linux.dev, linux-kernel@vger.kernel.org,
kernel-team@meta.com, vbabka@suse.cz, cl@gentwo.org,
rientjes@google.com, roman.gushchin@linux.dev
Subject: Re: [PATCH 2/2] mm: slub: only warn once when allocating slab obj extensions fails
Date: Tue, 20 May 2025 08:14:35 -0700 [thread overview]
Message-ID: <CAJuCfpF4dar7p+wMucP8uWn23U5kzDCdSw48nZX=a=ei9ZSZOQ@mail.gmail.com> (raw)
In-Reply-To: <h7mwe4tr4r233zewdqaoehmmoktaljslgcxvr2qybon2vnxhrz@pbwpt253olkd>
On Tue, May 20, 2025 at 7:18 AM Shakeel Butt <shakeel.butt@linux.dev> wrote:
>
> On Tue, May 20, 2025 at 02:42:09PM +0100, Usama Arif wrote:
> >
> >
> > On 20/05/2025 14:34, Harry Yoo wrote:
> > > On Tue, May 20, 2025 at 01:25:47PM +0100, Usama Arif wrote:
> > >> In memory bound systems, a large number of warnings for failing this
> > >> allocation repeatedly may mask any real issues in the system
> > >> during memory pressure being reported in dmesg. Change this to
> > >> WARN_ONCE.
> > >>
> > >> Signed-off-by: Usama Arif <usamaarif642@gmail.com>
> > >> Reported-by: Vlad Poenaru <vlad.wing@gmail.com>
> > >> Closes: https://lore.kernel.org/all/17fab2d6-5a74-4573-bcc3-b75951508f0a@gmail.com/
> > >> ---
> > >
> > > Hi,
> > >
> > > Please Cc SLAB ALLOCATOR folks in MAINTAINERS on patches that touch
> > > slab code ;)
> > >
> >
> > Thanks for adding them to CC! I was just thinking of this as a memory
> > allocation profiling issue and added the maintainers for it,
> > but should have added slab maintainers as well.
> >
> >
> > >> mm/slub.c | 2 +-
> > >> 1 file changed, 1 insertion(+), 1 deletion(-)
> > >>
> > >> diff --git a/mm/slub.c b/mm/slub.c
> > >> index bf43c403ead2..97cb3d9e8d00 100644
> > >> --- a/mm/slub.c
> > >> +++ b/mm/slub.c
> > >> @@ -2102,7 +2102,7 @@ prepare_slab_obj_exts_hook(struct kmem_cache *s, gfp_t flags, void *p)
> > >>
> > >> slab = virt_to_slab(p);
> > >> if (!slab_obj_exts(slab) &&
> > >> - WARN(alloc_slab_obj_exts(slab, s, flags, false),
> > >> + WARN_ONCE(alloc_slab_obj_exts(slab, s, flags, false),
> > >> "%s, %s: Failed to create slab extension vector!\n",
> > >> __func__, s->name))
> > >
> > > I think this should be pr_warn_once()?
> > > I'm not sure why this was WARN() in the first place.
> > >
> >
> > Isn't WARN_ONCE the same as pr_warn_once but with needing the condition
> > of the first arg to be true? We only want to warn if alloc_slab_obj_exts
> > returns non-zero. So WARN_ONCE should be ok?
> >
>
> The difference is the impact on panic_on_warn users which are mostly
> testing bots.
Another difference is that pr_warn() does not spit out the call stack.
> This warning is not actionable, so I agree with Harry to
> covert this to pr_warn_once().
Makes sense.
>
> > > The coding style guide explicitly states that:
> > >> Do not WARN lightly
> > >> ===================
> > >>
> > >> WARN*() is intended for unexpected, this-should-never-happen situations.
> > >> WARN*() macros are not to be used for anything that is expected to happen
> > >> during normal operation. These are not pre- or post-condition asserts,
> > >> for example. Again: WARN*() must not be used for a condition that is
> > >> expected to trigger easily, for example, by user space actions.
> > >> pr_warn_once() is a possible alternative, if you need to notify the user
> > >> of a problem.
> > >
> > > And failing to allocate the extension vector can happen during normal
> > > operations.
> > >
> > > panic_on_warn users will be unhappy if they notice their kernel panicked
> > > just because their kernel failed to allocate slab extension vectors, which is
> > > a totally normal situtation.
> > >
> > >> return NULL;
> > >> --
> > >> 2.47.1
> > >>
> > >>
> > >
> >
next prev parent reply other threads:[~2025-05-20 15:14 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-20 12:25 [PATCH 1/2] mm: slub: allocate slab object extensions non-contiguously Usama Arif
2025-05-20 12:25 ` [PATCH 2/2] mm: slub: only warn once when allocating slab obj extensions fails Usama Arif
2025-05-20 13:34 ` Harry Yoo
2025-05-20 13:42 ` Usama Arif
2025-05-20 14:18 ` Shakeel Butt
2025-05-20 15:14 ` Suren Baghdasaryan [this message]
2025-05-20 15:22 ` Usama Arif
2025-05-22 0:16 ` Harry Yoo
2025-05-22 12:42 ` Usama Arif
2025-05-20 13:44 ` [PATCH 1/2] mm: slub: allocate slab object extensions non-contiguously Kent Overstreet
2025-05-20 13:46 ` Usama Arif
2025-05-20 14:01 ` Kent Overstreet
2025-05-20 14:24 ` Shakeel Butt
2025-05-20 14:28 ` Kent Overstreet
2025-05-20 17:44 ` Uladzislau Rezki
2025-05-20 17:47 ` Kent Overstreet
2025-05-20 17:57 ` Uladzislau Rezki
2025-05-20 17:58 ` Kent Overstreet
2025-05-20 18:59 ` Uladzislau Rezki
2025-05-20 14:13 ` Usama Arif
2025-05-20 15:20 ` Suren Baghdasaryan
2025-05-20 16:41 ` Kent Overstreet
2025-05-20 17:20 ` Suren Baghdasaryan
2025-05-20 17:25 ` Kent Overstreet
2025-05-20 17:18 ` Johannes Weiner
2025-05-20 14:01 ` Usama Arif
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAJuCfpF4dar7p+wMucP8uWn23U5kzDCdSw48nZX=a=ei9ZSZOQ@mail.gmail.com' \
--to=surenb@google.com \
--cc=akpm@linux-foundation.org \
--cc=cl@gentwo.org \
--cc=hannes@cmpxchg.org \
--cc=harry.yoo@oracle.com \
--cc=kent.overstreet@linux.dev \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=usamaarif642@gmail.com \
--cc=vbabka@suse.cz \
--cc=vlad.wing@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox