From mboxrd@z Thu Jan 1 00:00:00 1970 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 D29BDC021A4 for ; Mon, 24 Feb 2025 15:49:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 68DBE6B007B; Mon, 24 Feb 2025 10:49:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 63C7E6B0082; Mon, 24 Feb 2025 10:49:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 505006B0083; Mon, 24 Feb 2025 10:49:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 3279A6B007B for ; Mon, 24 Feb 2025 10:49:31 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B233916186C for ; Mon, 24 Feb 2025 15:49:30 +0000 (UTC) X-FDA: 83155272900.22.6AF43EC Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf24.hostedemail.com (Postfix) with ESMTP id BD174180005 for ; Mon, 24 Feb 2025 15:49:28 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=TZefOmSR; dmarc=none; spf=none (imf24.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1740412169; a=rsa-sha256; cv=none; b=GnrJe7zA2zcF+9sJISANFfuGNvqrQSQiWZroBYfX7YCp7MLCBoC5s9rzXZpNLOjY4/LYoM 9rl2j6awo1MXV70QO21W6VtqYGAKvE9fNTk+wV8Pe8gDo5chbND/7nhoR/3t2edeG/n+Fw wLN2sREpcFlAinOI1YbFAE8V+wHi6G4= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=TZefOmSR; dmarc=none; spf=none (imf24.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1740412169; h=from:from:sender:reply-to:subject:subject: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:dkim-signature; bh=YErfRUqRg108yTH5RXZzWhvly/jQo5kC4YXPq+9ZtKA=; b=mMpOkWr1fuF1ccfoMGSqqvaJXPOYnoNAYlZ0yk+ytSVYhYNfkQ2tC5jHa0e3j0Ju8O5n0L 09YESsldEP7SduJtcnS+P4TRRH9w82RP8TDMgakd2MBqWvXIbOOPELG+WrwDYBbzeQrMO1 ne9p2NNlCWQEMcEUjh8xqBbUzxD70EA= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=YErfRUqRg108yTH5RXZzWhvly/jQo5kC4YXPq+9ZtKA=; b=TZefOmSRKXmue8yFnsBIq67Vzj Mdjvtl7tQycOyZFeRWtWhHbHO704f8fmdWuxrCyqNBIcvrYWK7dnq3AmArLPc4SneUxIAkUp2Yuxe ZpXX7X5dN/OB1OcQZWWb7+OWrrIbIyUOuc9CWSc1YLTMQVDZTnhZikNk5rg4JSJNlYkfAhTrbYNag L2H32yLitZPgUyJsPa5Uyf2J6+RPFHNVM4UVhiHGCORUWGTSa0sVcVJ3u96ESVxz9Iwt1VC0+djFe yCc3mg3Dww13/GtUIKZblhwwmeKUbTmTk8XYlKejibAd/p72Hkqn1EuWbCgHLZvNKSJwx5WOdzInb gl7GIKzw==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tmahz-00000007gGA-1xkE; Mon, 24 Feb 2025 15:49:27 +0000 Date: Mon, 24 Feb 2025 15:49:27 +0000 From: Matthew Wilcox To: "Raphael S. Carvalho" Cc: Christoph Hellwig , linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, djwong@kernel.org, Dave Chinner Subject: Re: [PATCH v2] mm: Fix error handling in __filemap_get_folio() with FGP_NOWAIT Message-ID: References: <20250224081328.18090-1-raphaelsc@scylladb.com> <20250224141744.GA1088@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: BD174180005 X-Stat-Signature: m73m8qk3hfh74qom4ecckmi3fr1f9a6r X-Rspam-User: X-HE-Tag: 1740412168-238389 X-HE-Meta: U2FsdGVkX19GSrq4V9Sb3qz1IzlDPdXoxxYj7WfbP5K+ByTOT0CPib61aRRMf+H2MF3nln4UWzfZ98hBaj4F6c/JgyKJfJ03Ee0wNW6N5IJiCoFKYrQW1KOJsCNVSadPZ0n9AgLaZqpE9/A84mGLfnU2ImqLIT2qxt7sijE4v01q1N+NL1REOnIHwhusguBD/HYlj5jBD9wGxJEFhVrO4PMA5mMPel88oslUioVvfyuOrBVU6820ulTP+GOi0IjAATzNKtK/5PREoK0/NGH4SBtqw0CiQRdrNWQnfwFfrZMgNdnhfGT4cnaEEiLIlXJzHtT8Qt3ACmKipOjDwhIIdNd8EJmiL63Rmg0wSc2/lnkzWG2Gzhr14wy6IWlAazp35fMApC3zcwFZyvPEQw5jeygBVnp6C66eoOnlOENTMCevCM7As15hp/QsFBYmQbFQWl8xSUT264NwoTvGZWkUFWSX6CnTonclwBR+KViTPL+6BbE5Mdr18uesh/SFM7PeBX+VH8KXL/v+hGOKdHZY1XjuAacKbqtkH+zU+3rTkMv91KtDIGixniBZjdu1sDdUoydVNaGdpcnWgKukjPlwWGsij9b/58pAMqqGvIURmluZ/CScJ05GdE9X/ZQBZNLEoDC2JRVtZT56zEyYWaYrKtCqjN/WGR8GbB4Fn0PIJx9Hsv1zwfLxzgVr8i86qUiw58Qh7KOwvEDVjIV08nF/oY6YySCQ4fP6+wLdy1ZaYqe3z3fzFnosH4YaDgCKb0LZSw5LI+PhvLJFCKnqTFt25ARuH/CLWw9kNqcTzo6BL8i3sgA+QJ0p4DPny9QpkCPe9osa6LoDr4PHZumC5Bf9BNUUW8GIQDvCixBSSSFS8ZIH3FKmIf7ye0oCMYHP1PKA4YZBel7rD1wFBLKzGm7j+qHrI+vxbiF0udCLquoffRXgx2srlqtxHOrim4/p7hPjR55j+f5AAdv3IYLdBqH VotvLP8+ bjq9QOkX4HebYekRG6V23bJv0ukE6TltbNsAnGSI1REisO7ykiHeAOmVTAo4DES4PIAbCSq5A7QDA0WZwPb8SH4cv1C/lOOjpj8bnHGQWkWk7HthdzLSxA6iShYukdbYn2vHfVTEA36XcNM+VYVImG4PlJnHGqpqQZatYYJOUqiA/DV8VtYuzkQQiXevJ46XoNAeQlpLCGW+LQmXS52UDZ3FH00k7cjj/CEorEevV0jwCWGhq1ya3LRiA4pHRz3tPf6zg+nc3y3f/4IkPxjyISLiyR4sxwvco+DzVC1SE68dOtP3j0kYOrBO78RvwvEjq7d6seFhvE0tZfn4S+uKHYf/xaihMp5kRgQeQaugY8BUS7hQ= 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: List-Subscribe: List-Unsubscribe: On Mon, Feb 24, 2025 at 12:45:21PM -0300, Raphael S. Carvalho wrote: > On Mon, Feb 24, 2025 at 12:33 PM Matthew Wilcox wrote: > > > > On Mon, Feb 24, 2025 at 03:17:44PM +0100, Christoph Hellwig wrote: > > > On Mon, Feb 24, 2025 at 05:13:28AM -0300, Raphael S. Carvalho wrote: > > > > + if (err) { > > > > + /* Prevents -ENOMEM from escaping to user space with FGP_NOWAIT */ > > > > + if ((fgp_flags & FGP_NOWAIT) && err == -ENOMEM) > > > > + err = -EAGAIN; > > > > return ERR_PTR(err); > > > > > > I don't think the comment is all that useful. It's also overly long. > > > > > > I'd suggest this instead: > > > > > > /* > > > * When NOWAIT I/O fails to allocate folios this could > > > * be due to a nonblocking memory allocation and not > > > * because the system actually is out of memory. > > > * Return -EAGAIN so that there caller retries in a > > > * blocking fashion instead of propagating -ENOMEM > > > * to the application. > > > */ > > > > I don't think it needs a comment at all, but the memory allocation > > might be for something other than folios, so your suggested comment > > is misleading. > > Isn't it all in the context of allocating or adding folio? The reason > behind a comment is to prevent movements in the future that could > cause a similar regression, and also to inform the poor reader that > might be left wondering why we're converting -ENOMEM into -EAGAIN with > FGP_NOWAIT. Can it be slightly adjusted to make it more correct? Or > you really think it's better to remove it completely? I really don't think the comment is needed. This is a common mistake when fixing a bug.