From patchwork Tue Nov 16 02:44:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 12621133 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B3A4C433F5 for ; Tue, 16 Nov 2021 02:45:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9EBD561C4F for ; Tue, 16 Nov 2021 02:45:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9EBD561C4F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 2F5D26B00AE; Mon, 15 Nov 2021 21:45:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2A5866B00B0; Mon, 15 Nov 2021 21:45:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 16D656B00B1; Mon, 15 Nov 2021 21:45:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0215.hostedemail.com [216.40.44.215]) by kanga.kvack.org (Postfix) with ESMTP id 057786B00AE for ; Mon, 15 Nov 2021 21:45:55 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id A462A84CEC for ; Tue, 16 Nov 2021 02:45:54 +0000 (UTC) X-FDA: 78813253428.20.AFD03FE Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf01.hostedemail.com (Postfix) with ESMTP id 844115092A30 for ; Tue, 16 Nov 2021 02:45:37 +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 DCE7C1FD67; Tue, 16 Nov 2021 02:45:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1637030752; 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=SCPnWzrli9uhGf5cSQnA2kslw6w9vTsO2ZaI10TRMW0=; b=pZE6Mn45OybuBUV0fFOy6OA0abrIA0AR+Fglj1GmFirEaWFtVDkCDYxp+ocPMp60lDJ7N2 TaWmdEQKPcqYIl2pmPRYlaKiDIw7u0icJyyQk2e/fKk1Mzsv1R0v4/yvnKIgkZCWcNlf83 VqbAdkFTRkcWYEkojriQxOzGfTp73+4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1637030752; 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=SCPnWzrli9uhGf5cSQnA2kslw6w9vTsO2ZaI10TRMW0=; b=8qHcqlPn9r3KPsRJ2cy06JSUnxN3MrXeqxOuPnS8oTruMA9u3t2SC7iQhU5U1gJPcf5I7b 3IWDw2sfjb9aJ/Cg== 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 84C4713B70; Tue, 16 Nov 2021 02:45:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id AYUoLF0bk2HZCAAAMHmgww (envelope-from ); Tue, 16 Nov 2021 02:45:49 +0000 Subject: [PATCH 03/13] MM: reclaim mustn't enter FS for swap-over-NFS From: NeilBrown To: Trond Myklebust , Anna Schumaker , Chuck Lever , Andrew Morton , Mel Gorman Cc: linux-nfs@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Tue, 16 Nov 2021 13:44:04 +1100 Message-ID: <163703064452.25805.16932817889703270242.stgit@noble.brown> In-Reply-To: <163702956672.25805.16457749992977493579.stgit@noble.brown> References: <163702956672.25805.16457749992977493579.stgit@noble.brown> User-Agent: StGit/0.23 MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 844115092A30 X-Stat-Signature: ism39bbf1r8dokjhw6bumnnbrwkowtkf Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=pZE6Mn45; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=8qHcqlPn; spf=pass (imf01.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: 1637030737-218139 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 Signed-off-by: NeilBrown Reported-by: kernel test robot --- mm/vmscan.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index fb9584641ac7..049ff4494081 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1513,8 +1513,14 @@ static unsigned int shrink_page_list(struct list_head *page_list, if (!sc->may_unmap && page_mapped(page)) goto keep_locked; + /* ->flags can be updated non-atomicially (scan_swap_map_slots), + * but that will never affect SWP_FS_OPS, so the data_race + * is safe. + */ may_enter_fs = (sc->gfp_mask & __GFP_FS) || - (PageSwapCache(page) && (sc->gfp_mask & __GFP_IO)); + (PageSwapCache(page) && + !data_race(page_swap_info(page)->flags & SWP_FS_OPS) && + (sc->gfp_mask & __GFP_IO)); /* * The number of dirty pages determines if a node is marked @@ -1682,7 +1688,9 @@ static unsigned int shrink_page_list(struct list_head *page_list, goto activate_locked_split; } - may_enter_fs = true; + if ((sc->gfp_mask & __GFP_FS) || + !data_race(page_swap_info(page)->flags & SWP_FS_OPS)) + may_enter_fs = true; /* Adding to swap updated mapping */ mapping = page_mapping(page);