* [mm-slab:slab/for-next 1/2] mm/slab_common.c:1012 new_kmalloc_cache() warn: always true condition '(type >= 0) => (0-u32max >= 0)'
@ 2026-11-20 14:32 kernel test robot
2026-12-02 11:00 ` Vlastimil Babka (SUSE)
0 siblings, 1 reply; 3+ messages in thread
From: kernel test robot @ 2026-11-20 14:32 UTC (permalink / raw)
To: Hao Li; +Cc: oe-kbuild-all, Harry Yoo, Vlastimil Babka (SUSE)
tree: https://git.kernel.org/pub/scm/linux/kernel/git/mm/slab.git slab/for-next
head: c6e6bf9b097d69a06974b2f8b5400b33e1faeb31
commit: ec81fa8f7dbcf89d9b4112544f76f47c8eb5c725 [1/2] mm/slab: don't set SLAB_MAY_ACCOUNT for KMALLOC_PARTITION_CACHES
config: um-randconfig-2200-20261120 (https://download.01.org/0day-ci/archive/20261120/20261120153115.isoaU88H-lkp@intel.com/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 8db60b003f961f25c5cafe91ee44176f61374279)
smatch: v0.5.0-9187-g5189e3fb
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/20261120153115.isoaU88H-lkp@intel.com/
smatch warnings:
mm/slab_common.c:1012 new_kmalloc_cache() warn: always true condition '(type >= 0) => (0-u32max >= 0)'
vim +1012 mm/slab_common.c
1001
1002 /*
1003 * If memcg_kmem is enabled and this is a KMALLOC_NORMAL or
1004 * KMALLOC_PARTITION_CACHES cache and not aliased with any other type,
1005 * make sure it's never merged with any other cache.
1006 *
1007 * In other cases the kmalloc cache may end up being used for a
1008 * __GFP_ACCOUNT allocation so mark it as such. The exception is a
1009 * KMALLOC_NO_OBJ_EXT cache.
1010 */
1011 if (!mem_cgroup_kmem_disabled()) {
> 1012 if (type >= KMALLOC_PARTITION_START &&
1013 type <= KMALLOC_PARTITION_END &&
1014 KMALLOC_RECLAIM != KMALLOC_NORMAL)
1015 flags |= SLAB_NO_MERGE;
1016 else if (!(flags & SLAB_NO_OBJ_EXT))
1017 flags |= SLAB_MAY_ACCOUNT;
1018 }
1019
1020 if (minalign > ARCH_KMALLOC_MINALIGN) {
1021 aligned_size = ALIGN(aligned_size, minalign);
1022 aligned_idx = __kmalloc_index(aligned_size, false);
1023 }
1024
1025 if (!kmalloc_caches[type][aligned_idx])
1026 kmalloc_caches[type][aligned_idx] = create_kmalloc_cache(
1027 kmalloc_info[aligned_idx].name[type],
1028 aligned_size, flags);
1029 if (idx != aligned_idx)
1030 kmalloc_caches[type][idx] = kmalloc_caches[type][aligned_idx];
1031 }
1032
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [mm-slab:slab/for-next 1/2] mm/slab_common.c:1012 new_kmalloc_cache() warn: always true condition '(type >= 0) => (0-u32max >= 0)'
2026-11-20 14:32 [mm-slab:slab/for-next 1/2] mm/slab_common.c:1012 new_kmalloc_cache() warn: always true condition '(type >= 0) => (0-u32max >= 0)' kernel test robot
@ 2026-12-02 11:00 ` Vlastimil Babka (SUSE)
2026-12-02 11:44 ` Hao Li
0 siblings, 1 reply; 3+ messages in thread
From: Vlastimil Babka (SUSE) @ 2026-12-02 11:00 UTC (permalink / raw)
To: kernel test robot, Hao Li; +Cc: oe-kbuild-all, Harry Yoo
On 11/20/26 15:32, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/mm/slab.git slab/for-next
> head: c6e6bf9b097d69a06974b2f8b5400b33e1faeb31
> commit: ec81fa8f7dbcf89d9b4112544f76f47c8eb5c725 [1/2] mm/slab: don't set SLAB_MAY_ACCOUNT for KMALLOC_PARTITION_CACHES
> config: um-randconfig-2200-20261120 (https://download.01.org/0day-ci/archive/20261120/20261120153115.isoaU88H-lkp@intel.com/config)
> compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 8db60b003f961f25c5cafe91ee44176f61374279)
> smatch: v0.5.0-9187-g5189e3fb
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/20261120153115.isoaU88H-lkp@intel.com/
>
> smatch warnings:
> mm/slab_common.c:1012 new_kmalloc_cache() warn: always true condition '(type >= 0) => (0-u32max >= 0)'
While the condition can become tautology in certain configs, I'm not sure if
it's worth complicating the code just to silence smatch, hm. AFAIU the
recommendation is "don't".
If we had more tests like this that could make adding a
"is_kmalloc_partition_type" helper useful on its own, then perhaps.
> vim +1012 mm/slab_common.c
>
> 1001
> 1002 /*
> 1003 * If memcg_kmem is enabled and this is a KMALLOC_NORMAL or
> 1004 * KMALLOC_PARTITION_CACHES cache and not aliased with any other type,
> 1005 * make sure it's never merged with any other cache.
> 1006 *
> 1007 * In other cases the kmalloc cache may end up being used for a
> 1008 * __GFP_ACCOUNT allocation so mark it as such. The exception is a
> 1009 * KMALLOC_NO_OBJ_EXT cache.
> 1010 */
> 1011 if (!mem_cgroup_kmem_disabled()) {
>> 1012 if (type >= KMALLOC_PARTITION_START &&
> 1013 type <= KMALLOC_PARTITION_END &&
> 1014 KMALLOC_RECLAIM != KMALLOC_NORMAL)
> 1015 flags |= SLAB_NO_MERGE;
> 1016 else if (!(flags & SLAB_NO_OBJ_EXT))
> 1017 flags |= SLAB_MAY_ACCOUNT;
> 1018 }
> 1019
> 1020 if (minalign > ARCH_KMALLOC_MINALIGN) {
> 1021 aligned_size = ALIGN(aligned_size, minalign);
> 1022 aligned_idx = __kmalloc_index(aligned_size, false);
> 1023 }
> 1024
> 1025 if (!kmalloc_caches[type][aligned_idx])
> 1026 kmalloc_caches[type][aligned_idx] = create_kmalloc_cache(
> 1027 kmalloc_info[aligned_idx].name[type],
> 1028 aligned_size, flags);
> 1029 if (idx != aligned_idx)
> 1030 kmalloc_caches[type][idx] = kmalloc_caches[type][aligned_idx];
> 1031 }
> 1032
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [mm-slab:slab/for-next 1/2] mm/slab_common.c:1012 new_kmalloc_cache() warn: always true condition '(type >= 0) => (0-u32max >= 0)'
2026-12-02 11:00 ` Vlastimil Babka (SUSE)
@ 2026-12-02 11:44 ` Hao Li
0 siblings, 0 replies; 3+ messages in thread
From: Hao Li @ 2026-12-02 11:44 UTC (permalink / raw)
To: Vlastimil Babka (SUSE); +Cc: kernel test robot, oe-kbuild-all, Harry Yoo
On Wed, Dec 02, 2026 at 12:00:34PM +0100, Vlastimil Babka (SUSE) wrote:
> On 11/20/26 15:32, kernel test robot wrote:
> > tree: https://git.kernel.org/pub/scm/linux/kernel/git/mm/slab.git slab/for-next
> > head: c6e6bf9b097d69a06974b2f8b5400b33e1faeb31
> > commit: ec81fa8f7dbcf89d9b4112544f76f47c8eb5c725 [1/2] mm/slab: don't set SLAB_MAY_ACCOUNT for KMALLOC_PARTITION_CACHES
> > config: um-randconfig-2200-20261120 (https://download.01.org/0day-ci/archive/20261120/20261120153115.isoaU88H-lkp@intel.com/config)
> > compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 8db60b003f961f25c5cafe91ee44176f61374279)
> > smatch: v0.5.0-9187-g5189e3fb
> >
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/20261120153115.isoaU88H-lkp@intel.com/
> >
> > smatch warnings:
> > mm/slab_common.c:1012 new_kmalloc_cache() warn: always true condition '(type >= 0) => (0-u32max >= 0)'
Oh, I somehow missed this robot email! Thanks for the heads-up.
>
> While the condition can become tautology in certain configs, I'm not sure if
> it's worth complicating the code just to silence smatch, hm. AFAIU the
> recommendation is "don't".
> If we had more tests like this that could make adding a
> "is_kmalloc_partition_type" helper useful on its own, then perhaps.
Agreed, I also lean towards keeping it as-is for now, and we can always
introduce a separate helper later if needed.
>
> > vim +1012 mm/slab_common.c
> >
> > 1001
> > 1002 /*
> > 1003 * If memcg_kmem is enabled and this is a KMALLOC_NORMAL or
> > 1004 * KMALLOC_PARTITION_CACHES cache and not aliased with any other type,
> > 1005 * make sure it's never merged with any other cache.
> > 1006 *
> > 1007 * In other cases the kmalloc cache may end up being used for a
> > 1008 * __GFP_ACCOUNT allocation so mark it as such. The exception is a
> > 1009 * KMALLOC_NO_OBJ_EXT cache.
> > 1010 */
> > 1011 if (!mem_cgroup_kmem_disabled()) {
> >> 1012 if (type >= KMALLOC_PARTITION_START &&
> > 1013 type <= KMALLOC_PARTITION_END &&
> > 1014 KMALLOC_RECLAIM != KMALLOC_NORMAL)
> > 1015 flags |= SLAB_NO_MERGE;
> > 1016 else if (!(flags & SLAB_NO_OBJ_EXT))
> > 1017 flags |= SLAB_MAY_ACCOUNT;
> > 1018 }
> > 1019
> > 1020 if (minalign > ARCH_KMALLOC_MINALIGN) {
> > 1021 aligned_size = ALIGN(aligned_size, minalign);
> > 1022 aligned_idx = __kmalloc_index(aligned_size, false);
> > 1023 }
> > 1024
> > 1025 if (!kmalloc_caches[type][aligned_idx])
> > 1026 kmalloc_caches[type][aligned_idx] = create_kmalloc_cache(
> > 1027 kmalloc_info[aligned_idx].name[type],
> > 1028 aligned_size, flags);
> > 1029 if (idx != aligned_idx)
> > 1030 kmalloc_caches[type][idx] = kmalloc_caches[type][aligned_idx];
> > 1031 }
> > 1032
> >
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-02 11:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 14:32 [mm-slab:slab/for-next 1/2] mm/slab_common.c:1012 new_kmalloc_cache() warn: always true condition '(type >= 0) => (0-u32max >= 0)' kernel test robot
2026-12-02 11:00 ` Vlastimil Babka (SUSE)
2026-12-02 11:44 ` Hao Li
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.