Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp12820815rwl; Tue, 3 Jan 2023 22:19:00 -0800 (PST) X-Google-Smtp-Source: AMrXdXtg3xuk45bRPoPT1/N3I6BkPi9kyC8hxZbb+OgUnduNb01SIIqjqLYaCa83q7jTin21o3+I X-Received: by 2002:a17:906:6d2:b0:7e7:4dd7:bb88 with SMTP id v18-20020a17090606d200b007e74dd7bb88mr36716773ejb.57.1672813140376; Tue, 03 Jan 2023 22:19:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672813140; cv=none; d=google.com; s=arc-20160816; b=UEvrxfZLV4qR4r17/hID/exGjvfFydtivMZNeU1l1Zptzlvehzywo3QhydZQLn7iUp JhR9mU5rjT7BQ3TcWSDOMQlBIqZq12FZBQMCefBYif+cbZuon3rIB231cb50Qn/aOx38 4pbK2ZoutiG1r+B+an/H3zKcWxIfNbPmgFb/Rnq563iW1xKMOask8EempwrE9xAQIf8l gqNgMg6UAlsdb0hqEB8cEZSK2DANI+RjvA53z8mAg4N5E5udHw5tlESSS4jMUOf5Yrug /bO5zXwJ0W2ZsHKwRXRZwEKFIcopL6yJjIrGWLVstPZsRiGLppysBAXsiDZJ54VnBKnX DRJg== 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=1s5P6iET2OaU2whx6wnFdyFdaEhzKdZCflQd8AxmlTo=; b=jt40OU2RXwkYWxLrjukPBLi3gYowOYQofU1JJWG02kO+oXpGGCCaLdrOVIrXJLqjGq /8y3PQTTx6gOhDnMx2HggQmzMdFbEdwuoAnUF0dTcPOAM8dku75EGtiD/F+ohx9RecGD hya4Ipyxp0OJEfCqWlAzYfmm7UDMLl+sby/5u6AJM1wL0AdDEJ8JL7uM7W5XQGhSEfjN EOEhbmCz/uc8xZoFIfNlCSj6shxBHNdMFo4zdglYeZzGg/1YgVWfIitAOta4DnvbcXbZ 9RPaWZkXaVL0GVsptHa1XtdT6F+YwMlvXAuW9Suhndce17VOAWk0Li4VAJyrJiEx9y9Y KZDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Jfv+xXHo; 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 hu9-20020a170907a08900b007c18ffbf16esi30224031ejc.433.2023.01.03.22.18.46; Tue, 03 Jan 2023 22:19:00 -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=Jfv+xXHo; 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 S233219AbjADGIs (ORCPT + 59 others); Wed, 4 Jan 2023 01:08:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229655AbjADGIr (ORCPT ); Wed, 4 Jan 2023 01:08:47 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D00F12637 for ; Tue, 3 Jan 2023 22:08:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672812526; x=1704348526; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=akgWoI1DZBNrZUnXySes4BuMOxDs0QUyVGoUEHSDAAM=; b=Jfv+xXHorquctWz0QKHm2VsD8x0fLPOfdppi6t/0zn8sLke12wUFHQEM ATnYcLKP+E1Wca7n+mn3CVcWpI6e11fjViPakW7NmH/MzA1SesVvym72Y PukpabBTbXDM7xqc27M48SYVaKWSLGNsDnO3WAgpkSjDoG/qrimyg/HF+ vQ3TNc1dt2zCrirIeovKy956Zrvi0SR64j6iZtqgpArA9dkXQ1plM5B5F MnZBZFFvGmMkagmXEUFU25vSkBpWfcRKRgARzgRspnIeJdX/MyPwQNNfg dH4m5Drq+l6E8JoLzjmPqdRGRjIGOaJXLrNESRaC4FjccRb9xbZSSctrx A==; X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="323840107" X-IronPort-AV: E=Sophos;i="5.96,299,1665471600"; d="scan'208";a="323840107" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jan 2023 22:08:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="779094063" X-IronPort-AV: E=Sophos;i="5.96,299,1665471600"; d="scan'208";a="779094063" Received: from feng-clx.sh.intel.com ([10.238.200.228]) by orsmga004.jf.intel.com with ESMTP; 03 Jan 2023 22:08:41 -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 v3 -mm 1/2] mm/slab: add is_kmalloc_cache() helper function Date: Wed, 4 Jan 2023 14:06:04 +0800 Message-Id: <20230104060605.930910-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=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 Acked-by: Vlastimil Babka Acked-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- changlog: since v2: * fix type in subject(Vlastimil Babka) * collect Acked-by tag since v1: * don't use macro for the helper (Andrew Morton) * place the inline function in mm/slab.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 7cc432969945..63fb4c00d529 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -323,6 +323,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