From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796306489; b=K+0gEhs2tROft1avqnzFs+9cx7i7/qqXAY0ae3faaMsN1vofKhhr2gCPVHKmC/GlL97U EGkWmAWljtiR70TRxKPWk641mxCmG0HtaI8nTZQuXpnoG3bOy8XQikd0bw4XEIbg+JcJz XJXZ9Y+D1Q5qqFFnYh094anjl3gziF4vOhF9//3dAxhy6ZW163sbefjT0YnXjJBdRnIu/ FcKhoyKzg0nZxDdliar9UQP091OqZTBJ1Kg5L4WYkKOxGrvR5FZO65BFSZ/82uADX7psm QcIKq/uKZFjiNWSz+XP06QjqrDm9Vy5WNyiGcT6ArqF1lYJdOYZhJf0Tz23GC9l6TyQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796306489; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=1pNhKEVHpn0cduD3LW3a9+GYq35UGdpV35qp24GMxis=; b=cqmrW6B46jlyAOVa7JN2dcXMg1/MFWvo/VBAHjwYx/uAeIV7mLuon3xTKCWK4l/PIChZ Y3dTbfh/Scvkc6A154olUBDOaJyIAmACr9h/Wb2pzmEeKV+Xz6o4ZBczmTZ9VKDv0SRzt n7rvQQSo5clYQXNgwpOFI5BY88SI0CQ//5uSzEkBxfWgqh+yWArmXxNU7quq64U+bNWV3 0fS78sznC+HBLLSkwmgPKXrJR8aGaqq3VggKNcx7MWRJKGrGDbAVyXnPw70LYwY1mszK3 EA40uTlMPRcBQ5g0R7zVDD51lCW8YmmMGs5to6RrJDnKDcR7A3ZO5Ki5V1UgEFI7veg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eXX98uv1; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 357F4606A322 for ; Thu, 3 Dec 2026 14:01:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eXX98uv1 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9373E1F00896; Thu, 3 Dec 2026 14:01:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796306489; bh=1pNhKEVHpn0cduD3LW3a9+GYq35UGdpV35qp24GMxis=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=eXX98uv1v9wcnmaI9VJX0piQt80T7DiXKog8zUyBaLAXiEAEnWICXUJq32aBFxbP0 28/QMQCpTsDhdaR9QpZbi+BSOXEV0EmO7t+WmBg1+l02UCiszdNnp+P4SWDxiiFsSg gbwRaoyDvu7MVCzE2ezEZnNF8Xmf3pUOOHy/8F9IRSvJtAwoMbbMnsXLf5oBCL0fk4 AhQlLwvqBrw0bLtPXS7ODla1DTNpassSl/fM83iMXCV+3abw57+O89/SuzFjmFYr0e FVTHS5dKFCLW3KkGlQvOnnCfX3WTw+w828VxDVw1VJgS9074dovj8lubQuUFnH7RtM zEjFsmgRI+iCQ== Date: Thu, 3 Dec 2026 14:01:27 +0000 From: Harry Yoo To: Hao Li Cc: "Vlastimil Babka (SUSE)" , kernel test robot , oe-kbuild-all@lists.linux.dev Subject: 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)' Message-ID: References: <20261120153115.isoaU88H-lkp@intel.com> X-Mailing-List: oe-kbuild-all@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Wed, Dec 02, 2026 at 11:44:37AM +0000, Hao Li wrote: > 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 > > > | 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. I immediately dismissed it as it's benign... :P > > 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. This sounds helpful to use as it's quite easy to overlook. > Agreed, I also lean towards keeping it as-is for now, and we can always > introduce a separate helper later if needed. Yeah no need to hurry! > > > 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 > > > > > -- Cheers, Harry / Hyeonggon