Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1769406rda; Tue, 24 Oct 2023 02:44:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFWKO2w0qXPz3r8nM+oJLLDMSR/PakqLDX1/UTZ7N3E7qmjxNcK85oBafXCOSD1A7Cea7z1 X-Received: by 2002:a05:6871:4909:b0:1e9:a70c:1323 with SMTP id tw9-20020a056871490900b001e9a70c1323mr11621453oab.39.1698140657813; Tue, 24 Oct 2023 02:44:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698140657; cv=none; d=google.com; s=arc-20160816; b=pBy4TY6YQ7s9XQFo3xXrLN9tUpuoipDXCIEFfmeSQXfFuYJ2TUaG2hpVidEUUvI1y7 c/xBBuVP0LEvOGd77g52JK6bIBI8BDdZk4G4KMiOaIDg0j2A2KKfgPRMTy2bZtVBr3Tx 8BkgivI1dZ7n0DG21lCfIY5WWjnlEG2ISxnqzcXv4YC13PGEe4npVO2/JtwQq7gzo1jN YvAQSo6a/zwM3CtQT+9x7JIWEEv9jmySCL5EaUEH1zk7zHpcdxRQKXQSowHSVxhO/sen llADV9zGWapxBJpdhazSGAd1hRpZkmCMSlkl6iaIdtjf/LcsywjkMNle/GmFRuoDvn62 Tm5A== 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=nZerFoAj8INaI6ZSxOyjE3BeTDGPig5MeJKjJh1pMQ8=; fh=pb+eBl776ZRvna1F9CtRk2Qy3fEtolZ93e7lS3CUucI=; b=npX2VGJvu2Vh4DzOGMhDZV6AAEbandPTVFYmT+Nenx0DvWtvjIjaqVZqE/2yBsXE94 oA1gCFK52LHrxex+upmvzIC+dlL4OVHFdz2QPtK1MO3l9fjClCaJMvZIIbNsNReUZbjj TzZLlWOFQ5zO5A7VNsh/+y29knB55N1uKx+V/msdYBsL1NLC4M+7nQE5qV+kOG50O2vi f4ayb6tIDQKC7IH/q+La21WlHL47/4tGSnSExuOqtjz3wc1fr57LhbckeP9Z5WjTq56X kUb0nLV5coWqnd/+Nthhj/iWAXLLUcKQujQMR+NWJBfFEEbdUt3HsfAMblWwduShqu2o ccZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=V5gwmpkG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id u63-20020a638542000000b005b8afa325b8si4398347pgd.410.2023.10.24.02.44.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 02:44:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=V5gwmpkG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 24C4580CD71D; Tue, 24 Oct 2023 02:44:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233995AbjJXJoI (ORCPT + 99 others); Tue, 24 Oct 2023 05:44:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234547AbjJXJeJ (ORCPT ); Tue, 24 Oct 2023 05:34:09 -0400 Received: from out-191.mta0.migadu.com (out-191.mta0.migadu.com [91.218.175.191]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBF0610F6 for ; Tue, 24 Oct 2023 02:34:03 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1698140042; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nZerFoAj8INaI6ZSxOyjE3BeTDGPig5MeJKjJh1pMQ8=; b=V5gwmpkG8243Dq0GOsqzdIUFu+jgwdS+wsU2S/1oNpANH7Jiro5jaQ+wSigcoAXTIwUHR0 tz233Wke1fEJVMWATf22pDzMl0BDfdcprGotQ76eoP2bW65VEb0nau30v/bz1ONYQ7C1iq uidyW/b1k2Vm8H6knFM73iZoGZXo8uc= From: chengming.zhou@linux.dev To: cl@linux.com, penberg@kernel.org Cc: rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, vbabka@suse.cz, roman.gushchin@linux.dev, 42.hyeyoo@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, chengming.zhou@linux.dev, Chengming Zhou Subject: [RFC PATCH v3 3/7] slub: Reflow ___slab_alloc() Date: Tue, 24 Oct 2023 09:33:41 +0000 Message-Id: <20231024093345.3676493-4-chengming.zhou@linux.dev> In-Reply-To: <20231024093345.3676493-1-chengming.zhou@linux.dev> References: <20231024093345.3676493-1-chengming.zhou@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 24 Oct 2023 02:44:15 -0700 (PDT) From: Chengming Zhou The get_partial() interface used in ___slab_alloc() may return a single object in the "kmem_cache_debug(s)" case, in which we will just return the "freelist" object. Move this handling up to prepare for later changes. And the "pfmemalloc_match()" part is not needed for node partial slab, since we already check this in the get_partial_node(). Signed-off-by: Chengming Zhou --- mm/slub.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index f568a32d7332..cd8aa68c156e 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -3218,8 +3218,21 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, pc.slab = &slab; pc.orig_size = orig_size; freelist = get_partial(s, node, &pc); - if (freelist) - goto check_new_slab; + if (freelist) { + if (kmem_cache_debug(s)) { + /* + * For debug caches here we had to go through + * alloc_single_from_partial() so just store the + * tracking info and return the object. + */ + if (s->flags & SLAB_STORE_USER) + set_track(s, freelist, TRACK_ALLOC, addr); + + return freelist; + } + + goto retry_load_slab; + } slub_put_cpu_ptr(s->cpu_slab); slab = new_slab(s, gfpflags, node); @@ -3255,20 +3268,6 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, inc_slabs_node(s, slab_nid(slab), slab->objects); -check_new_slab: - - if (kmem_cache_debug(s)) { - /* - * For debug caches here we had to go through - * alloc_single_from_partial() so just store the tracking info - * and return the object - */ - if (s->flags & SLAB_STORE_USER) - set_track(s, freelist, TRACK_ALLOC, addr); - - return freelist; - } - if (unlikely(!pfmemalloc_match(slab, gfpflags))) { /* * For !pfmemalloc_match() case we don't load freelist so that -- 2.40.1