Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4410655pxb; Thu, 14 Oct 2021 04:47:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxySRyy/Io5qSZKl4qNfXwGPT5ZBJF4x2mJrlG+EB1lAK6kqY+M9GJooHfUHh0e7RzLjQiG X-Received: by 2002:a63:3705:: with SMTP id e5mr3914520pga.307.1634212039318; Thu, 14 Oct 2021 04:47:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634212039; cv=none; d=google.com; s=arc-20160816; b=Qg96lLPMLSlYWUdIPtZEhqgV4mqHsWxfXcHAKlBb9gLtnm2UYXD3FSDYJYNMctVF/k MjdhXVOLkbI1L3JfWsR0qsRjsa44Kmy8+DBfwqN0zGlb+Z/tRf67bkbWtVTZWK9FC+C7 w62zx7CV+BY2FjXhDA60hk8zSCic5yNtDTLkLT4L1ZFn8D7nHVKChhH/sZJqRD+PwQQn P9Y8GdaqA884kThHshHwPhWZjSwxSa0N/flxxHaFMaQ51vpU5CBanxd4QjjtotfQiuNk uFFZ8RXH14g3A59dkxElse0HFZzRFTT30y5cEjoELkmVkb1mScsqvChrDmwGnU7psINQ qPAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=wyaP3FH3PLclKjDKzeDI/4MiW25bGyBys//UvUZ3Dtc=; b=JNSqWjmJt/+jNDiZwvwkW6OEA9hKD1IEpH1APujYcGzmcP0kcL5hHclO8lCC9jtE31 5ui+Ur840GDjGn8tIAKM10hQntBa/oz1/8Ml5GfgcjbmraqmMG1DPrd8E0U4koECz7wH SbOgJg0NgIKrcFPr5y3yAwdPd6Mov3re5flJjOHXtcJxZcAHFadN9BxXfmL4LFnEEvXM hGztlLR80uenC9jF0qTx123+62NW/t8Yrp/qSwMRz5X4yr5o9c8uVsYvoUa4DQS0ecwM Co4qX/qfjOSpR6niSEUjzs6lXd+8yecXp43e1OHDGzV7y+tsfTKPSa3qkGJ05xzlj7gM IibA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=oGF2SOMb; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o19si4771812pgu.606.2021.10.14.04.46.56; Thu, 14 Oct 2021 04:47:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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.com header.s=susede1 header.b=oGF2SOMb; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231220AbhJNLs4 (ORCPT + 99 others); Thu, 14 Oct 2021 07:48:56 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:57600 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231195AbhJNLs4 (ORCPT ); Thu, 14 Oct 2021 07:48:56 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id C454721A74; Thu, 14 Oct 2021 11:46:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1634212009; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=wyaP3FH3PLclKjDKzeDI/4MiW25bGyBys//UvUZ3Dtc=; b=oGF2SOMb+pNZDg14b6Db7pdF4DQSHbGw0lc7CMPv+bf+1B3mR4Wc+QoF8G3bESLpiicgq3 1oCC9VPDJ+OIF1PQO01uxozfS+WjRUmcVwp3ibJ9PrbIafhtupqhCv9IGsA+Y6IxQSHcd3 zJkxyTtr2HEu6eddciChxUNXtRP69tQ= Received: from suse.cz (unknown [10.100.201.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 95BE2A3B83; Thu, 14 Oct 2021 11:46:49 +0000 (UTC) Date: Thu, 14 Oct 2021 13:46:48 +0200 From: Michal Hocko To: David Sterba Cc: Dave Chinner , NeilBrown , Vlastimil Babka , Andrew Morton , Theodore Ts'o , Andreas Dilger , "Darrick J. Wong" , Matthew Wilcox , Mel Gorman , Jonathan Corbet , linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Subject: Re: [PATCH 2/6] MM: improve documentation for __GFP_NOFAIL Message-ID: References: <20211006231452.GF54211@dread.disaster.area> <163364854551.31063.4377741712039731672@noble.neil.brown.name> <20211008223649.GJ54211@dread.disaster.area> <20211013023231.GV2361455@dread.disaster.area> <20211014113201.GA19582@twin.jikos.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211014113201.GA19582@twin.jikos.cz> Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Thu 14-10-21 13:32:01, David Sterba wrote: > On Wed, Oct 13, 2021 at 10:26:58AM +0200, Michal Hocko wrote: > > > crap like this (found in btrfs): > > > > > > /* > > > * We're holding a transaction handle, so use a NOFS memory > > > * allocation context to avoid deadlock if reclaim happens. > > > */ > > > nofs_flag = memalloc_nofs_save(); > > > value = kmalloc(size, GFP_KERNEL); > > > memalloc_nofs_restore(nofs_flag); > > > > Yes this looks wrong indeed! If I were to review such a code I would ask > > why the scope cannot match the transaction handle context. IIRC jbd does > > that. > > Adding the transaction start/end as the NOFS scope is a long term plan > and going on for years, because it's not a change we would need in > btrfs, but rather a favor to MM to switch away from "GFP_NOFS everywhere > because it's easy". > > The first step was to convert the easy cases. Almost all safe cases > switching GFP_NOFS to GFP_KERNEL have happened. Another step is to > convert GFP_NOFS to memalloc_nofs_save/GFP_KERNEL/memalloc_nofs_restore > in contexts where we know we'd rely on the transaction NOFS scope in the > future. Once this is implemented, the memalloc_nofs_* calls are deleted > and it works as expected. Now you may argue that the switch could be > changing GFP_NOFS to GFP_KERNEL at that time but that is not that easy > to review or reason about in the whole transaction context in all > allocations. > > This leads to code that was found in __btrfs_set_acl and called crap > or wrong, because perhaps the background and the bigger plan is not > immediately obvious. I hope the explanation above it puts it to the > right perspective. Yes it helps. Thanks for the clarification because this is far from obvious and changelogs I've checked do not mention this high level plan. I would have gone with a /* TODO: remove me once transactions use scopes... */ but this is obviously your call. > > The other class of scoped NOFS protection is around vmalloc-based > allocations but that's for a different reason, would be solved by the > same transaction start/end conversion as well. > > I'm working on that from time to time but this usually gets pushed down > in the todo list. It's changing a lot of code, from what I've researched > so far cannot be done at once and would probably introduce bugs hard to > hit because of the external conditions (allocator, system load, ...). > > I have a plan to do that incrementally, adding assertions and converting > functions in small batches to be able to catch bugs early, but I'm not > exactly thrilled to start such endeavour in addition to normal > development bug hunting. > > To get things moving again, I've refreshed the patch adding stubs and > will try to find the best timing for merg to avoid patch conflicts, but > no promises. Thanks! -- Michal Hocko SUSE Labs