Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp799603pxt; Thu, 5 Aug 2021 12:00:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5nddgkMstl0n6ELhgDNI9whK+VTX47FNjGE5N8NSul5Agjz+n44u9qVtOgwIwIsXWBQ/n X-Received: by 2002:a17:906:a0ce:: with SMTP id bh14mr6152355ejb.434.1628190019208; Thu, 05 Aug 2021 12:00:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628190019; cv=none; d=google.com; s=arc-20160816; b=YOEmSH9PSckdrtc+Eqdd4QxnOjJjaca0g3sXuhkNJ7yazrojpmdDpLLcCTpByAi6/+ uy1H+BOxdeHnww8NjzZXVugy7o91NdMAmqPT038l3s8WOijXntc/k6Lhazp2ncoMirOZ DnudsiZUIYWDAm1LbgqPm3LursmlhY0fjw8KHnW2eMlTolfiT4nKFzlLG95h4t9qXYiT CigO/0CH4Eejof4cKOhYJWrroH22v84jJbHMrV3lJ+BTkQusWt1Z3A8L2/T7Px+MGzEE b5i+Z1GTnyF/Iuo7SMJMLupe4bG5q7a+pu92vY6GzZlO5uaDkYnQAdGQzahGEAOzf/s8 3y0g== 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=3KJ7vlasVzPQcTiLWSXiy0hK+jbKlWoiBOdLIILXkXI=; b=muuw8CslZZCy78DKCXmZyFXtxZGDmaUw7Jxq5vtQa3gs+eEmzDzWvxf7SVxYX/eaQ/ 9/+6LE6iQnsEEmBC2k1u2ePLxz6cqAErSUdJG3aR1zPuEWXZ1a7rSlJE4UpwGYfMjnLo H1blRO0xMrd7cP4S8qmR7DG+zzMbGtq2z8ltPxC5dxdJE2dOAov66oz5KJMJslIjxVsE XNvRVwV5XvPl8Pw6UIiqhTOOvjmzSYNcWf4ZgPZDA5odL/z7gD2OWyIMkHr0vlMmKPG+ 2eCnJmN1VEmsIU5IzgnS08e1UZZCzCPAqhAM74hACzfWVOqMLzRUo3Q3DN+cMsydlSAe 9mAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=xszuG1TL; 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 di10si6518027edb.484.2021.08.05.11.59.52; Thu, 05 Aug 2021 12:00:19 -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=xszuG1TL; 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 S242025AbhHEPXW (ORCPT + 99 others); Thu, 5 Aug 2021 11:23:22 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:59232 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241919AbhHEPUV (ORCPT ); Thu, 5 Aug 2021 11:20:21 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id D404E2024C; Thu, 5 Aug 2021 15:20:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1628176805; 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=3KJ7vlasVzPQcTiLWSXiy0hK+jbKlWoiBOdLIILXkXI=; b=xszuG1TLoA0yGB5S4JJNPizIFTsz5UvtaUqoQC0wuMs4FM+N2firROk/87T1iZGkXMcgOh YD9k9or9TN6Lq40WB5vcsGS7QSsrxD66BOSERLJ9YsUrX4jZ2OfTViGMxTsYJfhBVL5v7J 0iXicrZqCWsNuTqBG+pdIa2XzH1vvHg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1628176805; 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=3KJ7vlasVzPQcTiLWSXiy0hK+jbKlWoiBOdLIILXkXI=; b=XEfe1NA6UGgoLlnGjrj87lrhIPevkYxl1de1fvPy3XvhfTyC6ynJiIEcfTKaOWYp6OBQkB hrzN0123F/rpYoBQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A4AD813DAC; Thu, 5 Aug 2021 15:20:05 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id QGCXJ6UBDGFDdQAAMHmgww (envelope-from ); Thu, 05 Aug 2021 15:20:05 +0000 From: Vlastimil Babka To: Andrew Morton , Christoph Lameter , David Rientjes , Pekka Enberg , Joonsoo Kim Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mike Galbraith , Sebastian Andrzej Siewior , Thomas Gleixner , Mel Gorman , Jesper Dangaard Brouer , Jann Horn , Vlastimil Babka Subject: [PATCH v4 09/35] mm, slub: return slab page from get_partial() and set c->page afterwards Date: Thu, 5 Aug 2021 17:19:34 +0200 Message-Id: <20210805152000.12817-10-vbabka@suse.cz> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210805152000.12817-1-vbabka@suse.cz> References: <20210805152000.12817-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_cpu. In later patch we will need more control over the kmem_cache_cpu.page assignment, so instead of passing a kmem_cache_cpu pointer, pass a pointer to a pointer to a page that get_partial() can fill and the caller can assign the kmem_cache_cpu.page pointer. No functional change as all of this still happens with disabled IRQs. 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 3222ea51fb50..ed18fa3157ad 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2000,7 +2000,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; @@ -2029,7 +2029,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 { @@ -2049,7 +2049,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; @@ -2091,7 +2091,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() @@ -2113,7 +2113,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; @@ -2121,11 +2121,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 @@ -2737,9 +2737,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); @@ -2763,7 +2765,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.32.0