From patchwork Wed Aug 17 10:18:15 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: 12945685 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 3F5C5C25B08 for ; Wed, 17 Aug 2022 10:19:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C9C556B0075; Wed, 17 Aug 2022 06:19:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C4C1D6B007E; Wed, 17 Aug 2022 06:19:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AECA18D0001; Wed, 17 Aug 2022 06:19:09 -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 A08E26B0075 for ; Wed, 17 Aug 2022 06:19:09 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 7240B1208CE for ; Wed, 17 Aug 2022 10:19:09 +0000 (UTC) X-FDA: 79808686818.08.DE6904F Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) by imf06.hostedemail.com (Postfix) with ESMTP id 0EBA01801AF for ; Wed, 17 Aug 2022 10:19:08 +0000 (UTC) Received: by mail-pg1-f178.google.com with SMTP id q16so11605226pgq.6 for ; Wed, 17 Aug 2022 03:19:08 -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=mA3ow7hUqSccT7bNwtvWTEd/QzJvQLSRyOCnJvDyp6U=; b=KSORlivSY1gDZvvmSEL4PxisN5IhBGQ1AeMvUGp8veSEXXByVMSzBjP4EJs747a5pq EofZUC/QfmHd03v73+6exjCC4vKOklIzSLxg0nltRXkCXFS4Sc0OwHmR9KIl6TyAEJrc fHJBGiEwu0cAFe0dzqsjwmqN5xt8ff032WOB4BvTPxYzEfZz7b1pP7lJm08KccLkCQHJ jt569vdr1+djQJL67jwzVOqUDjxqN7XyixPqfbCIXDwsI35VKNdGOl8hek/QXE1J67DP RNLPeV6A5AyUr6bx88K6xfAy8EGoftktHop8hdTCXciIpaf7F43jIYcW+0Qxx8yVYu8U qlTg== 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=mA3ow7hUqSccT7bNwtvWTEd/QzJvQLSRyOCnJvDyp6U=; b=JCULsbI11OaFg1JzESroQbcfiJWwoKYMcAhW+5FSJ7ei2wGWwtd2d3HuzgwOb+cRPZ au6YfMu+Ep0wNZUB9ygSkTQJUo9AYxU95Y3N7z57/TDzB52qTpN2yiYvpHDSd3VOjLDn kFVLXKIJHQx2ChYZRStzsczrTKZSEWBrHM8LAvADmNFLsFolbBdofSyJLURjUp7ZElke 8Fnlv+whjxsnK2/LcZ1bDo34NeVywic3LSKqL3nZA/n/VWncge2uFCO967pUVtJogXD7 h3WqebQom4tou10oYvJQNaN+dIFwmIrdx11pEUnTzWkLXdouQSlbmKYo9Kll1NNynf+W vwEA== X-Gm-Message-State: ACgBeo3FVXyASBIpNBD9HAZnkR9WAfiuvNMyilvA6YIqtHLI7ORb1YML alOblBx0gWcAq4Yex3GSsTHZ19sz9Bw= X-Google-Smtp-Source: AA6agR7yr6u/vBTtWdBbY4Pd43tYRkW3wO6YJeVXJ+XtjSNhD6MsvXydP/mxQVwJjej0KHAHrH/4tQ== X-Received: by 2002:a63:494a:0:b0:41c:f29e:2a2e with SMTP id y10-20020a63494a000000b0041cf29e2a2emr21247258pgk.477.1660731548139; Wed, 17 Aug 2022 03:19:08 -0700 (PDT) Received: from hyeyoo.. ([114.29.91.56]) by smtp.gmail.com with ESMTPSA id d8-20020a170903230800b00172633fc236sm1071318plh.174.2022.08.17.03.19.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 03:19:07 -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 06/17] mm/slab_common: fold kmalloc_order_trace() into kmalloc_large() Date: Wed, 17 Aug 2022 19:18:15 +0900 Message-Id: <20220817101826.236819-7-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-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=KSORlivS; spf=pass (imf06.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.215.178 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660731549; a=rsa-sha256; cv=none; b=Nw86vYCyhm/gOBRytGnVhknAluY1DTbYkRhbp1sCHBGbHaoWrRcSuacJHibQOBkHI6NFjx rBVck3b/VwmTGsMzxqirXbUq5uWYXM+ctKLoMJW2bN6HOvN15QSzSkVzSTchpb5yq5taKR MkPiLp6MqJdTxm6OdqzNYavKfybjTNc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660731549; 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=mA3ow7hUqSccT7bNwtvWTEd/QzJvQLSRyOCnJvDyp6U=; b=z5QVLoqZfnm7r0FwBgcUycM6D5Lwp3ediTM4rZ7isjr5GzIM3BnwkAjxcJfPr2yyFYGwrY RgUvrY4GAKbGWX33vyYYThOcVUjDt0dpxufeYBXKrrdYGY6E3Fh7wCOUTJeBYYZjk3iOe2 fofl3bhrK5wf+U0TdrLbzaahdANnY7Q= Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=KSORlivS; spf=pass (imf06.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.215.178 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: 14y9omp9yf8bhbghbpmt8ua4ttzzuyyt X-Rspamd-Server: rspam09 X-Rspam-User: X-Rspamd-Queue-Id: 0EBA01801AF X-HE-Tag: 1660731548-361636 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 | 17 ++++------------- 2 files changed, 6 insertions(+), 33 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 17996649cfe3..8b1988544b89 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -905,16 +905,16 @@ 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); - flags |= __GFP_COMP; - page = alloc_pages(flags, order); + page = alloc_pages(flags | __GFP_COMP, order); if (likely(page)) { ret = page_address(page); mod_lruvec_page_state(page, NR_SLAB_UNRECLAIMABLE_B, @@ -923,19 +923,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 */