* [PATCH 0/5] Some tiny clean ups for SLUB
@ 2023-04-13 14:34 sxwjean
2023-04-13 14:34 ` [PATCH 1/5] slub: Correct the error code when slab_kset is NULL sxwjean
` (5 more replies)
0 siblings, 6 replies; 9+ messages in thread
From: sxwjean @ 2023-04-13 14:34 UTC (permalink / raw)
To: cl, penberg, rientjes, iamjoonsoo.kim, akpm, vbabka,
roman.gushchin, 42.hyeyoo, keescook
Cc: linux-mm, linux-kernel, linux-hardening, Xiongwei Song
From: Xiongwei Song <xiongwei.song@windriver.com>
Hi,
Just clean ups, no any functionality changed. Thanks for your time.
Xiongwei Song (5):
slub: Correct the error code when slab_kset is NULL
slub: Put objects_show() into CONFIG_SLUB_DEBUG enabled block
slub: Remove CONFIG_SMP defined check
slub: Remove slabs_node() function
slub: Don't read nr_slabs and total_objects directly
mm/slub.c | 45 +++++++++++++++++----------------------------
1 file changed, 17 insertions(+), 28 deletions(-)
--
2.30.2
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH 1/5] slub: Correct the error code when slab_kset is NULL 2023-04-13 14:34 [PATCH 0/5] Some tiny clean ups for SLUB sxwjean @ 2023-04-13 14:34 ` sxwjean 2023-04-13 14:34 ` [PATCH 2/5] slub: Put objects_show() into CONFIG_SLUB_DEBUG enabled block sxwjean ` (4 subsequent siblings) 5 siblings, 0 replies; 9+ messages in thread From: sxwjean @ 2023-04-13 14:34 UTC (permalink / raw) To: cl, penberg, rientjes, iamjoonsoo.kim, akpm, vbabka, roman.gushchin, 42.hyeyoo, keescook Cc: linux-mm, linux-kernel, linux-hardening, Xiongwei Song From: Xiongwei Song <xiongwei.song@windriver.com> The -ENOSYS is inproper when kset_create_and_add call returns a NULL pointer, the failure more likely is because lacking memory, hence returning -ENOMEM is better. Signed-off-by: Xiongwei Song <xiongwei.song@windriver.com> --- mm/slub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/slub.c b/mm/slub.c index 28ca576d988d..5cc56f780241 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -6225,7 +6225,7 @@ static int __init slab_sysfs_init(void) if (!slab_kset) { mutex_unlock(&slab_mutex); pr_err("Cannot register slab subsystem.\n"); - return -ENOSYS; + return -ENOMEM; } slab_state = FULL; -- 2.30.2 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/5] slub: Put objects_show() into CONFIG_SLUB_DEBUG enabled block 2023-04-13 14:34 [PATCH 0/5] Some tiny clean ups for SLUB sxwjean 2023-04-13 14:34 ` [PATCH 1/5] slub: Correct the error code when slab_kset is NULL sxwjean @ 2023-04-13 14:34 ` sxwjean 2023-04-13 17:53 ` kernel test robot 2023-04-13 14:34 ` [PATCH 3/5] slub: Remove CONFIG_SMP defined check sxwjean ` (3 subsequent siblings) 5 siblings, 1 reply; 9+ messages in thread From: sxwjean @ 2023-04-13 14:34 UTC (permalink / raw) To: cl, penberg, rientjes, iamjoonsoo.kim, akpm, vbabka, roman.gushchin, 42.hyeyoo, keescook Cc: linux-mm, linux-kernel, linux-hardening, Xiongwei Song From: Xiongwei Song <xiongwei.song@windriver.com> The SO_ALL|SO_OBJECTS pair is only used when enabling CONFIG_SLUB_DEBUG option, so the objects_show() definition should be surrounded by CONFIG_SLUB_DEBUG too. Signed-off-by: Xiongwei Song <xiongwei.song@windriver.com> --- mm/slub.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 5cc56f780241..b8afe12ebba1 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5613,12 +5613,6 @@ static ssize_t cpu_slabs_show(struct kmem_cache *s, char *buf) } SLAB_ATTR_RO(cpu_slabs); -static ssize_t objects_show(struct kmem_cache *s, char *buf) -{ - return show_slab_objects(s, buf, SO_ALL|SO_OBJECTS); -} -SLAB_ATTR_RO(objects); - static ssize_t objects_partial_show(struct kmem_cache *s, char *buf) { return show_slab_objects(s, buf, SO_PARTIAL|SO_OBJECTS); @@ -5713,6 +5707,12 @@ static ssize_t total_objects_show(struct kmem_cache *s, char *buf) } SLAB_ATTR_RO(total_objects); +static ssize_t objects_show(struct kmem_cache *s, char *buf) +{ + return show_slab_objects(s, buf, SO_ALL|SO_OBJECTS); +} +SLAB_ATTR_RO(objects); + static ssize_t sanity_checks_show(struct kmem_cache *s, char *buf) { return sysfs_emit(buf, "%d\n", !!(s->flags & SLAB_CONSISTENCY_CHECKS)); -- 2.30.2 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/5] slub: Put objects_show() into CONFIG_SLUB_DEBUG enabled block 2023-04-13 14:34 ` [PATCH 2/5] slub: Put objects_show() into CONFIG_SLUB_DEBUG enabled block sxwjean @ 2023-04-13 17:53 ` kernel test robot 2023-04-17 7:12 ` Song, Xiongwei 0 siblings, 1 reply; 9+ messages in thread From: kernel test robot @ 2023-04-13 17:53 UTC (permalink / raw) To: sxwjean, cl, penberg, rientjes, iamjoonsoo.kim, akpm, vbabka, roman.gushchin, 42.hyeyoo, keescook Cc: oe-kbuild-all, linux-mm, linux-kernel, linux-hardening, Xiongwei Song Hi, kernel test robot noticed the following build errors: [auto build test ERROR on vbabka-slab/for-next] [also build test ERROR on linus/master v6.3-rc6 next-20230412] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/sxwjean-me-com/slub-Correct-the-error-code-when-slab_kset-is-NULL/20230413-223743 base: git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab.git for-next patch link: https://lore.kernel.org/r/20230413143452.211250-3-sxwjean%40me.com patch subject: [PATCH 2/5] slub: Put objects_show() into CONFIG_SLUB_DEBUG enabled block config: i386-randconfig-a012-20230410 (https://download.01.org/0day-ci/archive/20230414/202304140110.lzjsYh25-lkp@intel.com/config) compiler: gcc-11 (Debian 11.3.0-8) 11.3.0 reproduce (this is a W=1 build): # https://github.com/intel-lab-lkp/linux/commit/356157a450e3905cdc07fd0e77c4ac42974706c7 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review sxwjean-me-com/slub-Correct-the-error-code-when-slab_kset-is-NULL/20230413-223743 git checkout 356157a450e3905cdc07fd0e77c4ac42974706c7 # save the config file mkdir build_dir && cp config build_dir/.config make W=1 O=build_dir ARCH=i386 olddefconfig make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> | Link: https://lore.kernel.org/oe-kbuild-all/202304140110.lzjsYh25-lkp@intel.com/ All errors (new ones prefixed by >>): >> mm/slub.c:5947:10: error: 'objects_attr' undeclared here (not in a function); did you mean 'object_size_attr'? 5947 | &objects_attr.attr, | ^~~~~~~~~~~~ | object_size_attr vim +5947 mm/slub.c b84e04f1baeebe6 Imran Khan 2022-08-15 5939 81819f0fc8285a2 Christoph Lameter 2007-05-06 5940 static struct attribute *slab_attrs[] = { 81819f0fc8285a2 Christoph Lameter 2007-05-06 5941 &slab_size_attr.attr, 81819f0fc8285a2 Christoph Lameter 2007-05-06 5942 &object_size_attr.attr, 81819f0fc8285a2 Christoph Lameter 2007-05-06 5943 &objs_per_slab_attr.attr, 81819f0fc8285a2 Christoph Lameter 2007-05-06 5944 &order_attr.attr, 73d342b169db700 David Rientjes 2009-02-22 5945 &min_partial_attr.attr, 49e2258586b4236 Christoph Lameter 2011-08-09 5946 &cpu_partial_attr.attr, 81819f0fc8285a2 Christoph Lameter 2007-05-06 @5947 &objects_attr.attr, 205ab99dd103e3d Christoph Lameter 2008-04-14 5948 &objects_partial_attr.attr, 81819f0fc8285a2 Christoph Lameter 2007-05-06 5949 &partial_attr.attr, 81819f0fc8285a2 Christoph Lameter 2007-05-06 5950 &cpu_slabs_attr.attr, 81819f0fc8285a2 Christoph Lameter 2007-05-06 5951 &ctor_attr.attr, 81819f0fc8285a2 Christoph Lameter 2007-05-06 5952 &aliases_attr.attr, 81819f0fc8285a2 Christoph Lameter 2007-05-06 5953 &align_attr.attr, 81819f0fc8285a2 Christoph Lameter 2007-05-06 5954 &hwcache_align_attr.attr, 81819f0fc8285a2 Christoph Lameter 2007-05-06 5955 &reclaim_account_attr.attr, 81819f0fc8285a2 Christoph Lameter 2007-05-06 5956 &destroy_by_rcu_attr.attr, a5a84755c590041 Christoph Lameter 2010-10-05 5957 &shrink_attr.attr, 49e2258586b4236 Christoph Lameter 2011-08-09 5958 &slabs_cpu_partial_attr.attr, ab4d5ed5eeda4f5 Christoph Lameter 2010-10-05 5959 #ifdef CONFIG_SLUB_DEBUG a5a84755c590041 Christoph Lameter 2010-10-05 5960 &total_objects_attr.attr, a5a84755c590041 Christoph Lameter 2010-10-05 5961 &slabs_attr.attr, a5a84755c590041 Christoph Lameter 2010-10-05 5962 &sanity_checks_attr.attr, a5a84755c590041 Christoph Lameter 2010-10-05 5963 &trace_attr.attr, 81819f0fc8285a2 Christoph Lameter 2007-05-06 5964 &red_zone_attr.attr, 81819f0fc8285a2 Christoph Lameter 2007-05-06 5965 &poison_attr.attr, 81819f0fc8285a2 Christoph Lameter 2007-05-06 5966 &store_user_attr.attr, 53e15af03be4fda Christoph Lameter 2007-05-06 5967 &validate_attr.attr, ab4d5ed5eeda4f5 Christoph Lameter 2010-10-05 5968 #endif 81819f0fc8285a2 Christoph Lameter 2007-05-06 5969 #ifdef CONFIG_ZONE_DMA 81819f0fc8285a2 Christoph Lameter 2007-05-06 5970 &cache_dma_attr.attr, 81819f0fc8285a2 Christoph Lameter 2007-05-06 5971 #endif 81819f0fc8285a2 Christoph Lameter 2007-05-06 5972 #ifdef CONFIG_NUMA 9824601ead957a2 Christoph Lameter 2008-01-07 5973 &remote_node_defrag_ratio_attr.attr, 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5974 #endif 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5975 #ifdef CONFIG_SLUB_STATS 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5976 &alloc_fastpath_attr.attr, 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5977 &alloc_slowpath_attr.attr, 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5978 &free_fastpath_attr.attr, 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5979 &free_slowpath_attr.attr, 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5980 &free_frozen_attr.attr, 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5981 &free_add_partial_attr.attr, 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5982 &free_remove_partial_attr.attr, 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5983 &alloc_from_partial_attr.attr, 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5984 &alloc_slab_attr.attr, 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5985 &alloc_refill_attr.attr, e36a2652d7d1ad9 Christoph Lameter 2011-06-01 5986 &alloc_node_mismatch_attr.attr, 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5987 &free_slab_attr.attr, 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5988 &cpuslab_flush_attr.attr, 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5989 &deactivate_full_attr.attr, 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5990 &deactivate_empty_attr.attr, 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5991 &deactivate_to_head_attr.attr, 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5992 &deactivate_to_tail_attr.attr, 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5993 &deactivate_remote_frees_attr.attr, 03e404af26dc2ea Christoph Lameter 2011-06-01 5994 &deactivate_bypass_attr.attr, 65c3376aaca96c6 Christoph Lameter 2008-04-14 5995 &order_fallback_attr.attr, b789ef518b2a723 Christoph Lameter 2011-06-01 5996 &cmpxchg_double_fail_attr.attr, b789ef518b2a723 Christoph Lameter 2011-06-01 5997 &cmpxchg_double_cpu_fail_attr.attr, 49e2258586b4236 Christoph Lameter 2011-08-09 5998 &cpu_partial_alloc_attr.attr, 49e2258586b4236 Christoph Lameter 2011-08-09 5999 &cpu_partial_free_attr.attr, 8028dcea8abbbd5 Alex Shi 2012-02-03 6000 &cpu_partial_node_attr.attr, 8028dcea8abbbd5 Alex Shi 2012-02-03 6001 &cpu_partial_drain_attr.attr, 81819f0fc8285a2 Christoph Lameter 2007-05-06 6002 #endif 4c13dd3b48fcb6f Dmitry Monakhov 2010-02-26 6003 #ifdef CONFIG_FAILSLAB 4c13dd3b48fcb6f Dmitry Monakhov 2010-02-26 6004 &failslab_attr.attr, 4c13dd3b48fcb6f Dmitry Monakhov 2010-02-26 6005 #endif 346907ceb9d11b9 Vlastimil Babka 2022-11-16 6006 #ifdef CONFIG_HARDENED_USERCOPY 8eb8284b4129061 David Windsor 2017-06-10 6007 &usersize_attr.attr, 346907ceb9d11b9 Vlastimil Babka 2022-11-16 6008 #endif b84e04f1baeebe6 Imran Khan 2022-08-15 6009 #ifdef CONFIG_KFENCE b84e04f1baeebe6 Imran Khan 2022-08-15 6010 &skip_kfence_attr.attr, b84e04f1baeebe6 Imran Khan 2022-08-15 6011 #endif 4c13dd3b48fcb6f Dmitry Monakhov 2010-02-26 6012 81819f0fc8285a2 Christoph Lameter 2007-05-06 6013 NULL 81819f0fc8285a2 Christoph Lameter 2007-05-06 6014 }; 81819f0fc8285a2 Christoph Lameter 2007-05-06 6015 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests ^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH 2/5] slub: Put objects_show() into CONFIG_SLUB_DEBUG enabled block 2023-04-13 17:53 ` kernel test robot @ 2023-04-17 7:12 ` Song, Xiongwei 0 siblings, 0 replies; 9+ messages in thread From: Song, Xiongwei @ 2023-04-17 7:12 UTC (permalink / raw) To: kernel test robot, sxwjean, cl, penberg, rientjes, iamjoonsoo.kim, akpm, vbabka, roman.gushchin, 42.hyeyoo, keescook Cc: oe-kbuild-all, linux-mm, linux-kernel, linux-hardening Sorry, the diff should be: diff --git a/mm/slub.c b/mm/slub.c index 28ca576d988d..0d99440727a5 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5613,12 +5613,6 @@ static ssize_t cpu_slabs_show(struct kmem_cache *s, char *buf) } SLAB_ATTR_RO(cpu_slabs); -static ssize_t objects_show(struct kmem_cache *s, char *buf) -{ - return show_slab_objects(s, buf, SO_ALL|SO_OBJECTS); -} -SLAB_ATTR_RO(objects); - static ssize_t objects_partial_show(struct kmem_cache *s, char *buf) { return show_slab_objects(s, buf, SO_PARTIAL|SO_OBJECTS); @@ -5713,6 +5707,12 @@ static ssize_t total_objects_show(struct kmem_cache *s, char *buf) } SLAB_ATTR_RO(total_objects); +static ssize_t objects_show(struct kmem_cache *s, char *buf) +{ + return show_slab_objects(s, buf, SO_ALL|SO_OBJECTS); +} +SLAB_ATTR_RO(objects); + static ssize_t sanity_checks_show(struct kmem_cache *s, char *buf) { return sysfs_emit(buf, "%d\n", !!(s->flags & SLAB_CONSISTENCY_CHECKS)); @@ -5944,7 +5944,6 @@ static struct attribute *slab_attrs[] = { &order_attr.attr, &min_partial_attr.attr, &cpu_partial_attr.attr, - &objects_attr.attr, &objects_partial_attr.attr, &partial_attr.attr, &cpu_slabs_attr.attr, @@ -5958,6 +5957,7 @@ static struct attribute *slab_attrs[] = { &slabs_cpu_partial_attr.attr, #ifdef CONFIG_SLUB_DEBUG &total_objects_attr.attr, + &objects_attr.attr, &slabs_attr.attr, &sanity_checks_attr.attr, &trace_attr.attr, Regards, Xiongwei > -----Original Message----- > From: kernel test robot <lkp@intel.com> > Sent: 2023年4月14日 1:54 > To: sxwjean@me.com; cl@linux.com; penberg@kernel.org; > rientjes@google.com; iamjoonsoo.kim@lge.com; akpm@linux- > foundation.org; vbabka@suse.cz; roman.gushchin@linux.dev; > 42.hyeyoo@gmail.com; keescook@chromium.org > Cc: oe-kbuild-all@lists.linux.dev; linux-mm@kvack.org; linux- > kernel@vger.kernel.org; linux-hardening@vger.kernel.org; Song, Xiongwei > <Xiongwei.Song@windriver.com> > Subject: Re: [PATCH 2/5] slub: Put objects_show() into > CONFIG_SLUB_DEBUG enabled block > > CAUTION: This email comes from a non Wind River email account! > Do not click links or open attachments unless you recognize the sender and > know the content is safe. > > Hi, > > kernel test robot noticed the following build errors: > > [auto build test ERROR on vbabka-slab/for-next] > [also build test ERROR on linus/master v6.3-rc6 next-20230412] > [If your patch is applied to the wrong git tree, kindly drop us a note. > And when submitting patch, we suggest to use '--base' as documented in > https://git-scm.com/docs/git-format-patch#_base_tree_information] > > url: https://github.com/intel-lab-lkp/linux/commits/sxwjean-me-com/slub- > Correct-the-error-code-when-slab_kset-is-NULL/20230413-223743 > base: git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab.git for-next > patch link: https://lore.kernel.org/r/20230413143452.211250-3- > sxwjean%40me.com > patch subject: [PATCH 2/5] slub: Put objects_show() into > CONFIG_SLUB_DEBUG enabled block > config: i386-randconfig-a012-20230410 (https://download.01.org/0day- > ci/archive/20230414/202304140110.lzjsYh25-lkp@intel.com/config) > compiler: gcc-11 (Debian 11.3.0-8) 11.3.0 > reproduce (this is a W=1 build): > # https://github.com/intel-lab- > lkp/linux/commit/356157a450e3905cdc07fd0e77c4ac42974706c7 > git remote add linux-review https://github.com/intel-lab-lkp/linux > git fetch --no-tags linux-review sxwjean-me-com/slub-Correct-the-error- > code-when-slab_kset-is-NULL/20230413-223743 > git checkout 356157a450e3905cdc07fd0e77c4ac42974706c7 > # save the config file > mkdir build_dir && cp config build_dir/.config > make W=1 O=build_dir ARCH=i386 olddefconfig > make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash > > If you fix the issue, kindly add following tag where applicable > | Reported-by: kernel test robot <lkp@intel.com> > | Link: https://lore.kernel.org/oe-kbuild-all/202304140110.lzjsYh25- > lkp@intel.com/ > > All errors (new ones prefixed by >>): > > >> mm/slub.c:5947:10: error: 'objects_attr' undeclared here (not in a > function); did you mean 'object_size_attr'? > 5947 | &objects_attr.attr, > | ^~~~~~~~~~~~ > | object_size_attr > > > vim +5947 mm/slub.c > > b84e04f1baeebe6 Imran Khan 2022-08-15 5939 > 81819f0fc8285a2 Christoph Lameter 2007-05-06 5940 static struct attribute > *slab_attrs[] = { > 81819f0fc8285a2 Christoph Lameter 2007-05-06 5941 &slab_size_attr.attr, > 81819f0fc8285a2 Christoph Lameter 2007-05-06 5942 > &object_size_attr.attr, > 81819f0fc8285a2 Christoph Lameter 2007-05-06 5943 > &objs_per_slab_attr.attr, > 81819f0fc8285a2 Christoph Lameter 2007-05-06 5944 &order_attr.attr, > 73d342b169db700 David Rientjes 2009-02-22 5945 &min_partial_attr.attr, > 49e2258586b4236 Christoph Lameter 2011-08-09 5946 > &cpu_partial_attr.attr, > 81819f0fc8285a2 Christoph Lameter 2007-05-06 @5947 &objects_attr.attr, > 205ab99dd103e3d Christoph Lameter 2008-04-14 5948 > &objects_partial_attr.attr, > 81819f0fc8285a2 Christoph Lameter 2007-05-06 5949 &partial_attr.attr, > 81819f0fc8285a2 Christoph Lameter 2007-05-06 5950 &cpu_slabs_attr.attr, > 81819f0fc8285a2 Christoph Lameter 2007-05-06 5951 &ctor_attr.attr, > 81819f0fc8285a2 Christoph Lameter 2007-05-06 5952 &aliases_attr.attr, > 81819f0fc8285a2 Christoph Lameter 2007-05-06 5953 &align_attr.attr, > 81819f0fc8285a2 Christoph Lameter 2007-05-06 5954 > &hwcache_align_attr.attr, > 81819f0fc8285a2 Christoph Lameter 2007-05-06 5955 > &reclaim_account_attr.attr, > 81819f0fc8285a2 Christoph Lameter 2007-05-06 5956 > &destroy_by_rcu_attr.attr, > a5a84755c590041 Christoph Lameter 2010-10-05 5957 &shrink_attr.attr, > 49e2258586b4236 Christoph Lameter 2011-08-09 5958 > &slabs_cpu_partial_attr.attr, > ab4d5ed5eeda4f5 Christoph Lameter 2010-10-05 5959 #ifdef > CONFIG_SLUB_DEBUG > a5a84755c590041 Christoph Lameter 2010-10-05 5960 > &total_objects_attr.attr, > a5a84755c590041 Christoph Lameter 2010-10-05 5961 &slabs_attr.attr, > a5a84755c590041 Christoph Lameter 2010-10-05 5962 > &sanity_checks_attr.attr, > a5a84755c590041 Christoph Lameter 2010-10-05 5963 &trace_attr.attr, > 81819f0fc8285a2 Christoph Lameter 2007-05-06 5964 &red_zone_attr.attr, > 81819f0fc8285a2 Christoph Lameter 2007-05-06 5965 &poison_attr.attr, > 81819f0fc8285a2 Christoph Lameter 2007-05-06 5966 &store_user_attr.attr, > 53e15af03be4fda Christoph Lameter 2007-05-06 5967 &validate_attr.attr, > ab4d5ed5eeda4f5 Christoph Lameter 2010-10-05 5968 #endif > 81819f0fc8285a2 Christoph Lameter 2007-05-06 5969 #ifdef > CONFIG_ZONE_DMA > 81819f0fc8285a2 Christoph Lameter 2007-05-06 5970 > &cache_dma_attr.attr, > 81819f0fc8285a2 Christoph Lameter 2007-05-06 5971 #endif > 81819f0fc8285a2 Christoph Lameter 2007-05-06 5972 #ifdef CONFIG_NUMA > 9824601ead957a2 Christoph Lameter 2008-01-07 5973 > &remote_node_defrag_ratio_attr.attr, > 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5974 #endif > 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5975 #ifdef > CONFIG_SLUB_STATS > 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5976 > &alloc_fastpath_attr.attr, > 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5977 > &alloc_slowpath_attr.attr, > 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5978 > &free_fastpath_attr.attr, > 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5979 > &free_slowpath_attr.attr, > 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5980 > &free_frozen_attr.attr, > 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5981 > &free_add_partial_attr.attr, > 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5982 > &free_remove_partial_attr.attr, > 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5983 > &alloc_from_partial_attr.attr, > 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5984 &alloc_slab_attr.attr, > 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5985 &alloc_refill_attr.attr, > e36a2652d7d1ad9 Christoph Lameter 2011-06-01 5986 > &alloc_node_mismatch_attr.attr, > 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5987 &free_slab_attr.attr, > 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5988 > &cpuslab_flush_attr.attr, > 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5989 > &deactivate_full_attr.attr, > 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5990 > &deactivate_empty_attr.attr, > 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5991 > &deactivate_to_head_attr.attr, > 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5992 > &deactivate_to_tail_attr.attr, > 8ff12cfc009a2a3 Christoph Lameter 2008-02-07 5993 > &deactivate_remote_frees_attr.attr, > 03e404af26dc2ea Christoph Lameter 2011-06-01 5994 > &deactivate_bypass_attr.attr, > 65c3376aaca96c6 Christoph Lameter 2008-04-14 5995 > &order_fallback_attr.attr, > b789ef518b2a723 Christoph Lameter 2011-06-01 5996 > &cmpxchg_double_fail_attr.attr, > b789ef518b2a723 Christoph Lameter 2011-06-01 5997 > &cmpxchg_double_cpu_fail_attr.attr, > 49e2258586b4236 Christoph Lameter 2011-08-09 5998 > &cpu_partial_alloc_attr.attr, > 49e2258586b4236 Christoph Lameter 2011-08-09 5999 > &cpu_partial_free_attr.attr, > 8028dcea8abbbd5 Alex Shi 2012-02-03 6000 > &cpu_partial_node_attr.attr, > 8028dcea8abbbd5 Alex Shi 2012-02-03 6001 > &cpu_partial_drain_attr.attr, > 81819f0fc8285a2 Christoph Lameter 2007-05-06 6002 #endif > 4c13dd3b48fcb6f Dmitry Monakhov 2010-02-26 6003 #ifdef > CONFIG_FAILSLAB > 4c13dd3b48fcb6f Dmitry Monakhov 2010-02-26 6004 &failslab_attr.attr, > 4c13dd3b48fcb6f Dmitry Monakhov 2010-02-26 6005 #endif > 346907ceb9d11b9 Vlastimil Babka 2022-11-16 6006 #ifdef > CONFIG_HARDENED_USERCOPY > 8eb8284b4129061 David Windsor 2017-06-10 6007 &usersize_attr.attr, > 346907ceb9d11b9 Vlastimil Babka 2022-11-16 6008 #endif > b84e04f1baeebe6 Imran Khan 2022-08-15 6009 #ifdef CONFIG_KFENCE > b84e04f1baeebe6 Imran Khan 2022-08-15 6010 &skip_kfence_attr.attr, > b84e04f1baeebe6 Imran Khan 2022-08-15 6011 #endif > 4c13dd3b48fcb6f Dmitry Monakhov 2010-02-26 6012 > 81819f0fc8285a2 Christoph Lameter 2007-05-06 6013 NULL > 81819f0fc8285a2 Christoph Lameter 2007-05-06 6014 }; > 81819f0fc8285a2 Christoph Lameter 2007-05-06 6015 > > -- > 0-DAY CI Kernel Test Service > https://github.com/intel/lkp-tests ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/5] slub: Remove CONFIG_SMP defined check 2023-04-13 14:34 [PATCH 0/5] Some tiny clean ups for SLUB sxwjean 2023-04-13 14:34 ` [PATCH 1/5] slub: Correct the error code when slab_kset is NULL sxwjean 2023-04-13 14:34 ` [PATCH 2/5] slub: Put objects_show() into CONFIG_SLUB_DEBUG enabled block sxwjean @ 2023-04-13 14:34 ` sxwjean 2023-04-13 14:34 ` [PATCH 4/5] slub: Remove slabs_node() function sxwjean ` (2 subsequent siblings) 5 siblings, 0 replies; 9+ messages in thread From: sxwjean @ 2023-04-13 14:34 UTC (permalink / raw) To: cl, penberg, rientjes, iamjoonsoo.kim, akpm, vbabka, roman.gushchin, 42.hyeyoo, keescook Cc: linux-mm, linux-kernel, linux-hardening, Xiongwei Song From: Xiongwei Song <xiongwei.song@windriver.com> As CONFIG_SMP is one of dependencies of CONFIG_SLUB_CPU_PARTIAL, so if CONFIG_SLUB_CPU_PARTIAL is defined then CONFIG_SMP must be defined, no need to check CONFIG_SMP definition here. Signed-off-by: Xiongwei Song <xiongwei.song@windriver.com> --- mm/slub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/slub.c b/mm/slub.c index b8afe12ebba1..d897df8fe7e7 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5641,7 +5641,7 @@ static ssize_t slabs_cpu_partial_show(struct kmem_cache *s, char *buf) objects = (slabs * oo_objects(s->oo)) / 2; len += sysfs_emit_at(buf, len, "%d(%d)", objects, slabs); -#if defined(CONFIG_SLUB_CPU_PARTIAL) && defined(CONFIG_SMP) +#ifdef CONFIG_SLUB_CPU_PARTIAL for_each_online_cpu(cpu) { struct slab *slab; -- 2.30.2 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 4/5] slub: Remove slabs_node() function 2023-04-13 14:34 [PATCH 0/5] Some tiny clean ups for SLUB sxwjean ` (2 preceding siblings ...) 2023-04-13 14:34 ` [PATCH 3/5] slub: Remove CONFIG_SMP defined check sxwjean @ 2023-04-13 14:34 ` sxwjean 2023-04-13 14:34 ` [PATCH 5/5] slub: Don't read nr_slabs and total_objects directly sxwjean 2023-04-18 7:50 ` [PATCH 0/5] Some tiny clean ups for SLUB Vlastimil Babka 5 siblings, 0 replies; 9+ messages in thread From: sxwjean @ 2023-04-13 14:34 UTC (permalink / raw) To: cl, penberg, rientjes, iamjoonsoo.kim, akpm, vbabka, roman.gushchin, 42.hyeyoo, keescook Cc: linux-mm, linux-kernel, linux-hardening, Xiongwei Song From: Xiongwei Song <xiongwei.song@windriver.com> When traversing nodes one by one, the get_node() function called in for_each_kmem_cache_node macro, no need to call get_node() again in slabs_node(), just reading nr_slabs field should be enough. However, the node_nr_slabs() function can do this. Hence, the slabs_node() function is not needed anymore. Signed-off-by: Xiongwei Song <xiongwei.song@windriver.com> --- mm/slub.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index d897df8fe7e7..33b4fec6bc7a 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1344,14 +1344,6 @@ static void remove_full(struct kmem_cache *s, struct kmem_cache_node *n, struct list_del(&slab->slab_list); } -/* Tracking of the number of slabs for debugging purposes */ -static inline unsigned long slabs_node(struct kmem_cache *s, int node) -{ - struct kmem_cache_node *n = get_node(s, node); - - return atomic_long_read(&n->nr_slabs); -} - static inline unsigned long node_nr_slabs(struct kmem_cache_node *n) { return atomic_long_read(&n->nr_slabs); @@ -1722,8 +1714,6 @@ slab_flags_t kmem_cache_flags(unsigned int object_size, #define disable_higher_order_debug 0 -static inline unsigned long slabs_node(struct kmem_cache *s, int node) - { return 0; } static inline unsigned long node_nr_slabs(struct kmem_cache_node *n) { return 0; } static inline void inc_slabs_node(struct kmem_cache *s, int node, @@ -4599,7 +4589,7 @@ bool __kmem_cache_empty(struct kmem_cache *s) struct kmem_cache_node *n; for_each_kmem_cache_node(s, node, n) - if (n->nr_partial || slabs_node(s, node)) + if (n->nr_partial || node_nr_slabs(n)) return false; return true; } @@ -4616,7 +4606,7 @@ int __kmem_cache_shutdown(struct kmem_cache *s) /* Attempt to free all objects */ for_each_kmem_cache_node(s, node, n) { free_partial(s, n); - if (n->nr_partial || slabs_node(s, node)) + if (n->nr_partial || node_nr_slabs(n)) return 1; } return 0; @@ -4829,7 +4819,7 @@ static int __kmem_cache_do_shrink(struct kmem_cache *s) list_for_each_entry_safe(slab, t, &discard, slab_list) free_slab(s, slab); - if (slabs_node(s, node)) + if (node_nr_slabs(n)) ret = 1; } -- 2.30.2 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 5/5] slub: Don't read nr_slabs and total_objects directly 2023-04-13 14:34 [PATCH 0/5] Some tiny clean ups for SLUB sxwjean ` (3 preceding siblings ...) 2023-04-13 14:34 ` [PATCH 4/5] slub: Remove slabs_node() function sxwjean @ 2023-04-13 14:34 ` sxwjean 2023-04-18 7:50 ` [PATCH 0/5] Some tiny clean ups for SLUB Vlastimil Babka 5 siblings, 0 replies; 9+ messages in thread From: sxwjean @ 2023-04-13 14:34 UTC (permalink / raw) To: cl, penberg, rientjes, iamjoonsoo.kim, akpm, vbabka, roman.gushchin, 42.hyeyoo, keescook Cc: linux-mm, linux-kernel, linux-hardening, Xiongwei Song From: Xiongwei Song <xiongwei.song@windriver.com> We have node_nr_slabs() to read nr_slabs, node_nr_objs() to read total_objects in a kmem_cache_node, so no need to access the two members directly. Signed-off-by: Xiongwei Song <xiongwei.song@windriver.com> --- mm/slub.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 33b4fec6bc7a..2c3af399d9d6 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5157,9 +5157,9 @@ static int validate_slab_node(struct kmem_cache *s, validate_slab(s, slab, obj_map); count++; } - if (count != atomic_long_read(&n->nr_slabs)) { + if (count != node_nr_slabs(n)) { pr_err("SLUB: %s %ld slabs counted but counter=%ld\n", - s->name, count, atomic_long_read(&n->nr_slabs)); + s->name, count, node_nr_slabs(n)); slab_add_kunit_errors(); } @@ -5443,12 +5443,11 @@ static ssize_t show_slab_objects(struct kmem_cache *s, for_each_kmem_cache_node(s, node, n) { if (flags & SO_TOTAL) - x = atomic_long_read(&n->total_objects); + x = node_nr_objs(n); else if (flags & SO_OBJECTS) - x = atomic_long_read(&n->total_objects) - - count_partial(n, count_free); + x = node_nr_objs(n) - count_partial(n, count_free); else - x = atomic_long_read(&n->nr_slabs); + x = node_nr_slabs(n); total += x; nodes[node] += x; } @@ -6387,7 +6386,7 @@ static int slab_debug_trace_open(struct inode *inode, struct file *filep) unsigned long flags; struct slab *slab; - if (!atomic_long_read(&n->nr_slabs)) + if (!node_nr_slabs(n)) continue; spin_lock_irqsave(&n->list_lock, flags); -- 2.30.2 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/5] Some tiny clean ups for SLUB 2023-04-13 14:34 [PATCH 0/5] Some tiny clean ups for SLUB sxwjean ` (4 preceding siblings ...) 2023-04-13 14:34 ` [PATCH 5/5] slub: Don't read nr_slabs and total_objects directly sxwjean @ 2023-04-18 7:50 ` Vlastimil Babka 5 siblings, 0 replies; 9+ messages in thread From: Vlastimil Babka @ 2023-04-18 7:50 UTC (permalink / raw) To: sxwjean, cl, penberg, rientjes, iamjoonsoo.kim, akpm, roman.gushchin, 42.hyeyoo, keescook Cc: linux-mm, linux-kernel, linux-hardening, Xiongwei Song On 4/13/23 16:34, sxwjean@me.com wrote: > From: Xiongwei Song <xiongwei.song@windriver.com> > > Hi, > > Just clean ups, no any functionality changed. Thanks for your time. Thanks, added to slab.git for 6.5: https://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab.git/log/?h=slab/for-6.5/cleanup > Xiongwei Song (5): > slub: Correct the error code when slab_kset is NULL > slub: Put objects_show() into CONFIG_SLUB_DEBUG enabled block > slub: Remove CONFIG_SMP defined check > slub: Remove slabs_node() function > slub: Don't read nr_slabs and total_objects directly > > mm/slub.c | 45 +++++++++++++++++---------------------------- > 1 file changed, 17 insertions(+), 28 deletions(-) > ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2023-04-18 7:50 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-04-13 14:34 [PATCH 0/5] Some tiny clean ups for SLUB sxwjean 2023-04-13 14:34 ` [PATCH 1/5] slub: Correct the error code when slab_kset is NULL sxwjean 2023-04-13 14:34 ` [PATCH 2/5] slub: Put objects_show() into CONFIG_SLUB_DEBUG enabled block sxwjean 2023-04-13 17:53 ` kernel test robot 2023-04-17 7:12 ` Song, Xiongwei 2023-04-13 14:34 ` [PATCH 3/5] slub: Remove CONFIG_SMP defined check sxwjean 2023-04-13 14:34 ` [PATCH 4/5] slub: Remove slabs_node() function sxwjean 2023-04-13 14:34 ` [PATCH 5/5] slub: Don't read nr_slabs and total_objects directly sxwjean 2023-04-18 7:50 ` [PATCH 0/5] Some tiny clean ups for SLUB Vlastimil Babka
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox