From patchwork Tue Jul 12 13:39:32 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: 12915001 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 D2C18C433EF for ; Tue, 12 Jul 2022 13:40:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7294E940077; Tue, 12 Jul 2022 09:40:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6AE47940063; Tue, 12 Jul 2022 09:40:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5286B940077; Tue, 12 Jul 2022 09:40:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 43B09940063 for ; Tue, 12 Jul 2022 09:40:01 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 0FF6D3376F for ; Tue, 12 Jul 2022 13:40:01 +0000 (UTC) X-FDA: 79678556202.11.3C187BA Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by imf23.hostedemail.com (Postfix) with ESMTP id 6F52E140073 for ; Tue, 12 Jul 2022 13:40:00 +0000 (UTC) Received: by mail-pl1-f174.google.com with SMTP id f11so7284532plr.4 for ; Tue, 12 Jul 2022 06:40:00 -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=r/sC4QUhXRkGGh2bMZjIx8vUi/+M03CaD7v75Vc4qIM=; b=Q4gF1YgEyhsTFkNHPaBVgVWmoB1UycH55o77nMikgwe0GbIhxDa72n1fUGC5vQe/QD Il9OHSXdBMCafC0e5otobL4t+Nwc7Cep5xa5y7tGgixwBwz0A4fO9F37XXfglBp11Pyt 7YhwCUoQcUh3fao2+JVDsNZrMz3SuZvF6CFZCenkPXSvDumwz/NLcRaOdC9dPGrHXm6M PTTMEWYUBKk4lYq3dYSSRqLl+xRm9yvnUq8luiT8pqvwQt4Dgm+DxmXKjFJL5bJVGwPy 1Cp6APIWKaZgmAcOs58RclTepUEjVTJJoQjwsoApSvNuDBHiGGsvuR0S6i12eiblMIDB s8sg== 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=r/sC4QUhXRkGGh2bMZjIx8vUi/+M03CaD7v75Vc4qIM=; b=olz/6MxT4QUxxUMfXyd9GPtQJb30zfmthotr7H7EuMwDbalRIc//p5wacf8cPzQiX1 fWfaiG2740FxmetA+Ukytkxk1iMoIY2Uzuzjcan/1vEBlt4WksYkI8j7582TdEH5/laF 7t9IMBrrTVF33TsuqvtMgmrFF/w5sgVZ6hlghzYrpEuRzt9J95gQG6bWsYxYVMGr5LYX W+MzC8BnZUAmWE8N7ppx9jeFD9kbihxqjlQPPfM5ay4aCoHM1fIRQ/e++PICtDpWIsbG 0efshXuoAYh+CIPt5wVoO3rluQwcdgAWA90m+S5gXDi4kQ7+BE92pAD7hZD9d3O5yUdI w8Qg== X-Gm-Message-State: AJIora/CX97Z72Ey35E9E9RoKmUx1DKESctiTd8e+TGu3pRWtfbiMQmq 5YS7T0v6S1zGyQ0F1BDYUm4= X-Google-Smtp-Source: AGRyM1vJg6rHv6f9xZ16nqyAOzl+pygP2/nWo+HF7ZxNCw7rYTwZRTp22u80Y8t30cgdcqSc0Zg+3A== X-Received: by 2002:a17:90b:4f4a:b0:1f0:65d:d888 with SMTP id pj10-20020a17090b4f4a00b001f0065dd888mr4576679pjb.136.1657633199556; Tue, 12 Jul 2022 06:39:59 -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.39.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jul 2022 06:39:58 -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 2/15] mm/slab: cleanup slab_alloc() and slab_alloc_node() Date: Tue, 12 Jul 2022 13:39:32 +0000 Message-Id: <20220712133946.307181-3-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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657633200; a=rsa-sha256; cv=none; b=tx/v2vE4OuuInkEwXn8PSnYEgFiZjWShlKNidKYXXMZXzwaDc66+XV7CirEQdxyHdQLEoe LWScvFmig8OPRFVub0RJxZC8JrSWkCVJnGG9Gz6UIVURCsS69xptp2Hhbnt49rT7SMxFGI ZDbQkrcWudL0MlL/r7tAuiNd56oGhQg= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Q4gF1YgE; spf=pass (imf23.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.214.174 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=1657633200; 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=r/sC4QUhXRkGGh2bMZjIx8vUi/+M03CaD7v75Vc4qIM=; b=nNL/2KPDnhGDSW2UUWQW7puOotaHIqhDJaYeCZ/t3+b3Tyx9RbYoWasAHSFFuFaV3X0AR0 fPdY6+pQaRM7PL7hiSOovV0wRgkDYZE7FYUeGJI/P4QQVyAEcF/QY3SeI2FykSOhNqmMSi IO+oGh/y1JTcl6HCkGuIbFGuzChnWIQ= X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 6F52E140073 X-Rspam-User: Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Q4gF1YgE; spf=pass (imf23.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.214.174 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: oro85ys3aidq1d5wn4hrukczgj1zft46 X-HE-Tag: 1657633200-881694 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 slab_alloc_node() available even when CONFIG_NUMA=n and make slab_alloc() wrapper of slab_alloc_node(). This is necessary for further cleanup. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Vlastimil Babka --- mm/slab.c | 50 +++++++++++++------------------------------------- 1 file changed, 13 insertions(+), 37 deletions(-) diff --git a/mm/slab.c b/mm/slab.c index 3d83d17ff3b3..5bcd2b62b5a2 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -3186,38 +3186,6 @@ static void *____cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, return obj ? obj : fallback_alloc(cachep, flags); } -static void *__do_cache_alloc(struct kmem_cache *cachep, gfp_t flags, int nodeid); - -static __always_inline void * -slab_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid, size_t orig_size, - unsigned long caller) -{ - unsigned long save_flags; - void *ptr; - struct obj_cgroup *objcg = NULL; - bool init = false; - - flags &= gfp_allowed_mask; - cachep = slab_pre_alloc_hook(cachep, NULL, &objcg, 1, flags); - if (unlikely(!cachep)) - return NULL; - - ptr = kfence_alloc(cachep, orig_size, flags); - if (unlikely(ptr)) - goto out_hooks; - - cache_alloc_debugcheck_before(cachep, flags); - local_irq_save(save_flags); - ptr = __do_cache_alloc(cachep, flags, nodeid); - local_irq_restore(save_flags); - ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller); - init = slab_want_init_on_alloc(flags, cachep); - -out_hooks: - slab_post_alloc_hook(cachep, objcg, flags, 1, &ptr, init); - return ptr; -} - static __always_inline void * __do_cache_alloc(struct kmem_cache *cachep, gfp_t flags, int nodeid) { @@ -3266,8 +3234,8 @@ __do_cache_alloc(struct kmem_cache *cachep, gfp_t flags, int nodeid __maybe_unus #endif /* CONFIG_NUMA */ static __always_inline void * -slab_alloc(struct kmem_cache *cachep, struct list_lru *lru, gfp_t flags, - size_t orig_size, unsigned long caller) +slab_alloc_node(struct kmem_cache *cachep, struct list_lru *lru, gfp_t flags, + int nodeid, size_t orig_size, unsigned long caller) { unsigned long save_flags; void *objp; @@ -3285,7 +3253,7 @@ slab_alloc(struct kmem_cache *cachep, struct list_lru *lru, gfp_t flags, cache_alloc_debugcheck_before(cachep, flags); local_irq_save(save_flags); - objp = __do_cache_alloc(cachep, flags, NUMA_NO_NODE); + objp = __do_cache_alloc(cachep, flags, nodeid); local_irq_restore(save_flags); objp = cache_alloc_debugcheck_after(cachep, flags, objp, caller); prefetchw(objp); @@ -3296,6 +3264,14 @@ slab_alloc(struct kmem_cache *cachep, struct list_lru *lru, gfp_t flags, return objp; } +static __always_inline void * +slab_alloc(struct kmem_cache *cachep, struct list_lru *lru, gfp_t flags, + size_t orig_size, unsigned long caller) +{ + return slab_alloc_node(cachep, lru, flags, NUMA_NO_NODE, orig_size, + caller); +} + /* * Caller needs to acquire correct kmem_cache_node's list_lock * @list: List of detached free slabs should be freed by caller @@ -3584,7 +3560,7 @@ EXPORT_SYMBOL(kmem_cache_alloc_trace); */ void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid) { - void *ret = slab_alloc_node(cachep, flags, nodeid, cachep->object_size, _RET_IP_); + void *ret = slab_alloc_node(cachep, NULL, flags, nodeid, cachep->object_size, _RET_IP_); trace_kmem_cache_alloc_node(_RET_IP_, ret, cachep, cachep->object_size, cachep->size, @@ -3602,7 +3578,7 @@ void *kmem_cache_alloc_node_trace(struct kmem_cache *cachep, { void *ret; - ret = slab_alloc_node(cachep, flags, nodeid, size, _RET_IP_); + ret = slab_alloc_node(cachep, NULL, flags, nodeid, size, _RET_IP_); ret = kasan_kmalloc(cachep, ret, size, flags); trace_kmalloc_node(_RET_IP_, ret, cachep,