From patchwork Tue Jan 4 00:10:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 12702862 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 76DDEC433FE for ; Tue, 4 Jan 2022 00:11:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED7236B0092; Mon, 3 Jan 2022 19:10:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A551D6B008C; Mon, 3 Jan 2022 19:10:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 28BC16B008A; Mon, 3 Jan 2022 19:10:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0095.hostedemail.com [216.40.44.95]) by kanga.kvack.org (Postfix) with ESMTP id 86AA46B0095 for ; Mon, 3 Jan 2022 19:10:57 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 40D3E90F5D for ; Tue, 4 Jan 2022 00:10:57 +0000 (UTC) X-FDA: 78990674154.25.773ED36 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf14.hostedemail.com (Postfix) with ESMTP id 29E4C10000B for ; Tue, 4 Jan 2022 00:10:55 +0000 (UTC) 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-out1.suse.de (Postfix) with ESMTPS id CB57D212BC; Tue, 4 Jan 2022 00:10:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1641255055; 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=YjegpdWpFeLRS01Hfzpc6UdrF/Ml0TEZLI/cOzLH1Rw=; b=hokgIIP8caXlYS3I0yuJSwELb378UbDlTR4WE4YHwtgQopGxwV5JTYUA6MeTbISYaKkpjZ 3/DcUidBj9ZbcqVy9iCBVdoi4uJUIBqJ4x/1ervWFNuaptt+/64jyQJtXfsWZs3ab0Yby9 rO8GCSA7pWLRlpytzV4iipvkLer/+9g= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1641255055; 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=YjegpdWpFeLRS01Hfzpc6UdrF/Ml0TEZLI/cOzLH1Rw=; b=gfQ7hcIA8TD6BdT7nSEPSk9U8qLzY+rENNaV42hlDphgodn5N8ynaXeMWq2+aFhxNXjPAe u+vpeU5WqD61PWAQ== 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 A07D8139D1; Tue, 4 Jan 2022 00:10:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id WD+NJo+Q02FEQwAAMHmgww (envelope-from ); Tue, 04 Jan 2022 00:10:55 +0000 From: Vlastimil Babka To: Matthew Wilcox , Christoph Lameter , David Rientjes , Joonsoo Kim , Pekka Enberg Cc: linux-mm@kvack.org, Andrew Morton , Johannes Weiner , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, patches@lists.linux.dev, Vlastimil Babka Subject: [PATCH v4 16/32] mm/slub: Convert pfmemalloc_match() to take a struct slab Date: Tue, 4 Jan 2022 01:10:30 +0100 Message-Id: <20220104001046.12263-17-vbabka@suse.cz> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220104001046.12263-1-vbabka@suse.cz> References: <20220104001046.12263-1-vbabka@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3028; i=vbabka@suse.cz; h=from:subject; bh=Pn37dXMX8RKLEDtW9qNrBwy1C9fNUsRg9YSuuIjgvy0=; b=owEBbQGS/pANAwAIAeAhynPxiakQAcsmYgBh05B3Nw881zQB5O5PLVqOx2iK61+7RWmpQNa1ZlHg Ny0a2HuJATMEAAEIAB0WIQSNS5MBqTXjGL5IXszgIcpz8YmpEAUCYdOQdwAKCRDgIcpz8YmpEJJmB/ 4u2nYrhjfc2+CZyn2iVdcaDZJp+/e3e+VyZDov1JKAM0sFhSicSJ4fbWk3gHQX9qgMSTP8dqvhtvFE hKypS5t61RA1CcqNdxZ7ycWDsb0jvJVlmLg0lgMNExKWDFCzYeIRMq8qlTysbDDhk1hmJP3pRTulrz SeDFdsI8WYnaV0tS0oy5by1z5r899Hl81tiaTwbkQudP6v9a8KA85uir8N0viAU2juiy4OTO0cgaY6 sY0NDi9BylX3kAj4txLm/UU+Z2Ag+LS/tD48EkxBN6B6WkF4yRRg0R4WUO8CgqPFKFKXZi9byVJ1V9 0L2mhsddjiaBQn9tWqmY5vAT4WJFSl X-Developer-Key: i=vbabka@suse.cz; a=openpgp; fpr=A940D434992C2E8E99103D50224FA7E7CC82A664 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 29E4C10000B X-Stat-Signature: ibm35o19y9y5a8yib1x3nkjjsesnhmnk Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=hokgIIP8; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=gfQ7hcIA; spf=pass (imf14.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none X-HE-Tag: 1641255055-750012 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: From: "Matthew Wilcox (Oracle)" Preparatory for mass conversion. Use the new slab_test_pfmemalloc() helper. As it doesn't do VM_BUG_ON(!PageSlab()) we no longer need the pfmemalloc_match_unsafe() variant. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Vlastimil Babka Reviewed-by: Roman Gushchin Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/slub.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 4d64c5b42629..c369806084e1 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2128,7 +2128,7 @@ static void put_cpu_partial(struct kmem_cache *s, struct page *page, int drain); static inline void put_cpu_partial(struct kmem_cache *s, struct page *page, int drain) { } #endif -static inline bool pfmemalloc_match(struct page *page, gfp_t gfpflags); +static inline bool pfmemalloc_match(struct slab *slab, gfp_t gfpflags); /* * Try to allocate a partial slab from a specific node. @@ -2154,7 +2154,7 @@ static void *get_partial_node(struct kmem_cache *s, struct kmem_cache_node *n, list_for_each_entry_safe(page, page2, &n->partial, slab_list) { void *t; - if (!pfmemalloc_match(page, gfpflags)) + if (!pfmemalloc_match(page_slab(page), gfpflags)) continue; t = acquire_slab(s, n, page, object == NULL); @@ -2832,22 +2832,9 @@ slab_out_of_memory(struct kmem_cache *s, gfp_t gfpflags, int nid) #endif } -static inline bool pfmemalloc_match(struct page *page, gfp_t gfpflags) +static inline bool pfmemalloc_match(struct slab *slab, gfp_t gfpflags) { - if (unlikely(PageSlabPfmemalloc(page))) - return gfp_pfmemalloc_allowed(gfpflags); - - return true; -} - -/* - * A variant of pfmemalloc_match() that tests page flags without asserting - * PageSlab. Intended for opportunistic checks before taking a lock and - * rechecking that nobody else freed the page under us. - */ -static inline bool pfmemalloc_match_unsafe(struct page *page, gfp_t gfpflags) -{ - if (unlikely(__PageSlabPfmemalloc(page))) + if (unlikely(slab_test_pfmemalloc(slab))) return gfp_pfmemalloc_allowed(gfpflags); return true; @@ -2949,7 +2936,7 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, * PFMEMALLOC but right now, we are losing the pfmemalloc * information when the page leaves the per-cpu allocator */ - if (unlikely(!pfmemalloc_match_unsafe(page, gfpflags))) + if (unlikely(!pfmemalloc_match(page_slab(page), gfpflags))) goto deactivate_slab; /* must check again c->page in case we got preempted and it changed */ @@ -3061,7 +3048,7 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, } } - if (unlikely(!pfmemalloc_match(page, gfpflags))) + if (unlikely(!pfmemalloc_match(page_slab(page), gfpflags))) /* * For !pfmemalloc_match() case we don't load freelist so that * we don't make further mismatched allocations easier.