From patchwork Thu Dec 16 23:48:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 12683101 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 C205AC433F5 for ; Thu, 16 Dec 2021 23:55:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C513B6B007B; Thu, 16 Dec 2021 18:53:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BD9536B007D; Thu, 16 Dec 2021 18:53:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A54946B007E; Thu, 16 Dec 2021 18:53:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0198.hostedemail.com [216.40.44.198]) by kanga.kvack.org (Postfix) with ESMTP id 9526B6B007B for ; Thu, 16 Dec 2021 18:53:01 -0500 (EST) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 5ED90180E1E3D for ; Thu, 16 Dec 2021 23:52:51 +0000 (UTC) X-FDA: 78925310142.13.E835E37 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf27.hostedemail.com (Postfix) with ESMTP id 8CDBB40018 for ; Thu, 16 Dec 2021 23:52:50 +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-out2.suse.de (Postfix) with ESMTPS id 964391F3A1; Thu, 16 Dec 2021 23:52:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1639698769; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7ousG1C9Pxwr7ZMS3mSr07mvDQMxv5ZghnPgeMf5y5g=; b=LZTBmx+YstZRDskbnMwV6zkDjYe93SBkIGqjHStCAnwzjkMxskosNMqvaccsA+Kajs/Y3e 4TyAjP1udslAhzgZqWgznoYCzWqn0Y95H78dR0yIqzarh8rdmbErnaoKXTUpSNXPgyKvT/ G+IUkpEySr3DlAty65nYefYOE+JC1kI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1639698769; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7ousG1C9Pxwr7ZMS3mSr07mvDQMxv5ZghnPgeMf5y5g=; b=IxGPaeBY0t2YOmBoUfLGHbsyDNeAXuMNUW8TD3DA5PWYhO6cDHdZji2FUTqXBz5ZTOh7Vx 5QIeulAD/grm24Dg== 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 87F9513EFD; Thu, 16 Dec 2021 23:52:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id vcfFEE7Ru2FlWwAAMHmgww (envelope-from ); Thu, 16 Dec 2021 23:52:46 +0000 Subject: [PATCH 05/18] MM: reclaim mustn't enter FS for SWP_FS_OPS swap-space From: NeilBrown To: Trond Myklebust , Anna Schumaker , Chuck Lever , Andrew Morton , Mel Gorman , Christoph Hellwig , David Howells Cc: linux-nfs@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Fri, 17 Dec 2021 10:48:22 +1100 Message-ID: <163969850295.20885.4255989535187500085.stgit@noble.brown> In-Reply-To: <163969801519.20885.3977673503103544412.stgit@noble.brown> References: <163969801519.20885.3977673503103544412.stgit@noble.brown> User-Agent: StGit/0.23 MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 8CDBB40018 X-Stat-Signature: zojuaw391dbd71jm5usgtbfefoocjb63 Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=LZTBmx+Y; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=IxGPaeBY; spf=pass (imf27.hostedemail.com: domain of neilb@suse.de designates 195.135.220.29 as permitted sender) smtp.mailfrom=neilb@suse.de; dmarc=pass (policy=none) header.from=suse.de X-HE-Tag: 1639698770-885560 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: If swap-out is using filesystem operations (SWP_FS_OPS), then it is not safe to enter the FS for reclaim. So only down-grade the requirement for swap pages to __GFP_IO after checking that SWP_FS_OPS are not being used. Signed-off-by: NeilBrown Reported-by: kernel test robot --- mm/vmscan.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 969bcdb4ca80..5f460d174b1b 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1465,6 +1465,21 @@ static unsigned int demote_page_list(struct list_head *demote_pages, return nr_succeeded; } +static bool test_may_enter_fs(struct page *page, gfp_t gfp_mask) +{ + if (gfp_mask & __GFP_FS) + return true; + if (!PageSwapCache(page) || !(gfp_mask & __GFP_IO)) + return false; + /* We can "enter_fs" for swap-cache with only __GFP_IO + * providing this isn't SWP_FS_OPS. + * ->flags can be updated non-atomicially (scan_swap_map_slots), + * but that will never affect SWP_FS_OPS, so the data_race + * is safe. + */ + return !data_race(page_swap_info(page)->flags & SWP_FS_OPS); +} + /* * shrink_page_list() returns the number of reclaimed pages */ @@ -1514,8 +1529,7 @@ static unsigned int shrink_page_list(struct list_head *page_list, if (!sc->may_unmap && page_mapped(page)) goto keep_locked; - may_enter_fs = (sc->gfp_mask & __GFP_FS) || - (PageSwapCache(page) && (sc->gfp_mask & __GFP_IO)); + may_enter_fs = test_may_enter_fs(page, sc->gfp_mask); /* * The number of dirty pages determines if a node is marked @@ -1683,7 +1697,8 @@ static unsigned int shrink_page_list(struct list_head *page_list, goto activate_locked_split; } - may_enter_fs = true; + may_enter_fs = test_may_enter_fs(page, + sc->gfp_mask); /* Adding to swap updated mapping */ mapping = page_mapping(page);