From patchwork Thu Apr 14 08:57:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hyeonggon Yoo <42.hyeyoo@gmail.com> X-Patchwork-Id: 12813157 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A51FC433F5 for ; Thu, 14 Apr 2022 08:58:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E8C5B6B0078; Thu, 14 Apr 2022 04:58:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E3B8A6B007B; Thu, 14 Apr 2022 04:58:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D04456B007D; Thu, 14 Apr 2022 04:58:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id C30E86B0078 for ; Thu, 14 Apr 2022 04:58:04 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 9336A25438 for ; Thu, 14 Apr 2022 08:58:04 +0000 (UTC) X-FDA: 79354882488.17.0B412B2 Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) by imf18.hostedemail.com (Postfix) with ESMTP id 235101C0005 for ; Thu, 14 Apr 2022 08:58:03 +0000 (UTC) Received: by mail-pg1-f175.google.com with SMTP id t4so4259000pgc.1 for ; Thu, 14 Apr 2022 01:58:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=K7ZmOmH1IbMc+vnlcJBZfbxN3MEcHeLW2ET7s3Wh5sM=; b=I70WfUKgVpQ6q+asH3FAmRn1WWiOAy6zd0FZbkAq6a02yN2z6/+ljmprknkpE2cMGP b4fjuvaH99F1aAEhWhnan9EeGlHqrNslTlrjI4++n/eXgw1TU26x9LyLn7zzYY7G8I5H k+Me9mMeCsC6PFp93hM/rk+BLLAkGkljpvOBs/M9dmFGcEAxWhAOIEZbIEa6HSBsTTR/ gGDOtgcz78mbZNfs+WMW7SVniVtfBKOzZjoUJOB74VvgPmFiGz4yVUfDdsGyyDfDMEYI /7LrxWRqv+J5fTU5AIfm6CDGouRBJSKF5fdrjc8qplsLME+iRSJfjU0b9+2f2fdEOGPX 9LJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=K7ZmOmH1IbMc+vnlcJBZfbxN3MEcHeLW2ET7s3Wh5sM=; b=C5xUbltMmUX42eKRKBJ7bRoOGSJh5EXHKilEMqxsRKEqq9OHuQErixCIG09wOLKhY6 CbFrpen7hiHecUtuulwj2SE1uCiJLkmzjwtlkqj8jov7/Dq6Av0LY5zHoum0KJw04a0A D/lANW/1uw+b+iL0j7ilWKHqxh6dTA42+TVnVRHVkTyfugPQj/hoMDORttB9uVRteF/e KB9wb9/K88XViKRJlylNXsEVktPCcBc7s6P+GyOSbVbxlCjo+l+wOLg9kaAq5Cgva1im 3NgVZO3y2VuJpJ4iLnMH02kBalec3rsF7f1ts4vraWUlNGRAN+eZ4k2Ls5UUrl7Hod5a CoJg== X-Gm-Message-State: AOAM530Ul4N/uCMvRMPAt7fNefFOo7YSDQLCXZ+sNwLm+lgzqhvDwDcg rz+TT9dmM4dupp+jxMbx0lE= X-Google-Smtp-Source: ABdhPJwjedRUJ62C/VUVzRlP7p+Lh/lKMZPqawWi7OpyiXjnkb9bEleKPusTPvxIUdrOkQXNBlkZtg== X-Received: by 2002:aa7:88ce:0:b0:505:6a0b:c965 with SMTP id k14-20020aa788ce000000b005056a0bc965mr14021729pff.67.1649926683254; Thu, 14 Apr 2022 01:58:03 -0700 (PDT) Received: from hyeyoo.. ([114.29.24.243]) by smtp.gmail.com with ESMTPSA id p9-20020aa79e89000000b00505fada20dfsm1403537pfq.117.2022.04.14.01.57.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Apr 2022 01:58:01 -0700 (PDT) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Vlastimil Babka Cc: Marco Elver , Matthew WilCox , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Roman Gushchin , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 04/23] mm/slab_common: cleanup kmalloc_track_caller() Date: Thu, 14 Apr 2022 17:57:08 +0900 Message-Id: <20220414085727.643099-5-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220414085727.643099-1-42.hyeyoo@gmail.com> References: <20220414085727.643099-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 235101C0005 X-Stat-Signature: o8uptnpoonfkaf5pew4ms5b1k993hh3g X-Rspam-User: Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=I70WfUKg; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf18.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.215.175 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com X-HE-Tag: 1649926683-442898 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Make kmalloc_track_caller() wrapper of kmalloc_node_track_caller(). Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Vlastimil Babka --- include/linux/slab.h | 17 ++++++++--------- mm/slab.c | 6 ------ mm/slob.c | 6 ------ mm/slub.c | 22 ---------------------- 4 files changed, 8 insertions(+), 43 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index a3b9d4c20d7e..acdb4b7428f9 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -639,6 +639,12 @@ static inline __alloc_size(1, 2) void *kcalloc(size_t n, size_t size, gfp_t flag return kmalloc_array(n, size, flags | __GFP_ZERO); } +extern void *__kmalloc_node_track_caller(size_t size, gfp_t flags, int node, + unsigned long caller) __alloc_size(1); +#define kmalloc_node_track_caller(size, flags, node) \ + __kmalloc_node_track_caller(size, flags, node, \ + _RET_IP_) + /* * kmalloc_track_caller is a special version of kmalloc that records the * calling function of the routine calling it for slab leak tracking instead @@ -647,9 +653,9 @@ static inline __alloc_size(1, 2) void *kcalloc(size_t n, size_t size, gfp_t flag * allocator where we care about the real place the memory allocation * request comes from. */ -extern void *__kmalloc_track_caller(size_t size, gfp_t flags, unsigned long caller); #define kmalloc_track_caller(size, flags) \ - __kmalloc_track_caller(size, flags, _RET_IP_) + __kmalloc_node_track_caller(size, flags, \ + NUMA_NO_NODE, _RET_IP_) static inline __alloc_size(1, 2) void *kmalloc_array_node(size_t n, size_t size, gfp_t flags, int node) @@ -668,13 +674,6 @@ static inline __alloc_size(1, 2) void *kcalloc_node(size_t n, size_t size, gfp_t return kmalloc_array_node(n, size, flags | __GFP_ZERO, node); } - -extern void *__kmalloc_node_track_caller(size_t size, gfp_t flags, int node, - unsigned long caller) __alloc_size(1); -#define kmalloc_node_track_caller(size, flags, node) \ - __kmalloc_node_track_caller(size, flags, node, \ - _RET_IP_) - /* * Shortcuts */ diff --git a/mm/slab.c b/mm/slab.c index 5ad55ca96ab6..5f20efc7a330 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -3675,12 +3675,6 @@ void *__kmalloc(size_t size, gfp_t flags) } EXPORT_SYMBOL(__kmalloc); -void *__kmalloc_track_caller(size_t size, gfp_t flags, unsigned long caller) -{ - return __do_kmalloc(size, flags, caller); -} -EXPORT_SYMBOL(__kmalloc_track_caller); - /** * kmem_cache_free - Deallocate an object * @cachep: The cache the allocation was from. diff --git a/mm/slob.c b/mm/slob.c index c8c3b5662edf..6d0fc6ad1413 100644 --- a/mm/slob.c +++ b/mm/slob.c @@ -528,12 +528,6 @@ void *__kmalloc(size_t size, gfp_t gfp) } EXPORT_SYMBOL(__kmalloc); -void *__kmalloc_track_caller(size_t size, gfp_t gfp, unsigned long caller) -{ - return __do_kmalloc_node(size, gfp, NUMA_NO_NODE, caller); -} -EXPORT_SYMBOL(__kmalloc_track_caller); - void *__kmalloc_node_track_caller(size_t size, gfp_t gfp, int node, unsigned long caller) { diff --git a/mm/slub.c b/mm/slub.c index e36c148e5069..e425c5c372de 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -4903,28 +4903,6 @@ int __kmem_cache_create(struct kmem_cache *s, slab_flags_t flags) return 0; } -void *__kmalloc_track_caller(size_t size, gfp_t gfpflags, unsigned long caller) -{ - struct kmem_cache *s; - void *ret; - - if (unlikely(size > KMALLOC_MAX_CACHE_SIZE)) - return kmalloc_large(size, gfpflags); - - s = kmalloc_slab(size, gfpflags); - - if (unlikely(ZERO_OR_NULL_PTR(s))) - return s; - - ret = slab_alloc(s, NULL, gfpflags, caller, size); - - /* Honor the call site pointer we received. */ - trace_kmalloc(caller, ret, size, s->size, gfpflags); - - return ret; -} -EXPORT_SYMBOL(__kmalloc_track_caller); - void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags, int node, unsigned long caller) {