Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp270492rdb; Tue, 31 Oct 2023 07:09:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF2oLTZNKAHNrUuUZyTtT9AuRn4P4f9736l9VWZ8EMK5G0bTG3ShigInByiNKSbWX05Wd6W X-Received: by 2002:a05:6a20:3d06:b0:160:83e1:712f with SMTP id y6-20020a056a203d0600b0016083e1712fmr16625396pzi.23.1698761358885; Tue, 31 Oct 2023 07:09:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698761358; cv=none; d=google.com; s=arc-20160816; b=pacdb5vDCxS+7BKLW9pmZs6BoC201B8Vx/KrU74cts+M9Fje0oVrxsCGJEvvR67/X3 XFHt3Kze9Elgp1h25/cxEa12ZJcWp7jWXqBq7g3icGFKJ8WfA1UejI4NVajzJoB1TTkO 7i+M5mmoF0KuQ9wxOZg22019JknbzczShYbkWU0j4ej9Xiptts/jDjZsGtASEOh3DmRK pkX+RBVm3ZQGlgtRBBFSKMUdxwfDgW9KlnlIW6WpIEKjhKeorZs/qDIuJJDRqrbwXjTO jdQqaAP/wzAClfSYa/6O2s2ps9XXfaXC2rmS97YdOddCcuWUB9B9jq96G0kc1148nEdO Ruiw== 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=V/1IQ8DC4Ww2WANT0Yk1WGGMP6T1XolwvFVe/nWWtdo=; fh=1GJaSiew/4nhYvae+yJYXPcARWi0PNZhXd1mB5ASXRg=; b=mZ/itlPyaBxnlSAvGnW59yY4bOXdj3GoTWCKtU7SkfPIk21m5dQSy8/phH2TO1kbD3 QeV6rZWxnqWL2BxDuXFV2kbB5atfGqE5xUYs3N8nTMvtV8eB4dFqZ6VYv2Ibqkec/RQo qLwXjdlWZlbt/ugCva0TysUZUFyMX3xSmBJUGR4x6lXQF6HD05PY1h4KBa1u+B9lWs2W 96Qbj1xLCEyuzHRKWt1gijD8cOI6hs99zddWtC4l7ZzzWYXpFFJWiMzaHePgdBSP4hVV MJfuySFqQRB+vJ+kOZMjIfztBwK1oVTEvMejdKZaIQ3JmaMrr+iQj0e3u+N2M0CT277O rZTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=fWm3Ia9W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id j186-20020a638bc3000000b0058978136247si1057894pge.483.2023.10.31.07.09.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 07:09:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=fWm3Ia9W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id F137880BD53A; Tue, 31 Oct 2023 07:09:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230405AbjJaOJI (ORCPT + 99 others); Tue, 31 Oct 2023 10:09:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbjJaOJF (ORCPT ); Tue, 31 Oct 2023 10:09:05 -0400 Received: from out-179.mta1.migadu.com (out-179.mta1.migadu.com [IPv6:2001:41d0:203:375::b3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA376C1 for ; Tue, 31 Oct 2023 07:09:02 -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=1698761341; 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=V/1IQ8DC4Ww2WANT0Yk1WGGMP6T1XolwvFVe/nWWtdo=; b=fWm3Ia9WLFuFmGWFVj3nkTO3KKIcArYI3sKwoNpxt4Vp+VSnp85jAdULf4fwS1xOUGBFRy qaL4xq+9jHvu/YO3QBypb2sb88cVvTthrSNRtZkaROqU8A7pGtYB9RLWsXKVwXBPAiXyCD wIoAlyBL54p89iiOAU9sfE8NjzIGnzM= From: chengming.zhou@linux.dev To: vbabka@suse.cz, cl@linux.com, penberg@kernel.org, willy@infradead.org Cc: rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, 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 v4 1/9] slub: Reflow ___slab_alloc() Date: Tue, 31 Oct 2023 14:07:33 +0000 Message-Id: <20231031140741.79387-2-chengming.zhou@linux.dev> In-Reply-To: <20231031140741.79387-1-chengming.zhou@linux.dev> References: <20231031140741.79387-1-chengming.zhou@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 31 Oct 2023 07:09:16 -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 Reviewed-by: Vlastimil Babka --- mm/slub.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 63d281dfacdb..0b0fdc8c189f 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -3216,8 +3216,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); @@ -3253,20 +3266,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.20.1