From patchwork Thu Apr 14 08:57:24 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: 12813171 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 7E4DAC433FE for ; Thu, 14 Apr 2022 08:59:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B8FE6B0073; Thu, 14 Apr 2022 04:59:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1694D6B0075; Thu, 14 Apr 2022 04:59:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 031626B007B; Thu, 14 Apr 2022 04:59:44 -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 E8A2C6B0073 for ; Thu, 14 Apr 2022 04:59:44 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C60A561AA9 for ; Thu, 14 Apr 2022 08:59:44 +0000 (UTC) X-FDA: 79354886688.06.9D575B0 Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) by imf01.hostedemail.com (Postfix) with ESMTP id 1F3524000B for ; Thu, 14 Apr 2022 08:59:43 +0000 (UTC) Received: by mail-pg1-f180.google.com with SMTP id q19so4236384pgm.6 for ; Thu, 14 Apr 2022 01:59:43 -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=ua/uZ6qm2oTljPWsofJREnrVaB3Pp7mzKI9GmIJ+zVs=; b=i3xDvTW0KEoA3rocpb/ts6nvQdVhG/gwVA+cxvSoNic20GYFjH31pocaxRa1Gh3LSl er7pUR2X7EB5Vpam3pnIaxCJPc7HKG+SK0tY+SL9qwUloa6IpB4carU16P+0BFvn3Ve3 jMkpgb5ur0o/LiQ/geHPuBcqAqAgRsG1xpZ6VuxtGZr0tQNMW4a/+DkO7kqid05uJmDJ TdPyWjSiO5qVsRdFro8/swAA20IXRPTZP1pL6Th05qXGgxX8S96uowdqPh5hqZryplAZ vdMoTau5uN6f9RxjzOV24KJMBPuK9PUWe89dsCl0SryZyVROw90wYX9LkpQxtN8NpZIS bZPA== 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=ua/uZ6qm2oTljPWsofJREnrVaB3Pp7mzKI9GmIJ+zVs=; b=k8VE/E/oJJROtQRkyEICeRMK6+O29+WFqJHqga+SHgT7DWLPunHG/fbw/deVu9jt9+ 0mRIhLB6sCBRhbrdpvENTZtaI5RPwr1pzusmRoqNqZn9XPOZCODMbf88FiJAFPif6fly 7bhAGmSacYtaOLw/gtlB0K1CgGuoX2fskInB7iVvW94gS2WzKqdTgU5a1x+/mtIA3BhK AVyWPNN3pTsGALgNrGS9sAifsViUVNVO6nYFLpzxO+8z2T/4llo0pF3NuK2lQx1Lqruf kd4OJEGY2Nuxg3N+aZ4aA8cP3PTdR6yX4Ykz+5Nxf1nMhBZlOwxHAy1IfKBC+KZqlk7a bPow== X-Gm-Message-State: AOAM533voJEE1oakLxyUo8Aov9peeqxBc1k8YIfHEERWIvNM2dJblLbC mkjDTt726A531ktOZm3HTxY= X-Google-Smtp-Source: ABdhPJx/Hd0A3GzOSvel1BxHOz4/B46nvZGT//rxRVflVuYWERDTpthd5Fup1TuuwYMwwTBDcmCmiw== X-Received: by 2002:a63:a804:0:b0:398:e7d7:29ab with SMTP id o4-20020a63a804000000b00398e7d729abmr1454997pgf.138.1649926783121; Thu, 14 Apr 2022 01:59:43 -0700 (PDT) Received: from hyeyoo.. ([114.29.24.243]) by smtp.gmail.com with ESMTPSA id p9-20020aa79e89000000b00505fada20dfsm1403537pfq.117.2022.04.14.01.59.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Apr 2022 01:59:41 -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 20/23] mm/slab_common: factor out __do_kmalloc_node() Date: Thu, 14 Apr 2022 17:57:24 +0900 Message-Id: <20220414085727.643099-21-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-Rspam-User: X-Stat-Signature: 1p8miz5c5eeqqptpx9o47x7bxoemrceu Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=i3xDvTW0; spf=pass (imf01.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.215.180 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 1F3524000B X-HE-Tag: 1649926783-43625 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: Factor out common code into __do_kmalloc_node(). Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/slab_common.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/mm/slab_common.c b/mm/slab_common.c index 6abe7f61c197..af563e64e8aa 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -919,7 +919,9 @@ void free_large_kmalloc(struct folio *folio, void *object) __free_pages(folio_page(folio, 0), order); } -void *__kmalloc_node(size_t size, gfp_t flags, int node) +static __always_inline +void *__do_kmalloc_node(size_t size, gfp_t flags, int node, + unsigned long caller __maybe_unused) { struct kmem_cache *s; void *ret; @@ -932,31 +934,22 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node) if (unlikely(ZERO_OR_NULL_PTR(s))) return s; - ret = __kmem_cache_alloc_node(s, NULL, flags, node, _RET_IP_); + ret = __kmem_cache_alloc_node(s, NULL, flags, node, caller); ret = kasan_kmalloc(s, ret, size, flags); return ret; } + +void *__kmalloc_node(size_t size, gfp_t flags, int node) +{ + return __do_kmalloc_node(size, flags, node, _RET_IP_); +} EXPORT_SYMBOL(__kmalloc_node); void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags, int node, unsigned long caller) { - struct kmem_cache *s; - void *ret; - - if (unlikely(size > KMALLOC_MAX_CACHE_SIZE)) - return kmalloc_large_node(size, gfpflags, node); - - s = kmalloc_slab(size, gfpflags); - - if (unlikely(ZERO_OR_NULL_PTR(s))) - return s; - - ret = __kmem_cache_alloc_node(s, NULL, gfpflags, node, caller); - ret = kasan_kmalloc(s, ret, size, gfpflags); - - return ret; + return __do_kmalloc_node(size, flags, node, caller); } EXPORT_SYMBOL(__kmalloc_node_track_caller);