From patchwork Tue Oct 31 14:07:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengming Zhou X-Patchwork-Id: 13441575 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 1DE1DC4167D for ; Tue, 31 Oct 2023 14:09:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B1AAE6B0301; Tue, 31 Oct 2023 10:09:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AC9DB6B0300; Tue, 31 Oct 2023 10:09:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 96A9B6B0301; Tue, 31 Oct 2023 10:09:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 883F26B02FE for ; Tue, 31 Oct 2023 10:09:05 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id D56AF1A070D for ; Tue, 31 Oct 2023 14:09:04 +0000 (UTC) X-FDA: 81405938208.26.92A9464 Received: from out-186.mta1.migadu.com (out-186.mta1.migadu.com [95.215.58.186]) by imf22.hostedemail.com (Postfix) with ESMTP id C35C3C000C for ; Tue, 31 Oct 2023 14:09:02 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=fWm3Ia9W; spf=pass (imf22.hostedemail.com: domain of chengming.zhou@linux.dev designates 95.215.58.186 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1698761342; 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=V/1IQ8DC4Ww2WANT0Yk1WGGMP6T1XolwvFVe/nWWtdo=; b=N60ZHEKevHrWvbq+lRHU3Wp3YoVlWb1QkQwRhOIoC0XZ+9MuyYjM/8IZXdr4sQa2AZueCT gsjFjx9ivWC8wEnwK8T1mAsm4kl15/kg1H9wi73U88uOT2rI5rWOQwSkp4aEFCuV6LbvPE CzQDzuMSg3aL9Zn4BStGEoEnrJ13pwE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698761343; a=rsa-sha256; cv=none; b=QkXwCIbV11zApFdhXra522+Eq7pBQfqZiaNMpp1ABNKLmQG4+DKwfUZluUL9yr6gWn7SRL UWIuOt6xML/6ozUHl1UdiHCX6DfqXglBABdLyCsoTx2VG/kX8Rt0irJqbNCmr38wGQ+oaI J1euPjFflgpf4hTXBVp223BCAxcRoCc= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=fWm3Ia9W; spf=pass (imf22.hostedemail.com: domain of chengming.zhou@linux.dev designates 95.215.58.186 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev; dmarc=pass (policy=none) header.from=linux.dev 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 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: C35C3C000C X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: ef6a9watcm7zcgcxec19j9da8setied9 X-HE-Tag: 1698761342-93511 X-HE-Meta: U2FsdGVkX19uI8C8/qoaLSElIaZdPJnJD6QzX3GqIGhNNCGEKXPQXFu2Zm8aC29VVa9G6OZhqu99ygvTzeaisDdo2eFsxzVq5FQeByF1aG3Z6DQcFsy3Khs8dG5ITl8bFR9PNlcAYKQ0FFZMv5w5sKHQEvQNdK5WiOzljHWgLK/21msRKJJ7JWcZzTF6apkmj//pY3k9WREUfS4mpH4c67AwAw9HKLblcRaso8CMq2r9d8qL9AqXZylGyQku30bygtCrBUONpLK3IehTGdDwBmWWsau/A+6srSGo3/H3kEsthCb/0yqlQaH7blKSu58VasiRe1WiJeI8q/G2gACnod0t8KL916qIuhTSEMLxZxu3uOfpMGiDSeo4w8ahbmSXTJrdIUOQVut9z4aPKla/LjTTvIvrWy4gicyY8hRYkiZRqjA11OEx9lFUtywxIzV9bslp5XxHgIc867KSfxYt5+e0SrYk6bF7q0WFi4ezdE+B/uSk6NGkGqHlzOgah1pgBI/VR9EP9RwADIBf2JPROOGg+C7qLT+YOMzPKalSluqc1F7AQyTEBPC/VOuMNP0pZ6WZ5ZyHSK+wAeiWHFQLfn3Dya/62a3kG3jjYYy1zWLBuPD0Dlo3QcmdPvFudKALYVYVRsG73wMYfIJLeVj2FOx4xtPQF2XnPMYXqY4OfHWpKLv9c8hRvx1DiZTEFdo51njUtyVEr8dKUlvs/x96e2uyviYmgtJjKmk9dr0Ej6yHDVteB6faGZYbuCfSBWmm0Nx5bEQb+8eeMRxfmYVYxgoVB81boa9UNLocxi5Fu6iRyIn8BMkxwxPU7SwQrJgdmcVxUTq0ugOG+Yjgm7yjaDXIQragN6l4wskqFQcdSZcP7Lmpe4f/W1VLciH6pkSuJ2rbmOEMVEnYZuAPxlALwACnSRla1Cojcy0AChP39jMbFzr12FBePhA1TPyRV1ayJ4IsgEJIrz1uFPAkrL+ MFls9MRF wFpt/PhRjb+uNG6E0q8IB8jH5k1epkdtq0rsLbkJmeM/4JkIfsuFq6AAqXOyb/c91ctWuFpdQNIlzNIzi5YGX42jEtsuOD27fcbz4mLZT7HOnTLiSvjSRH4BiN5Tlq/zlRZd5cWEDVCxz5zEwE+O2Ph5W8Nh3GypYNRhJ8+sEO5T7fUsJ053+Yzvh1d4ChzxD4/esfdMU8OnrEnJFHHbcaK4sXRqv9KYpK05qwX2qPrKQ9Oll1A9ldu44Dnp8etLizYx7Y/7K3bnoTgUatwrs975qWw== 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: List-Subscribe: List-Unsubscribe: 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