On Fri, Jun 05, 2020 at 06:24:33PM +0200, Vlastimil Babka wrote: > On 5/28/20 12:34 AM, Roman Gushchin wrote: > > diff --git a/mm/slab.h b/mm/slab.h > > index c49a863adb63..57b425d623e5 100644 > > --- a/mm/slab.h > > +++ b/mm/slab.h > ... > > @@ -526,8 +430,7 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x) > > * When kmemcg is not being used, both assignments should return the > > * same value. but we don't want to pay the assignment price in that > > * case. If it is not compiled in, the compiler should be smart enough > > - * to not do even the assignment. In that case, slab_equal_or_root > > - * will also be a constant. > > + * to not do even the assignment. > > */ > > if (!memcg_kmem_enabled() && > > Just realized that this test can go away - we don't have to call virt_to_cache() > due to kmemcg if there is just a single cache. Good point, will remove it in v6. Thanks! > > > !IS_ENABLED(CONFIG_SLAB_FREELIST_HARDENED) && > > @@ -535,7 +438,7 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x) > > return s; > > > > cachep = virt_to_cache(x); > > - WARN_ONCE(cachep && !slab_equal_or_root(cachep, s), > > + WARN_ONCE(cachep && cachep != s, > > "%s: Wrong slab cache. %s but object is from %s\n", > > __func__, s->name, cachep->name); > > return cachep; >