From: David Rientjes <rientjes@google.com>
To: Hyesoo Yu <hyesoo.yu@samsung.com>
Cc: Vlastimil Babka <vbabka@suse.cz>,
janghyuck.kim@samsung.com, Christoph Lameter <cl@linux.com>,
Pekka Enberg <penberg@kernel.org>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
Andrew Morton <akpm@linux-foundation.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Hyeonggon Yoo <42.hyeyoo@gmail.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] mm: slub: call WARN() instead of pr_err on slab_fix.
Date: Thu, 6 Feb 2025 09:59:33 -0800 (PST) [thread overview]
Message-ID: <c95fca1d-7905-502b-f6ef-e4c762285160@google.com> (raw)
In-Reply-To: <20250206061507.GA3959749@tiffany>
On Thu, 6 Feb 2025, Hyesoo Yu wrote:
> What do you think of this comment ? I will add it in patch v3.
>
> /*
> * slab_fix indicates that the value would be restored even if an error occurs.
> * Or, it is possible to trigger a panic without restoring using WARN() if panic_on_warn
> * is enabled. This can obtain a crash dump at the point of issue to debug.
> * It is advisable not to restore the data before calling slab_fix() to check for corrupted
> * data in the crash dump.
> */
>
Looks good, you might consider it to be a bit more brief, but otherwise
looks to clearly document the intent here.
Was thinking of something like:
/*
* If panic_on_warn is enabled to generate a crash dump, be careful to not
* restore data before this point.
*/
WARN()
But I don't feel strongly. Thanks!
> Thanks,
> Regards.
>
> > > >> Changes in v2:
> > > >> - Replace direct calling with BUG_ON with the use of WARN in slab_fix.
> > > >>
> > > >> Signed-off-by: Hyesoo Yu <hyesoo.yu@samsung.com>
> > > >> ---
> > > >> mm/slub.c | 10 +++++-----
> > > >> 1 file changed, 5 insertions(+), 5 deletions(-)
> > > >>
> > > >> diff --git a/mm/slub.c b/mm/slub.c
> > > >> index 1f50129dcfb3..ea956cb4b8be 100644
> > > >> --- a/mm/slub.c
> > > >> +++ b/mm/slub.c
> > > >> @@ -1043,7 +1043,7 @@ static void slab_fix(struct kmem_cache *s, char *fmt, ...)
> > > >> va_start(args, fmt);
> > > >> vaf.fmt = fmt;
> > > >> vaf.va = &args;
> > > >> - pr_err("FIX %s: %pV\n", s->name, &vaf);
> > > >> + WARN(1, "FIX %s: %pV\n", s->name, &vaf);
> > > >> va_end(args);
> > > >> }
> > > >>
> > > >> @@ -1106,8 +1106,8 @@ static bool freelist_corrupted(struct kmem_cache *s, struct slab *slab,
> > > >> if ((s->flags & SLAB_CONSISTENCY_CHECKS) &&
> > > >> !check_valid_pointer(s, slab, nextfree) && freelist) {
> > > >> object_err(s, slab, *freelist, "Freechain corrupt");
> > > >> - *freelist = NULL;
> > > >> slab_fix(s, "Isolate corrupted freechain");
> > > >> + *freelist = NULL;
> > > >> return true;
> > > >> }
> > > >>
> > > >> @@ -1445,9 +1445,9 @@ static int on_freelist(struct kmem_cache *s, struct slab *slab, void *search)
> > > >> set_freepointer(s, object, NULL);
> > > >> } else {
> > > >> slab_err(s, slab, "Freepointer corrupt");
> > > >> + slab_fix(s, "Freelist cleared");
> > > >> slab->freelist = NULL;
> > > >> slab->inuse = slab->objects;
> > > >> - slab_fix(s, "Freelist cleared");
> > > >> return 0;
> > > >> }
> > > >> break;
> > > >> @@ -1464,14 +1464,14 @@ static int on_freelist(struct kmem_cache *s, struct slab *slab, void *search)
> > > >> if (slab->objects != max_objects) {
> > > >> slab_err(s, slab, "Wrong number of objects. Found %d but should be %d",
> > > >> slab->objects, max_objects);
> > > >> - slab->objects = max_objects;
> > > >> slab_fix(s, "Number of objects adjusted");
> > > >> + slab->objects = max_objects;
> > > >> }
> > > >> if (slab->inuse != slab->objects - nr) {
> > > >> slab_err(s, slab, "Wrong object count. Counter is %d but counted were %d",
> > > >> slab->inuse, slab->objects - nr);
> > > >> - slab->inuse = slab->objects - nr;
> > > >> slab_fix(s, "Object count adjusted");
> > > >> + slab->inuse = slab->objects - nr;
> > > >> }
> > > >> return search == NULL;
> > > >> }
> > > >> --
> > > >> 2.48.0
> > > >>
> > > >>
> > >
> > >
> >
>
next prev parent reply other threads:[~2025-02-06 17:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20250205004741epcas2p3081bc2c97b7c1c27a9797cd498c4bc64@epcas2p3.samsung.com>
2025-02-05 0:46 ` Hyesoo Yu
2025-02-05 17:10 ` David Rientjes
2025-02-05 18:36 ` Vlastimil Babka
2025-02-06 2:57 ` David Rientjes
2025-02-06 6:15 ` Hyesoo Yu
2025-02-06 17:59 ` David Rientjes [this message]
2025-02-06 11:35 ` Vlastimil Babka
2025-02-07 3:28 ` Hyesoo Yu
2025-02-07 9:08 ` Vlastimil Babka
2025-02-10 3:53 ` Hyesoo Yu
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=c95fca1d-7905-502b-f6ef-e4c762285160@google.com \
--to=rientjes@google.com \
--cc=42.hyeyoo@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=hyesoo.yu@samsung.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=janghyuck.kim@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=penberg@kernel.org \
--cc=roman.gushchin@linux.dev \
--cc=vbabka@suse.cz \
/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