Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4374877imw; Tue, 12 Jul 2022 06:59:51 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tcaUK702GfD3RRtU8/cCARAVa9MrWzRr88wwLFG2Qf9EIXsoL/rJcOYgBl2Qv4EZagl+cA X-Received: by 2002:a05:6402:d05:b0:425:b5c8:faeb with SMTP id eb5-20020a0564020d0500b00425b5c8faebmr31340435edb.273.1657634390771; Tue, 12 Jul 2022 06:59:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657634390; cv=none; d=google.com; s=arc-20160816; b=XUOMj8BrIFST6ZVWsxqLJu6gom7QPPAksye2LNMZYPpm9YOAFMj2Vxvevy0daOznQz zYt0ASig9APng9AWbbZ/w3opi7fh7wrGCsIjhkdMwtt0oXVwcP9ZCGwn5RuqVtryq76Q Q4wd70V1SHWfMKLsoFKNnoqxiQxa4Df8kcw3c8IDsGDVezWBFiPCH4B9woZmImzfr56T ME9d2cRjs8en6HnleLsqtzR5UcmtLsZzUMB5XrhXc56QjWbifNC/ENFseHVf8qn1B/3X SGOnJHJn5G74veWwNVDMBAU6FZ5fatYNuqtVfojPxEX+Coz6wkfxPOHbgFZIcjOtTR6V v3SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=r/sC4QUhXRkGGh2bMZjIx8vUi/+M03CaD7v75Vc4qIM=; b=rbMLB8MWDmxQ9CGmaH8X4cf5vuV4pqZzbOBlpih9Z0uiw6UeR4IxK2jukRaIaWnS/z XgKGZpJaY3UCDlQRAOLAjYQrE79BwLOuOKMRFUETUPdhjCQ30ncyi7kdOfEdygbsJEW+ EhfyDy55TS7xH1GunCD0Sj2zgVX9dFAKb+azq4/PHL6iU8st3hv2DIDjfiV1Pm7bgeQM hYUMV/y4Lz2fUn2Em6rC161TesgR1aDQeHk6hJ9G8P3zw03GlTXvW9vS2ShXQDWn815B ARntxFQC0qZTJEwQepsv8dwLVl2j0ZZFAEfJ/SW+NZBIYXsDQTF12EKr4rS2m6q8y/oN H4yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Q4gF1YgE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o2-20020a056402438200b0043abd7a1ba6si13755134edc.618.2022.07.12.06.59.24; Tue, 12 Jul 2022 06:59:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Q4gF1YgE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233175AbiGLNkM (ORCPT + 99 others); Tue, 12 Jul 2022 09:40:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233171AbiGLNkD (ORCPT ); Tue, 12 Jul 2022 09:40:03 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E75E5B79F9 for ; Tue, 12 Jul 2022 06:40:00 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id q5-20020a17090a304500b001efcc885cc4so8009369pjl.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=xB/+ST/XGMxaf/x3ctHswoz9odRZLmeOYDXCUvUKDsWY9EdKUApT4EEpQwukDM5QIm daNkUYM6iDFZEiF4VnvAwx6tSFRrwFVFgxh+T0fiwrZqGlN8V8zoL2r8QqFBEOy3eiG5 fsg2KenGGdbrgnGF4DDaB+YuSQHRb+pyvYidMb5cIrm+88txQSTSg+Dos94bkWqk7DKQ hRTnoZFlr1YwQO/74EEN7ec87SJjQ8fh4zdSuR3YCbRx9kyD5yUfnEbQNY9HXKkMz25X 8SpAgJtbIY5oXavUhQhg2eokLqyf+SAwDACoZJ8XDoU4pU2eZZGLYtpoRuFCVft8A4a1 cJXQ== X-Gm-Message-State: AJIora+0iqn9T3BdKm8YaQqQB/S4I5uBQ2NQYerhfQxTJQ31WmpqrVAl gPI+8ODPwyKZQzVgfBOfBOU= 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HK_RANDOM_ENVFROM, HK_RANDOM_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, -- 2.34.1