On 2/26/25 09:12, Hyesoo Yu wrote: > If a slab object is corrupted or an error occurs in its internal > value, continuing after restoration may cause other side effects. > At this point, it is difficult to debug because the problem occurred > in the past. It is useful to use WARN() to catch errors at the point > of issue because WARN() could trigger panic for system debugging when > panic_on_warn is enabled. WARN() is added where to detect the error > on slab_err and object_err. > > It makes sense to only do the WARN() after printing the logs. slab_err > is splited to __slab_err that calls the WARN() and it is called after > printing logs. > > Changes in v4: > - Remove WARN() in kmem_cache_destroy to remove redundant warning. > > Changes in v3: > - move the WARN from slab_fix to slab_err, object_err and check_obj to > use WARN on all error reporting paths. > > Changes in v2: > - Replace direct calling with BUG_ON with the use of WARN in slab_fix. > > Signed-off-by: Hyesoo Yu <hyesoo.yu@xxxxxxxxxxx> As Harry said. I'll remove that locally. > --- > mm/slab_common.c | 3 --- > mm/slub.c | 31 +++++++++++++++++++------------ > 2 files changed, 19 insertions(+), 15 deletions(-) > > diff --git a/mm/slab_common.c b/mm/slab_common.c > index 477fa471da18..d13f4ffe252b 100644 > --- a/mm/slab_common.c > +++ b/mm/slab_common.c > @@ -517,9 +517,6 @@ void kmem_cache_destroy(struct kmem_cache *s) > kasan_cache_shutdown(s); > > err = __kmem_cache_shutdown(s); > - if (!slab_in_kunit_test()) > - WARN(err, "%s %s: Slab cache still has objects when called from %pS", > - __func__, s->name, (void *)_RET_IP_); I think I'll keep this one, because the more detailed warning via list_slab_objects() is only enabled with CONFIG_SLUB_DEBUG. If it's not enabled, the kmem_cache_destroy() failure rather should not be silent. So slab_in_kunit_test() would also stay. > } else { > - list_slab_objects(s, slab, > - "Objects remaining in %s on __kmem_cache_shutdown()"); > + list_slab_objects(s, slab); I tried to extract slab_bug() and __slab_err() from list_slab_objects() but they were also only available with CONFIG_SLUB_DEBUG. Perhaps we can improve that, but as a follow-up cleanup so we don't hold this up further. > } > } > spin_unlock_irq(&n->list_lock);