From patchwork Tue Mar 8 11:41: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: 12773568 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 6C31BC433EF for ; Tue, 8 Mar 2022 11:42:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0F0CC8D000C; Tue, 8 Mar 2022 06:42:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0A0C08D0001; Tue, 8 Mar 2022 06:42:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ED2738D000C; Tue, 8 Mar 2022 06:42:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0146.hostedemail.com [216.40.44.146]) by kanga.kvack.org (Postfix) with ESMTP id E05CF8D0001 for ; Tue, 8 Mar 2022 06:42:41 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 91FEF182EFDFB for ; Tue, 8 Mar 2022 11:42:41 +0000 (UTC) X-FDA: 79221031722.18.D956584 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by imf23.hostedemail.com (Postfix) with ESMTP id 04064140008 for ; Tue, 8 Mar 2022 11:42:40 +0000 (UTC) Received: by mail-pl1-f170.google.com with SMTP id t19so13267723plr.5 for ; Tue, 08 Mar 2022 03:42:40 -0800 (PST) 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=dRBTUQACiQlx0LwCs+gvgSw5DzRBjLDB/xFsjZpjfn8=; b=eKhM8L1Q6v+MAnYmglapfX6kG3lc2plE0eACiYKlqVnXpgx6WVSGv+Lqf/5cDPEDP4 gZ+5uvrqB+Xqokx85qkhqLFzX0sgrCqmtk4511gissRzPIjOlt0zU1ZdG18sJp0iaLvk dG/RkxfbD4qUOGLzPuwQEuRcLFom7ajyiwfQ4gci/VBV3tV35Q2aEzhWb1efes/Dr+4c c5HyIVkQ50Ma/cEs0oXvFtYuVzYmY4Xo1KYScGZ2PNGP4NMB8k7wxOB4dHTuzUQiXPZE P8apwja9zdytSWgXOoIxtsKuiYTDApaTg3muHU4KoHFmZNWmvyAgrEoTAlbw2AtgduRq PuhQ== 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=dRBTUQACiQlx0LwCs+gvgSw5DzRBjLDB/xFsjZpjfn8=; b=FV1kPEm8GTDh8rVA69SxL+DZbNXTjd8rPnfcsxQ9vybb73R7RZqAZm8yMpD4yzDE6R 1FtQPoC8XQ78YfQ+g+nBTEcKn0u/2ByIPi/4oSn7lNU/iQnmkayGaV5Oz+w7cTJHMH21 tmAUimeybN/WRqQtgOiywHIVmqg6sknhPkOoWE3nETS7u58+WZRRtkSL4DF08WZLIor4 EAUjRPqzdMSen/MYqzdC66aUXauQvzk/gBC4nUCCehr0Q9Ndc/9jmcsD1q0eB/y0wRt6 VPhMD3f4DIYg+4+cZZRFqJmB6JqgHPNvFouiIuReyYT9S0yrQV+V0vtlMV1wK10npIkx OuDA== X-Gm-Message-State: AOAM531dK/nXjwA3vuWMNXVqfyNtVIm/LMkhP9kfvur2cdmCEkFMJ/JM pNPx/JQ+/yineo8go6WcTcANITvboCQvOQ== X-Google-Smtp-Source: ABdhPJxPvhmUGL9XnU9afnShPr0BQ2rnu562TEMPr2BvMh14WzqH80Eyl1ZH6ljIydlfk5YeOt4KAQ== X-Received: by 2002:a17:90b:4b4f:b0:1bf:2381:b247 with SMTP id mi15-20020a17090b4b4f00b001bf2381b247mr4163411pjb.75.1646739759779; Tue, 08 Mar 2022 03:42:39 -0800 (PST) Received: from ip-172-31-19-208.ap-northeast-1.compute.internal (ec2-18-181-137-102.ap-northeast-1.compute.amazonaws.com. [18.181.137.102]) by smtp.gmail.com with ESMTPSA id i2-20020a17090ac40200b001bd0e552d27sm2578285pjt.11.2022.03.08.03.42.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 03:42:39 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: linux-mm@kvack.org Cc: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Marco Elver , Matthew WilCox , Roman Gushchin , linux-kernel@vger.kernel.org, 42.hyeyoo@gmail.com Subject: [RFC PATCH v1 07/15] mm/sl[au]b: kmalloc_node: pass large requests to page allocator Date: Tue, 8 Mar 2022 11:41:34 +0000 Message-Id: <20220308114142.1744229-8-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220308114142.1744229-1-42.hyeyoo@gmail.com> References: <20220308114142.1744229-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 04064140008 X-Rspam-User: Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=eKhM8L1Q; spf=pass (imf23.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: 17yb7m8u5jo137y4kfo5m7dw8pupj6e5 X-HE-Tag: 1646739760-998736 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: Now that kmalloc_large_node() is in common code, pass large requests to page allocator in kmalloc_node() using kmalloc_large_node(). Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Vlastimil Babka --- include/linux/slab.h | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index 8840b2d55567..33d4260bce8b 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -551,23 +551,35 @@ static __always_inline __alloc_size(1) void *kmalloc(size_t size, gfp_t flags) return __kmalloc(size, flags); } +#ifndef CONFIG_SLOB static __always_inline __alloc_size(1) void *kmalloc_node(size_t size, gfp_t flags, int node) { -#ifndef CONFIG_SLOB - if (__builtin_constant_p(size) && - size <= KMALLOC_MAX_CACHE_SIZE) { - unsigned int i = kmalloc_index(size); + if (__builtin_constant_p(size)) { + unsigned int index; - if (!i) + if (size > KMALLOC_MAX_CACHE_SIZE) + return kmalloc_large_node(size, flags, node); + + index = kmalloc_index(size); + + if (!index) return ZERO_SIZE_PTR; return kmem_cache_alloc_node_trace( kmalloc_caches[kmalloc_type(flags)][i], flags, node, size); } -#endif return __kmalloc_node(size, flags, node); } +#else +static __always_inline __alloc_size(1) void *kmalloc_node(size_t size, gfp_t flags, int node) +{ + if (__builtin_constant_p(size) && size > KMALLOC_MAX_CACHE_SIZE) + return kmalloc_large_node(size, flags, node); + + return __kmalloc_node(size, flags, node); +} +#endif /** * kmalloc_array - allocate memory for an array.