From patchwork Wed Aug 17 10:18:13 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: 12945683 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 D1F88C25B08 for ; Wed, 17 Aug 2022 10:19:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6CF2B6B007B; Wed, 17 Aug 2022 06:19:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 67F386B007D; Wed, 17 Aug 2022 06:19:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4F9186B007E; Wed, 17 Aug 2022 06:19:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 404146B007B for ; Wed, 17 Aug 2022 06:19:02 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 1B73D1C3EED for ; Wed, 17 Aug 2022 10:19:02 +0000 (UTC) X-FDA: 79808686524.01.F78A782 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by imf10.hostedemail.com (Postfix) with ESMTP id BC4ECC01D2 for ; Wed, 17 Aug 2022 10:19:01 +0000 (UTC) Received: by mail-pj1-f53.google.com with SMTP id m10-20020a17090a730a00b001fa986fd8eeso1437221pjk.0 for ; Wed, 17 Aug 2022 03:19:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=Ga89EBm/M0pSIGR8VO7j68eF/ZO7QJRQA6L4btLKSFg=; b=QvUbGhywEPeBhwJmjbmSzIFybywy0vyCr2SJpbyRtQyIAz/VHy0E9scAmI4tj9TDt1 7CCk4lbN/5d6jWw7cwcGb8PBl3ye5q15nhrzA5sqxvDUGMSFqVg7NYHiX3XBRAni81eB auRwaRmIuJf7ov23ZgTvUnKbzv3DtzTYDWOO4ADxnf805wypIVs5TPMc3HWNxAfQge4u Tg6TyCAaDMi3EWtSGO6vJy/T3OsHv9bFnT5fSSzBnJsGjmYouddxdZ11fsxvo7fUAqG1 9FcIao+/tb8ciwjz9SJKcMtwT9GpZ1eH3PJdTUfkmGedsuJqSgTl3kHnOfOaXBbqmEkk cGOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=Ga89EBm/M0pSIGR8VO7j68eF/ZO7QJRQA6L4btLKSFg=; b=TTQTrE0voTC5Q2jPww98fFf0RtYB/f/o3o0O9RakBlCNs9DJhe/w2MI5JSE3KEWN8S z+xP6M2rVMVTutSeWSLKXZupIUx7x8xoA+NKdemare/gG4rCONsDlNmEDi4bodEzPOA8 XkZAu0us59l0MI7041Bcg7Gg1nXmYfa5TUVWKqYkiUfDgimzQzaRrKSnFmloaitdfMlP D9j8X+lCGHCPYGbQd0ZyPD3IgFti5aFO1j6dBgKHrDqB84FnUOL1A5hsrKU1ej+D3d6E WV5YpOyfsgRtuwbscCZ2QhF1VF5Qx3ocOwmT+8uyP04O3A8LlwfPqEgILOMb0hGiLyDD SRSA== X-Gm-Message-State: ACgBeo2DRCC6P3CVtcP+WbYVamw/sl5qtfshPYpbRzzm4IsY7hRb7a1f tb5FKMxnecxdtnWSNHLHxRw= X-Google-Smtp-Source: AA6agR7bPV9zEhLcxPDQaHMgtadEN07BrNJzVtA2QjN0NjCwWz3hrowIypljfqszymfPovsGjThBlg== X-Received: by 2002:a17:902:9307:b0:170:d739:a3cf with SMTP id bc7-20020a170902930700b00170d739a3cfmr26025458plb.127.1660731540819; Wed, 17 Aug 2022 03:19:00 -0700 (PDT) Received: from hyeyoo.. ([114.29.91.56]) by smtp.gmail.com with ESMTPSA id d8-20020a170903230800b00172633fc236sm1071318plh.174.2022.08.17.03.18.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 03:18:59 -0700 (PDT) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Roman Gushchin Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 04/17] mm/slab_common: cleanup kmalloc_track_caller() Date: Wed, 17 Aug 2022 19:18:13 +0900 Message-Id: <20220817101826.236819-5-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220817101826.236819-1-42.hyeyoo@gmail.com> References: <20220817101826.236819-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660731541; a=rsa-sha256; cv=none; b=YiGUnY11k02fZ+FPEJjaLtez84dGOv83thCwC3/O1M+OUBIBXKFJglxUA8VWxqybm0hj9/ c9ZRo4nL+1dj8TyXccDMEMse40ATYmP1dmhMI+rRChhzMqdmToky0/IElil4Aaogg9C32L UE+/IfvLTYcGsA11P6E77Xc2vlJGmFI= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=QvUbGhyw; spf=pass (imf10.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.216.53 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660731541; 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=Ga89EBm/M0pSIGR8VO7j68eF/ZO7QJRQA6L4btLKSFg=; b=mowV7PpYQayRwBmHIcKV7wvm/s0N1Q1yS166Y4a+kvN2VZKC4MfF3CRdow8N8sGTEI0SXN F8E2phGZhWXwcQb/wuY1WfMwUlBl+4j6/K0c1Zz3JvDg4fuj/sKRg/Rt3U89yrHR1t7O7K H184kSlrc3ab953EAXyQdJXo0tODQsI= Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=QvUbGhyw; spf=pass (imf10.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.216.53 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Stat-Signature: 648jt1twd183st86xymwfgfx1ikoex6b X-Rspamd-Queue-Id: BC4ECC01D2 X-Rspamd-Server: rspam06 X-HE-Tag: 1660731541-161989 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 0acd65358c83..611e630ff860 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 74d850967213..96b08acd72ce 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 b29b3c9d3175..c82a4062f730 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) {