From patchwork Tue Jul 12 13:39:34 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: 12915003 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 DDB62C43334 for ; Tue, 12 Jul 2022 13:40:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 79AF0940079; Tue, 12 Jul 2022 09:40:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 74BF4940063; Tue, 12 Jul 2022 09:40:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6140B940079; Tue, 12 Jul 2022 09:40:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 4F003940063 for ; Tue, 12 Jul 2022 09:40:08 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 2768433EEE for ; Tue, 12 Jul 2022 13:40:08 +0000 (UTC) X-FDA: 79678556496.13.53BEAC3 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by imf13.hostedemail.com (Postfix) with ESMTP id 5C7D62005F for ; Tue, 12 Jul 2022 13:40:07 +0000 (UTC) Received: by mail-pl1-f170.google.com with SMTP id 5so7269197plk.9 for ; Tue, 12 Jul 2022 06:40:07 -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=W+t2TYQyUd3MLoRrZFHRafgKosCtEfHks/X4I7bodFI=; b=lC9cVXM2npScD2ZYw8CT4kj9R7jq2JvDLs1QphPos+o7fmVpE0703VFXwBBoaSuZhj do6IQnZW/TV5vv8kqxIIgodC+sQz51op1rKKgohqWHwuj/MqEorzrMTj1co42+Ld/j0A CkDaf/7TID8mjapFQN4v6YVew41uT2Qd2o/kEPHo4zGlAW23FoGiiqYbRHKFBF7po/7L dsZEsN55SNfbFLL8fiY6CjOtiLvKP3rmoxVQhYK4YjZG59ppQ3+RlG0SrqRNd0hNO2s1 ilfwlaRg0ZSeaTuaEFpKYY1OvIh2/w7uQVwN3N3iXaEbVGBCCx9YE4c1oTG3TaIq8NmH l9ow== 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=W+t2TYQyUd3MLoRrZFHRafgKosCtEfHks/X4I7bodFI=; b=GdfBxh8Fk1mu5IXOcV12rZejw2F2BaH7debqCD97sIOdPLXfSE0ZTcQfL1ezP0G6z3 dwMYfIsNyRbnQufxqHiBAvN0+zbZ0E4YIKctl2RF2Z6Rmiq5Hfppfv7xGrlt3TBKB7ov 4S3w7ciZOJ6EEfSt6JJ8LZ8byEGjEM+lmSPVjgKCFRV3Jeg5tPXYgwutQaA9WyyCLlK6 eZxCQmepRuLqBHz1kYJoGA1QC9w4R5262L9zeO51IcyCmPHXkGDVZ4D/ynh88vdtGQOc LPLm3ZBp3uk5Jf9Kch9jg6A34SRSNcqLg2NPF1JiOwcmkG5zSpzak/DWQ8AMrQ1OUh6Z Fh6w== X-Gm-Message-State: AJIora9EDBgCVV6l7qd1z7m+mULh6vb5D8x8MhsyrksUf3sbfCp0fM/W Qi0NAClMJvCnfHQ6cMPVO3w= X-Google-Smtp-Source: AGRyM1tF4nj/+intWIHCMQ8XyAHzk+7R0O55XlDFiY10p+ezbHjlYwpSeqsyseQ0P6NtV2q1y+hqLg== X-Received: by 2002:a17:90b:1c0e:b0:1ef:f82c:1746 with SMTP id oc14-20020a17090b1c0e00b001eff82c1746mr4371155pjb.124.1657633206339; Tue, 12 Jul 2022 06:40:06 -0700 (PDT) Received: from ip-172-31-24-42.ap-northeast-1.compute.internal (ec2-35-75-15-180.ap-northeast-1.compute.amazonaws.com. [35.75.15.180]) by smtp.gmail.com with ESMTPSA id r6-20020aa79886000000b0052ae3bcb807sm1947178pfl.188.2022.07.12.06.40.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jul 2022 06:40:05 -0700 (PDT) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Joe Perches , Vasily Averin , Matthew WilCox Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v3 04/15] mm/slab_common: cleanup kmalloc_track_caller() Date: Tue, 12 Jul 2022 13:39:34 +0000 Message-Id: <20220712133946.307181-5-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220712133946.307181-1-42.hyeyoo@gmail.com> References: <20220712133946.307181-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657633207; a=rsa-sha256; cv=none; b=Oxdshkjs4i6sbGQbCjzT9AkUi/jBndXYtw4dYAjIoWJ0fg3SuG/Nik0ySRPfdtWfAjvhYq R63/OM4gmMHE9Qj/aS0lcQ/f9t98LsbbaEyn273zv+iRzm0EwKJ6cqfnch6BTKv/lMkHOo sP6i6WWnV4GfR3osAVZ6EGR6R+FxOkk= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=lC9cVXM2; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf13.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657633207; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=W+t2TYQyUd3MLoRrZFHRafgKosCtEfHks/X4I7bodFI=; b=HNjGdUnsHOZN5PpJs9SqNMljU4/rTiZB1mg3CPcH1PFlDDMIzinCBnuwbCbbW1fcUYQh18 b7AN7BjQp8I9NwtSfYXFrmGkcRn3KMoc6wMvq1ZkluUc6DWMDrEpjvNBS/DOhD18Fx+zHx ywMpxDxqedLUA4vn911RCqqrqyxENzE= Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=lC9cVXM2; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf13.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com X-Rspam-User: X-Stat-Signature: c118hpk3te4x9cjw1corgtdndrxna9r7 X-Rspamd-Queue-Id: 5C7D62005F X-Rspamd-Server: rspam08 X-HE-Tag: 1657633207-388583 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 4754c834b0e3..a0e57df3d5a4 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -651,6 +651,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); } +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 @@ -659,9 +665,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) @@ -680,13 +686,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 81804921c538..da2f6a5dd8fa 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -3665,12 +3665,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 c54aad6b106c..80cdbe4f0d67 100644 --- a/mm/slob.c +++ b/mm/slob.c @@ -530,12 +530,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 a5b3a4484263..7c284535a62b 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -4904,28 +4904,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, s, 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) {