From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.31 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796211902; b=RE9jXW3F4haqo64mYrhiVa87Zt9K19y2ynjercKBj+blH3DW3XnKVayEE9BKguViSS6C SaUT9ESX1FqiwclvACvCLTRvXGfXSpvrHuhtMPtF3bHOuhJM0O6fUHCEbDn0pVIZDYqPg hlhxc9td2lYJj11uCOeVXCjFiOWeSyD9Yj6cV2+5ABUNxgIpPBg9eleGJS9DTSnr7PpVc vO+a0hYB9QLopU//ISUhcP/zml05HTIxnwM64D0Wx1lguBPw43q/7qSuKxpsoIlw5NcVd L7EU0I1oz2KVtN2t9Bv4cxchffoN7INVLyReVfI+ugKU3HWt78nXYJt5ejhD7hF12Vw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796211902; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=O/1bruzwXr4LQskmY5oWaEQ+/Jvp7e4+8TpTeF9SnWQ=; b=tE35vQTXK0W/yuLSizxzP0ptDW0pC94DaDNhOSWy2zlkYrI3Lmtqef8KdBF7anAtYR1+ m1+cvbmzAmO4HO0qa0lqWK+jMDcBDJrG92W+hhx9w1NQl20YEI/vDWBHoK7o8wNfkR/R/ VAzu423iKqwXc8dg39IE5Ch0Ftcpe9nboFo0zjf8X6PMYRCXaNbRAAvsihjSDkIs/taT1 UC+6zyROaO0fCNACvcs9gAYoSXFQU10cWd88m6LDvpdFyp3O4aDwsJZItgQhRu8c4DzOy y08byEFzet1sOgXVIU9RC+Am5Ih313GLJTvzVnWzEdQEqJ+CAtfqSN9l6YTpEGL26CA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=KnLkKl2S; arc=none smtp.remote-ip=91.218.175.31 Received: from mta0.migadu.com (out-31.mta0.migadu.com [91.218.175.31]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 06736606A32D for ; Wed, 2 Dec 2026 11:45:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 06736606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=KnLkKl2S X-Envelope-To: oe-kbuild-all@lists.linux.dev DKIM-Signature: a=rsa-sha256; bh=j4QjQh3rmVlNjUDWNfS3esr/uiQ4kokxeSdpdlB8FqU=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796211898; v=1; x=1796816698; b=KnLkKl2SQlch43p6tG1imo0UaArjmJKFulrA92oGdaz7FR8aTPdoCZBQEBg4kSBVRqhgnyD4 N1NB8Ser0ickRUW9juyyOF8avUyDpL5FMKd073UK3nqg6PF5qGPO4ChxSRMyKgukJEkK5hQuat9 WdcN8v8o3OJg4rK62xbirb5Y= X-Envelope-To: oe-kbuild-all@lists.linux.dev Received: by smtp.migadu.com with ESMTPS id fed6ddcaa6eefbf3; Wed, 02 Dec 2026 11:44:58 +0000 X-Mizu-Trace-ID: fed6ddcaa6eefbf3 X-Migadu-Flow: FLOW_OUT Date: Wed, 2 Dec 2026 11:44:37 +0000 From: Hao Li To: "Vlastimil Babka (SUSE)" Cc: kernel test robot , oe-kbuild-all@lists.linux.dev, Harry Yoo 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 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. > > 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 > > >