Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4416122imw; Tue, 12 Jul 2022 07:35:57 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vEBKsZgiVtIvnIi4zEk7gZoaHqt/KcCyUciUUKh6uR9deEQV/NL6heLKcnQJKzftwmlG1S X-Received: by 2002:a17:907:2c61:b0:72b:3a12:5121 with SMTP id ib1-20020a1709072c6100b0072b3a125121mr17456757ejc.52.1657636557167; Tue, 12 Jul 2022 07:35:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657636557; cv=none; d=google.com; s=arc-20160816; b=Dn9ouWXLtL/l3DJFUHcZ/N5iwjnAM2TD+7PTIa9Ys0ewmmUALpqa14bat+mBMMZJPJ FSWq1atGCmwM1QI8DivbZwBYR1Jk1+1xwLLIliX5VS1Jr4AmUJ96yOL66UEH5t5vlbkA r4UwFz1eyscH9+YhtQX4opMGPYrFQhEE1Y3e16v62dmHhHxGCR7TroVZF/JHSb1we6sF sFF1hFXR/fYF5vk2LSaDH7P++yQHnQ80zdeyYqs6hqrGm0c67ZQ9re8OgoaputT84MZB X//d9NaZQefr+vE+Uzp/3VPJ00xhXXPeEUnwMaCfIbl2Hh/mXtX5juh1cpzj+WSmGt5M 7Aig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=7H8tkpBxnBdiZo3DXoVeZeAacccKssPXr2lR8DnOrqE=; b=zzB/rSqZZVhdGI5TS4hhvqLeQC4lcdGxTDq72+CxbsadfxzSXLJU/w93jCa2r6lBOb 6IUFrfyzgw02GII6S3tymQtg5ii3azYC3r58LnOYAGdnNSXPiMLQrB71bVgGiiVdOv7W 8RfUSDVxweupQcm9pSzsy8HyvMjJCnV7OvsudTaunmyITPyqsOagSt8EmHRnBYh82uT9 FCux4ZBBov2/1VIe553CdPSfi5x3n8sP8avV8Ug2fFRubzJPFt6gpSM/w8nHMOApzJM1 ByDvgrF1M0e2X7R0iLK54OaipHqe0PXokeWqK4VjTGaTUrRiM2Cp1EJni7zKkx0ytsMt qMyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gentwo.de header.s=default header.b=chNsj66T; 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=NONE dis=NONE) header.from=gentwo.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hy23-20020a1709068a7700b00718cd33f793si12321272ejc.158.2022.07.12.07.35.30; Tue, 12 Jul 2022 07:35:57 -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=@gentwo.de header.s=default header.b=chNsj66T; 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=NONE dis=NONE) header.from=gentwo.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229497AbiGLO3S (ORCPT + 99 others); Tue, 12 Jul 2022 10:29:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233572AbiGLO3N (ORCPT ); Tue, 12 Jul 2022 10:29:13 -0400 Received: from gentwo.de (gentwo.de [IPv6:2a02:c206:2048:5042::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60038D8F for ; Tue, 12 Jul 2022 07:29:12 -0700 (PDT) Received: by gentwo.de (Postfix, from userid 1001) id C672CB00422; Tue, 12 Jul 2022 16:29:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gentwo.de; s=default; t=1657636150; bh=XqZSR6vsTCgGnza0thiZL4p41K1Z4arAxxg+LT4Q08U=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=chNsj66T6C5Yjk38kP6Y0X+r2jkn6hvDNBcnA8D90YmilYAEo5d6zRTUSGwXkkFGD o4lGaT7bKF3qaMOK3o4XvxNYZsUEBs1pY/ZziLN5sFaKAjqCqQ+SEMquPrZ1LRpyDv ohhlK1pLjQW8JhhsSAZpI74oGAorx26f9mV7Q0TpRt3h0iDUPNuSHyPZkYHpnTRci8 ifnorxskQC3dnoBIMmxhQMIof19CKPgpELRmSpY0MoGwy/UnfTmO02wdywBKRYBs/i m6V9lhor16N7I5+uS6nL7N3YF6S5RAz2NwBUGR3ilCR2WNNUjiGFstbqKSKcbaN4OV ldKCg7YAdQfmg== Received: from localhost (localhost [127.0.0.1]) by gentwo.de (Postfix) with ESMTP id C2A03B0026E; Tue, 12 Jul 2022 16:29:10 +0200 (CEST) Date: Tue, 12 Jul 2022 16:29:10 +0200 (CEST) From: Christoph Lameter To: Hyeonggon Yoo <42.hyeyoo@gmail.com> cc: Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Roman Gushchin , Joe Perches , Vasily Averin , Matthew WilCox , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v3 1/15] mm/slab: move NUMA-related code to __do_cache_alloc() In-Reply-To: <20220712133946.307181-2-42.hyeyoo@gmail.com> Message-ID: References: <20220712133946.307181-1-42.hyeyoo@gmail.com> <20220712133946.307181-2-42.hyeyoo@gmail.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 On Tue, 12 Jul 2022, Hyeonggon Yoo wrote: > @@ -3241,31 +3219,46 @@ slab_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid, size_t orig_ > } > > static __always_inline void * > -__do_cache_alloc(struct kmem_cache *cache, gfp_t flags) > +__do_cache_alloc(struct kmem_cache *cachep, gfp_t flags, int nodeid) > { > - void *objp; > + void *objp = NULL; > + int slab_node = numa_mem_id(); > > - if (current->mempolicy || cpuset_do_slab_mem_spread()) { > - objp = alternate_node_alloc(cache, flags); > - if (objp) > - goto out; > + if (nodeid == NUMA_NO_NODE) { > + if (current->mempolicy || cpuset_do_slab_mem_spread()) { > + objp = alternate_node_alloc(cachep, flags); > + if (objp) > + goto out; > + } > + /* > + * Use the locally cached objects if possible. > + * However ____cache_alloc does not allow fallback > + * to other nodes. It may fail while we still have > + * objects on other nodes available. > + */ > + objp = ____cache_alloc(cachep, flags); > + nodeid = slab_node; > + } else if (nodeid == slab_node) { > + objp = ____cache_alloc(cachep, flags); > + } else if (!get_node(cachep, nodeid)) { > + /* Node not bootstrapped yet */ > + objp = fallback_alloc(cachep, flags); > + goto out; > } > - objp = ____cache_alloc(cache, flags); > > /* > * We may just have run out of memory on the local node. > * ____cache_alloc_node() knows how to locate memory on other nodes > */ > if (!objp) > - objp = ____cache_alloc_node(cache, flags, numa_mem_id()); > - > + objp = ____cache_alloc_node(cachep, flags, nodeid); Does this preserve the original behavior? nodeid is the parameter passed to __do_cache_alloc(). numa_mem_id() is the nearest memory node.