Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7337628rwb; Wed, 23 Nov 2022 05:26:59 -0800 (PST) X-Google-Smtp-Source: AA0mqf7FTCg7vTNlumUbSZLRB3qIN+aY6/cEYKF57rzh/DCTBD6bZ0iJPnazrxhOj5R2Odw3hSfk X-Received: by 2002:a65:594e:0:b0:46f:f911:eee with SMTP id g14-20020a65594e000000b0046ff9110eeemr8192214pgu.432.1669210019043; Wed, 23 Nov 2022 05:26:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669210019; cv=none; d=google.com; s=arc-20160816; b=HMXar623+vNWarUqT+qLIX7h+H0qh+TFyadRJfz/+HfetvpRNuzJLL5uv7SL/rKA8x nVyYdoUcSW33ckGcxXlhJy+FTRTcB8ZLJI2ZBYM8PNXJ0+Mm7t6gTj420eWCBZk0egq1 Y6YQTo5iN1v+1Okor062Cpd1V9FD2eJm7Jus1WvWqjJgwf+dqPNWFGmjcre03vpqHIf+ bAFM3o4uydEqiVqhigAEjzzfXlMj95+0IfnWMohyN6YIKHbkPsRH923IW9/bRJuu6boB CvOw67tHgNdl8rbt0xbvM6eSPeKUL6/KxPvboPdLQ9MS122L8vB+nTTa8kXkuel/BOYS 7CFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=CJmzxhK0F+EQBwqW32oQ/vEbzIh81a1UF0l3egqzynI=; b=MkT4t+fakCDVC1qvVoAFbg8p8OzBA3/pgvo9Fw2y8zOlMaoYbFcOewgi9lbHDMwcFL qSEfXTCEr8ptNVVkz/mOuR15Mm37xLcyx83FKQ0idbF8Cza3nZMsO8fg6kKn6/nSdyRd 6RL1BEYECkOe7+gLuPbEkaVuDIdDHqpCLQPl60PqHSTzMQ0nZ9N3Uu78GNYECXUQM6A0 Fwl7rsKJyJJXZjA4JHnlnp8Q9DLDsF1TipuH5WRNfKB7F/mrI7jBTagZTGB53HKwv6Zx XQ3YdXFRRNJmbebFg/Oojt5ErXgOS3g3reTv4F3MTpAA8CDgkdJfonXUK0LwQJECTdN9 ruWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=flTN7wX6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 38-20020a631566000000b00476c25c2d68si15027817pgv.116.2022.11.23.05.26.46; Wed, 23 Nov 2022 05:26:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=flTN7wX6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236766AbiKWMfE (ORCPT + 90 others); Wed, 23 Nov 2022 07:35:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235612AbiKWMfB (ORCPT ); Wed, 23 Nov 2022 07:35:01 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A534DEBD for ; Wed, 23 Nov 2022 04:35:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669206901; x=1700742901; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=32aAwApD/Py6ob5i40TYQ76jp/UicXBWzicek/tVfb0=; b=flTN7wX6/StGouVIAT1r6wDjNg34KVw+HaYf50587lPCkKomMB5rSbcI j5pQbxtOAJKxllGBtIiTaoeubBlA4tGvMQY0a38H5rllx5LGpHVmZbLWw MlEcWdY1qc83CKLyd+fl1DAGg2fMrAS0JPtNgliMdQADsKnjdpAydH6D8 Aw/bwLJiH5XufAUSTaval5r7AuHRc+KabG+ZkjOCMi9/LsfT5AJT6JYy2 xgTMG01AHoCK8si/02168JCdrT6CwoxX8Ga1ANTY52W5In943czumGwp1 HqjMQL5H55jfag4pZ060yup1J3+ZZO2DqdwierW5OheS4OU9kMGYEqYlA w==; X-IronPort-AV: E=McAfee;i="6500,9779,10539"; a="340935416" X-IronPort-AV: E=Sophos;i="5.96,187,1665471600"; d="scan'208";a="340935416" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2022 04:35:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10539"; a="705349428" X-IronPort-AV: E=Sophos;i="5.96,187,1665471600"; d="scan'208";a="705349428" Received: from feng-clx.sh.intel.com ([10.238.200.228]) by fmsmga008.fm.intel.com with ESMTP; 23 Nov 2022 04:34:57 -0800 From: Feng Tang To: Andrew Morton , Vlastimil Babka , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Andrey Konovalov , Dmitry Vyukov , Andrey Ryabinin , Alexander Potapenko , Vincenzo Frascino Cc: linux-mm@kvack.org, kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, Feng Tang Subject: [PATCH v2 -next 1/2] mm/slb: add is_kmalloc_cache() helper function Date: Wed, 23 Nov 2022 20:31:58 +0800 Message-Id: <20221123123159.2325763-1-feng.tang@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org commit 6edf2576a6cc ("mm/slub: enable debugging memory wasting of kmalloc") introduces 'SLAB_KMALLOC' bit specifying whether a kmem_cache is a kmalloc cache for slab/slub (slob doesn't have dedicated kmalloc caches). Add a helper inline function for other components like kasan to simplify code. Signed-off-by: Feng Tang --- changlog: since v1: * don't use macro for the helper (Andrew Morton) * place the inline function in mm/slb.h to solve data structure definition issue (Vlastimil Babka) mm/slab.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mm/slab.h b/mm/slab.h index e3b3231af742..0d72fd62751a 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -325,6 +325,14 @@ static inline slab_flags_t kmem_cache_flags(unsigned int object_size, } #endif +static inline bool is_kmalloc_cache(struct kmem_cache *s) +{ +#ifndef CONFIG_SLOB + return (s->flags & SLAB_KMALLOC); +#else + return false; +#endif +} /* Legal flag mask for kmem_cache_create(), for various configurations */ #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | \ -- 2.34.1