Message ID | 20221123123159.2325763-1-feng.tang@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2759618wrr; Wed, 23 Nov 2022 04:36:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf5v7j2Dy4dmVVGKSwvnJOAH49d7IpwLLYSiBFddlAxBvLABozo28psWITathHC3eRZRtjAj X-Received: by 2002:a17:907:c20d:b0:7b8:882d:43fc with SMTP id ti13-20020a170907c20d00b007b8882d43fcmr6404836ejc.0.1669207001695; Wed, 23 Nov 2022 04:36:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669207001; cv=none; d=google.com; s=arc-20160816; b=RZ0uko/KRkSC9KsC32Q8o7yvb7HIs/X5KrunDrjfXKt1CE3DEovcV9O61iGNTCdsjA 8hb2qaGpG0Kd/iBgzszIVT1lmUPB7/fsEzGvftA55tSFM31lfuYeGczFLOzns0y5FTSK shn3Eojvp49aVrzfCSglRAbl5tKru3raG0yb6LIkmwdqck4kq7XUuuGR9bXPWV9T1mCh M1BxOU40IeaOItPV9jaRoXw2mmMsamGaM6g++5FJcq9fXywcSe43jBD6WbKgfMh85s7p jvTZQMt7/SAb5lfRcggtCMnZyEDrREuil2fA3qIBSMZtkz1j6RvJu+rr22vMgQr6obHo orbg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ga4-20020a1709070c0400b007ade20fc40csi15777242ejc.810.2022.11.23.04.36.16; Wed, 23 Nov 2022 04:36:41 -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 <rfc822;fengqi706@gmail.com> + 99 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <linux-kernel@vger.kernel.org>; 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 <feng.tang@intel.com> To: Andrew Morton <akpm@linux-foundation.org>, Vlastimil Babka <vbabka@suse.cz>, Christoph Lameter <cl@linux.com>, Pekka Enberg <penberg@kernel.org>, David Rientjes <rientjes@google.com>, Joonsoo Kim <iamjoonsoo.kim@lge.com>, Roman Gushchin <roman.gushchin@linux.dev>, Hyeonggon Yoo <42.hyeyoo@gmail.com>, Andrey Konovalov <andreyknvl@gmail.com>, Dmitry Vyukov <dvyukov@google.com>, Andrey Ryabinin <ryabinin.a.a@gmail.com>, Alexander Potapenko <glider@google.com>, Vincenzo Frascino <vincenzo.frascino@arm.com> Cc: linux-mm@kvack.org, kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, Feng Tang <feng.tang@intel.com> 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750290401123126260?= X-GMAIL-MSGID: =?utf-8?q?1750290401123126260?= |
Series |
[v2,-next,1/2] mm/slb: add is_kmalloc_cache() helper function
|
|
Commit Message
Feng Tang
Nov. 23, 2022, 12:31 p.m. UTC
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 <feng.tang@intel.com>
---
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(+)
Comments
Subject should say mm/slab On 11/23/22 13:31, Feng Tang wrote: > 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 <feng.tang@intel.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> Patch 2 seems to depend on patches in Andrew's tree so it's simpler if he takes both of these too. Thanks, Vlastimil > --- > 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 | \
On Wed, Nov 23, 2022 at 06:03:26PM +0100, Vlastimil Babka wrote: > Subject should say mm/slab My bad, thanks for catching this. > On 11/23/22 13:31, Feng Tang wrote: > > 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 <feng.tang@intel.com> > > Acked-by: Vlastimil Babka <vbabka@suse.cz> Thanks! > Patch 2 seems to depend on patches in Andrew's tree so it's simpler if he > takes both of these too. Yes, patch 2/2 change many places of kasan code. Hi Andrew, Could you consider taking these 2 patches to your tree? If you think it's too close to the merge windown, I can respin after 6.2. thanks! - Feng > Thanks, > Vlastimil > > > --- > > 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 | \ >
On Wed, Nov 23, 2022 at 08:31:58PM +0800, Feng Tang wrote: > 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 <feng.tang@intel.com> > --- > 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 With Vlastimil's comment: Acked-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
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 | \