From patchwork Tue Jul 12 13:39:36 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: 12915005 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 24F91C43334 for ; Tue, 12 Jul 2022 13:40:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B440594007B; Tue, 12 Jul 2022 09:40:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AF493940063; Tue, 12 Jul 2022 09:40:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9BC7194007B; Tue, 12 Jul 2022 09:40:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 8F813940063 for ; Tue, 12 Jul 2022 09:40:14 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 6567760D2C for ; Tue, 12 Jul 2022 13:40:14 +0000 (UTC) X-FDA: 79678556748.08.F5616D0 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by imf01.hostedemail.com (Postfix) with ESMTP id 072CB40035 for ; Tue, 12 Jul 2022 13:40:13 +0000 (UTC) Received: by mail-pj1-f51.google.com with SMTP id j1-20020a17090aeb0100b001ef777a7befso1533632pjz.0 for ; Tue, 12 Jul 2022 06:40:13 -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=RfZICKzfMt9jP521ltPO4rr38titj9GujPx2SBl9+NM=; b=Lg0N91mr0+CDOYu+efRU4fHCR7Qv3ssQqZ5FEFbYTsc//saKmmUTlEeXOMTauarXrT 6lWX5v9SwRcnkS8qmBYYIwxTKQG7t4ihTTYZe22uPKe1RrVAvIIb23e41kXILNHh2zNU 9z4wt2QwoiZ1XiACht3mok9xBmUUlqDwGv8gKgMHdFnFUltMkCqIHUCY6TrJ2+diPX4y 81/PPs6VRwN63pMoo0OyfU1/DepI1eK6jVpYLrmDv0XlEKEp2nEU+W5QCJ40DcCrMUwi DlqxHINZEVrxBh82Wy6tgJZPVrMuMsZ830BIUtDkPBotOYLldgp+/ePgUJDazYKMHWew N+tg== 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=RfZICKzfMt9jP521ltPO4rr38titj9GujPx2SBl9+NM=; b=yu/BF/n2h176TIaLMGnkHxoqvrU+VuMES8V+ncZFPURaEauxwZgogjnEt5cyXAOjPo 3hyR+9NdXslr9UrkEmBdaxfBvDlb+TzVavWtQOIBpeRWLoSmleFMIWEk/51cn8F8CPBZ 3G47lLmUVWC6lYOyKhCt1TkejkpTJBnox6lhYltVy+G9USRp3ZTJwZMmhTMH6ogL+ZXZ H9epSnNYTfsk9BDz2kuqEugHq9HDrguAJuFgx+CBylaErWwlRDPmeNTICArA4sS2hq50 oPJT3iI+PCiMACmF00iWSPsjnsQK3okPOg0iQtvlQRVLAuMhfKCaMcmU0wciCYIXcMRs jYcQ== X-Gm-Message-State: AJIora+KlmZWGL3SpLth0xRmYT4r7rQO2T3B/kyHlLRvHpXP/OiJbBxB VsPljl4RwWgowyubYqDpQWo= X-Google-Smtp-Source: AGRyM1vlXqHvvszhpDV2iSM8ks7jydXWE9ZU4N9umSMIWSjNT0JIA0n9gnMP/DPU6j56Ir4d5vWV9w== X-Received: by 2002:a17:902:e746:b0:16c:4eb6:915d with SMTP id p6-20020a170902e74600b0016c4eb6915dmr9478865plf.106.1657633213063; Tue, 12 Jul 2022 06:40:13 -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.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jul 2022 06:40:12 -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 06/15] mm/slab_common: fold kmalloc_order_trace() into kmalloc_large() Date: Tue, 12 Jul 2022 13:39:36 +0000 Message-Id: <20220712133946.307181-7-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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657633214; 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=RfZICKzfMt9jP521ltPO4rr38titj9GujPx2SBl9+NM=; b=nn2VMx7GvSM+gJb8NOE6fjXKRP86KAjbrpFlYHP65HfB0Es1KPCC9EbBkRI2zad5s+wvaJ fsDHfG2bV5vKUQ1pvmknbc0bzFqmr3j13N8bRY7xKagmLxBXdg4M014TjQmWFafP9p4a+I o5FRUJjUbGAF+U0F28C9Ch/aB8p/GJk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657633214; a=rsa-sha256; cv=none; b=Q8zm1kDtNb9Os2oOh1agyh4VdB0YLln07/oDvKyZ/y2wBEvxVfM2fJacfo4Ejw0Kd+3V7x macqTfCJzDz4/Xal2g54vXoYyEaEmL3Xqu0tN5SzJHwZlQnKQpxEhVHXkdvph1AogLT5Py fyu9jFEddgwxdKpqDcmO27czRph0+Vo= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Lg0N91mr; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.216.51 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com X-Stat-Signature: 7r5jzr75o4r5r1bjp575usbcnm46rcnb X-Rspamd-Queue-Id: 072CB40035 X-Rspam-User: Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Lg0N91mr; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.216.51 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com X-Rspamd-Server: rspam05 X-HE-Tag: 1657633213-573136 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: There is no caller of kmalloc_order_trace() except kmalloc_large(). Fold it into kmalloc_large() and remove kmalloc_order{,_trace}(). Also add tracepoint in kmalloc_large() that was previously in kmalloc_order_trace(). Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Vlastimil Babka --- include/linux/slab.h | 22 ++-------------------- mm/slab_common.c | 14 +++----------- 2 files changed, 5 insertions(+), 31 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index a0e57df3d5a4..15a4c59da59e 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -489,26 +489,8 @@ static __always_inline void *kmem_cache_alloc_node_trace(struct kmem_cache *s, g } #endif /* CONFIG_TRACING */ -extern void *kmalloc_order(size_t size, gfp_t flags, unsigned int order) __assume_page_alignment - __alloc_size(1); - -#ifdef CONFIG_TRACING -extern void *kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order) - __assume_page_alignment __alloc_size(1); -#else -static __always_inline __alloc_size(1) void *kmalloc_order_trace(size_t size, gfp_t flags, - unsigned int order) -{ - return kmalloc_order(size, flags, order); -} -#endif - -static __always_inline __alloc_size(1) void *kmalloc_large(size_t size, gfp_t flags) -{ - unsigned int order = get_order(size); - return kmalloc_order_trace(size, flags, order); -} - +void *kmalloc_large(size_t size, gfp_t flags) __assume_page_alignment + __alloc_size(1); /** * kmalloc - allocate memory * @size: how many bytes of memory are required. diff --git a/mm/slab_common.c b/mm/slab_common.c index 6c9aac5d8f4a..1f8af2106df0 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -932,10 +932,11 @@ gfp_t kmalloc_fix_flags(gfp_t flags) * directly to the page allocator. We use __GFP_COMP, because we will need to * know the allocation order to free the pages properly in kfree. */ -void *kmalloc_order(size_t size, gfp_t flags, unsigned int order) +void *kmalloc_large(size_t size, gfp_t flags) { void *ret = NULL; struct page *page; + unsigned int order = get_order(size); if (unlikely(flags & GFP_SLAB_BUG_MASK)) flags = kmalloc_fix_flags(flags); @@ -950,19 +951,10 @@ void *kmalloc_order(size_t size, gfp_t flags, unsigned int order) ret = kasan_kmalloc_large(ret, size, flags); /* As ret might get tagged, call kmemleak hook after KASAN. */ kmemleak_alloc(ret, size, 1, flags); - return ret; -} -EXPORT_SYMBOL(kmalloc_order); - -#ifdef CONFIG_TRACING -void *kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order) -{ - void *ret = kmalloc_order(size, flags, order); trace_kmalloc(_RET_IP_, ret, NULL, size, PAGE_SIZE << order, flags); return ret; } -EXPORT_SYMBOL(kmalloc_order_trace); -#endif +EXPORT_SYMBOL(kmalloc_large); #ifdef CONFIG_SLAB_FREELIST_RANDOM /* Randomize a generic freelist */