Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp956504ybt; Fri, 26 Jun 2020 16:12:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBZiiM4zhhbtdjgtzxsRrQRN8peIBpkI6EFMSTqbadYvS1CTgRXROEj0FQrfzs+xWomX9C X-Received: by 2002:aa7:d457:: with SMTP id q23mr3578517edr.376.1593213151313; Fri, 26 Jun 2020 16:12:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593213151; cv=none; d=google.com; s=arc-20160816; b=Jxj2ANdFo3Wmd0TSGAp/5dNBwldeHNQlX9qlR2MxfqACxDNv8RtmkAscbc0DDqOOZy jhzHohw7DCnDkEE3OWJk7hRqxcE6OYy/QuqWlhNGvm97P+Na2ArBQZKkzC43OKmNHd1e LZMW5QjDTFHIJLAWexuH4ypXS0S20Yw0VOThQC+JDmyAhI5RGurt6MYIhb+e3tNW7D27 vsSiJJKo82EQq8P80uPsAHbE72IMl4lAsifqEvHhywBU1UslxFVCR0jZwW15Zf6dKgFt 8BjIvmx5COCseSRk5BTtuQ0bF7E1LzLuEz27vP9xUXYGPwQ6NWbiMJHYcVPB7Pxtxzbq x3QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=WJPhn14oeUwgEwjXIMSvvKmwuwXCuQ1aVoWIHvFvJwM=; b=HtQxPZAVGNvpApczM8DJ09O6lY7fBUzfKB79fzW+bZreOs6w06EfT9uLI4MFh2k9WF cOKl8ddqGTTMAsIqj+5GisSCnIn+Wx+525NVdnBxraNuJ2u9pBcIZNDyqVLOOfP9kWb/ qqO5OJ4sGosaS82qwdDGAK4ck1nqB/7S3OiNHrPAB6salSj6d7FsBFJ+Y3zumdf1jcdv YYHEGFzpEty78eNQM5L4ywqD3zzBLTTdzG9cHD7CDXSJUCkW/GEWFgYHOR9Zw7SGOMWe lP0jQOBb3S+r1O2sQB+t+WalREmxrH+7pFOO1MzR3hNSVNDD+Lm81FD3cdl06Bt14bzN hAtg== ARC-Authentication-Results: i=1; mx.google.com; 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 b12si3863019ejp.213.2020.06.26.16.12.06; Fri, 26 Jun 2020 16:12:31 -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; 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 S1726415AbgFZXI6 (ORCPT + 99 others); Fri, 26 Jun 2020 19:08:58 -0400 Received: from mail108.syd.optusnet.com.au ([211.29.132.59]:58755 "EHLO mail108.syd.optusnet.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725883AbgFZXI6 (ORCPT ); Fri, 26 Jun 2020 19:08:58 -0400 Received: from dread.disaster.area (pa49-180-53-24.pa.nsw.optusnet.com.au [49.180.53.24]) by mail108.syd.optusnet.com.au (Postfix) with ESMTPS id E630E1A8BB7; Sat, 27 Jun 2020 09:08:54 +1000 (AEST) Received: from dave by dread.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1joxSh-0001Ar-Mw; Sat, 27 Jun 2020 09:08:47 +1000 Date: Sat, 27 Jun 2020 09:08:47 +1000 From: Dave Chinner To: Mikulas Patocka Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-xfs@vger.kernel.org, dm-devel@redhat.com, Jens Axboe , NeilBrown Subject: Re: [PATCH 0/6] Overhaul memalloc_no* Message-ID: <20200626230847.GI2005@dread.disaster.area> References: <20200625113122.7540-1-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.3 cv=W5xGqiek c=1 sm=1 tr=0 a=moVtWZxmCkf3aAMJKIb/8g==:117 a=moVtWZxmCkf3aAMJKIb/8g==:17 a=kj9zAlcOel0A:10 a=nTHF0DUjJn0A:10 a=7-415B0cAAAA:8 a=FVrTFY9nI9_O9HWt5mYA:9 a=CjuIK1q_8ugA:10 a=biEYGPWJfzWAr4FL6Ov7:22 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 26, 2020 at 11:02:19AM -0400, Mikulas Patocka wrote: > Hi > > I suggest to join memalloc_noio and memalloc_nofs into just one flag that > prevents both filesystem recursion and i/o recursion. > > Note that any I/O can recurse into a filesystem via the loop device, thus > it doesn't make much sense to have a context where PF_MEMALLOC_NOFS is set > and PF_MEMALLOC_NOIO is not set. Correct me if I'm wrong, but I think that will prevent swapping from GFP_NOFS memory reclaim contexts. IOWs, this will substantially change the behaviour of the memory reclaim system under sustained GFP_NOFS memory pressure. Sustained GFP_NOFS memory pressure is quite common, so I really don't think we want to telling memory reclaim "you can't do IO at all" when all we are trying to do is prevent recursion back into the same filesystem. Given that the loop device IO path already operates under memalloc_noio context, (i.e. the recursion restriction is applied in only the context that needs is) I see no reason for making that a global reclaim limitation.... In reality, we need to be moving the other way with GFP_NOFS - to fine grained anti-recursion contexts, not more broad contexts. That is, GFP_NOFS prevents recursion into any filesystem, not just the one that we are actively operating on and needing to prevent recursion back into. We can safely have reclaim do relcaim work on other filesysetms without fear of recursion deadlocks, but the memory reclaim infrastructure does not provide that capability.(*) e.g. if memalloc_nofs_save() took a reclaim context structure that the filesystem put the superblock, the superblock's nesting depth (because layering on loop devices can create cross-filesystem recursion dependencies), and any other filesyetm private data the fs wanted to add, we could actually have reclaim only avoid reclaim from filesytsems where there is a deadlock possiblity. e.g: - superblock nesting depth is different, apply GFP_NOFS reclaim unconditionally - superblock different apply GFP_KERNEL reclaim - superblock the same, pass context to filesystem to decide if reclaim from the sueprblock is safe. At this point, we get memory reclaim able to always be able to reclaim from filesystems that are not at risk of recursion deadlocks. Direct reclaim is much more likely to be able to make progress now because it is much less restricted in what it can reclaim. That's going to make direct relcaim faster and more efficient, and taht's the ultimate goal we are aiming to acheive here... Cheers, Dave. -- Dave Chinner david@fromorbit.com