Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3846087pxj; Mon, 24 May 2021 16:43:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSyicwqLzTfs4+GZD6LxFx7OvnQCNq5HnmBzyXufqht9r7gUK7FCDnc2DEhWkOkbUSt9oF X-Received: by 2002:a17:906:3c56:: with SMTP id i22mr25401470ejg.147.1621899794357; Mon, 24 May 2021 16:43:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621899794; cv=none; d=google.com; s=arc-20160816; b=WtSSJOE2tkGonWHo3DC056Ic1yNRIiFSuOAbp13u2VtIiKAiJqUEnClz/zXWL2JDnP 34G4D/Hl6JQavtD1uwFfJtQJtxcs/lfFXURLJyAqq0pfZZ8p7Kj/VOmtUEyXZiZutrA3 UcpQ72cM1Ozbk4Ukkfv6utX+R+w8s5OTt/9fGetmyV55gMW0Wd8L5uVDUqhZD/wesfr3 /hN9wJHEMBHBt+BdqdIs3ls3HQollvmr7ytoq0U9f0gl8q28ac9BuvO7gfYieNABdyJw ioaSz6NCCwPdY8vzjLbyTmhqrQv9mWxsyaKJsxXabFaV+onf3ROy0WCGU0Wr9y9NHEmB lrmA== 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:dkim-signature; bh=Itpk5RUVIGbzOPy2bBQujTjq+wd25hK2eSbkgY6gPGQ=; b=ID+FBkGta/KRiJzvSP2tbSGbMFnBkX1p/krgh67fV9x3GfJltgsNizXpon6Xf79wMb 9mZw/XGENX3HykpOwyEuNnqZTBlYGWufnh+wfybhKEQq5HuEXXkZzCt7lAV/6RsSoT+C 7nImXxNSA3uGCMyrKma4YYH2P4NkRXIMhNAyqSGCA6P8ftv59iDh29Z82340IqZM7svW DkmKmM0Uey5emUu1JvQ5tBWVYOlWcEHswrkiB83NIuDtnN845fr43yXeozzzrJlLwvrO sHhvzANYgXucQbKxzbtMIIkQO4VqM+8+6KEmMNaQpArrzwUIG4Uf3AuM6kfJmNxMfIO7 SUCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=zc1bXgW8; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c10si13363642edr.581.2021.05.24.16.42.52; Mon, 24 May 2021 16:43:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=zc1bXgW8; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230094AbhEXXmq (ORCPT + 99 others); Mon, 24 May 2021 19:42:46 -0400 Received: from mx2.suse.de ([195.135.220.15]:50690 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229819AbhEXXmU (ORCPT ); Mon, 24 May 2021 19:42:20 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1621899648; h=from:from:reply-to: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=Itpk5RUVIGbzOPy2bBQujTjq+wd25hK2eSbkgY6gPGQ=; b=zc1bXgW83EUrZ2Nr+mnIOlovX/VcqohQuu2pLMfSO/wN15bXtx81UzJSR8ewJJdoUGycNm t2KxvXEWOIZz6BxRsE+ghmU18IUV4RIxT4U2hw+EPWnjS6vbk8I9o0tyUiXmgeFXn3xGij r4xbvdDNVbiROzCgxG9Mmkw/1Ax3EFw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1621899648; h=from:from:reply-to: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=Itpk5RUVIGbzOPy2bBQujTjq+wd25hK2eSbkgY6gPGQ=; b=M5KMWt/JDneaR0KQJ5KLSENBWRR7oRYoWiI2q1dYkCBsn2WiHC6jz47qjeHKxwAyqvX3PX PmowsNFq0vOvSzBQ== Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 35CF5AF26; Mon, 24 May 2021 23:40:48 +0000 (UTC) From: Vlastimil Babka To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Christoph Lameter , David Rientjes , Pekka Enberg , Joonsoo Kim Cc: Sebastian Andrzej Siewior , Thomas Gleixner , Mel Gorman , Jesper Dangaard Brouer , Peter Zijlstra , Jann Horn , Vlastimil Babka Subject: [RFC 07/26] mm, slub: return slab page from get_partial() and set c->page afterwards Date: Tue, 25 May 2021 01:39:27 +0200 Message-Id: <20210524233946.20352-8-vbabka@suse.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524233946.20352-1-vbabka@suse.cz> References: <20210524233946.20352-1-vbabka@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The function get_partial() finds a suitable page on a partial list, acquires and returns its freelist and assigns the page pointer to kmem_cache_node. In later patch we will need more control over the kmem_cache_node assignment, so instead return the page pointer to get_partial()'s caller and assign it there. No functional change as all of this still happens with disabled irq. Signed-off-by: Vlastimil Babka --- mm/slub.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 9d1d872f5ab9..f240e424c861 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1971,7 +1971,7 @@ static inline bool pfmemalloc_match(struct page *page, gfp_t gfpflags); * Try to allocate a partial slab from a specific node. */ static void *get_partial_node(struct kmem_cache *s, struct kmem_cache_node *n, - struct kmem_cache_cpu *c, gfp_t flags) + struct page **ret_page, gfp_t flags) { struct page *page, *page2; void *object = NULL; @@ -2000,7 +2000,7 @@ static void *get_partial_node(struct kmem_cache *s, struct kmem_cache_node *n, available += objects; if (!object) { - c->page = page; + *ret_page = page; stat(s, ALLOC_FROM_PARTIAL); object = t; } else { @@ -2020,7 +2020,7 @@ static void *get_partial_node(struct kmem_cache *s, struct kmem_cache_node *n, * Get a page from somewhere. Search in increasing NUMA distances. */ static void *get_any_partial(struct kmem_cache *s, gfp_t flags, - struct kmem_cache_cpu *c) + struct page **ret_page) { #ifdef CONFIG_NUMA struct zonelist *zonelist; @@ -2062,7 +2062,7 @@ static void *get_any_partial(struct kmem_cache *s, gfp_t flags, if (n && cpuset_zone_allowed(zone, flags) && n->nr_partial > s->min_partial) { - object = get_partial_node(s, n, c, flags); + object = get_partial_node(s, n, ret_page, flags); if (object) { /* * Don't check read_mems_allowed_retry() @@ -2084,7 +2084,7 @@ static void *get_any_partial(struct kmem_cache *s, gfp_t flags, * Get a partial page, lock it and return it. */ static void *get_partial(struct kmem_cache *s, gfp_t flags, int node, - struct kmem_cache_cpu *c) + struct page **ret_page) { void *object; int searchnode = node; @@ -2092,11 +2092,11 @@ static void *get_partial(struct kmem_cache *s, gfp_t flags, int node, if (node == NUMA_NO_NODE) searchnode = numa_mem_id(); - object = get_partial_node(s, get_node(s, searchnode), c, flags); + object = get_partial_node(s, get_node(s, searchnode), ret_page, flags); if (object || node != NUMA_NO_NODE) return object; - return get_any_partial(s, flags, c); + return get_any_partial(s, flags, ret_page); } #ifdef CONFIG_PREEMPTION @@ -2715,9 +2715,11 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, goto redo; } - freelist = get_partial(s, gfpflags, node, c); - if (freelist) + freelist = get_partial(s, gfpflags, node, &page); + if (freelist) { + c->page = page; goto check_new_page; + } page = new_slab(s, gfpflags, node); @@ -2741,7 +2743,6 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, c->page = page; check_new_page: - page = c->page; if (likely(!kmem_cache_debug(s) && pfmemalloc_match(page, gfpflags))) goto load_freelist; -- 2.31.1