[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHk-=wiF7jkOrpCe8=s+s=xxw8NovYWfNpe+kVHZth4m0mV5XQ@mail.gmail.com>
Date: Tue, 3 Aug 2021 12:43:11 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Andreas Gruenbacher <agruenba@...hat.com>
Cc: Alexander Viro <viro@...iv.linux.org.uk>,
Christoph Hellwig <hch@...radead.org>,
"Darrick J. Wong" <djwong@...nel.org>, Jan Kara <jack@...e.cz>,
Matthew Wilcox <willy@...radead.org>,
cluster-devel <cluster-devel@...hat.com>,
linux-fsdevel <linux-fsdevel@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
ocfs2-devel@....oracle.com
Subject: Re: [PATCH v5 03/12] Turn fault_in_pages_{readable,writeable} into fault_in_{readable,writeable}
On Tue, Aug 3, 2021 at 12:18 PM Andreas Gruenbacher <agruenba@...hat.com> wrote:
>
> Turn fault_in_pages_{readable,writeable} into versions that return the number
> of bytes faulted in instead of returning a non-zero value when any of the
> requested pages couldn't be faulted in.
Ugh. This ends up making most users have horribly nasty conditionals.
I think I suggested (or maybe that was just my internal voice and I
never actually vocalized it) using the same semantics as
"copy_to/from_user()" for fault_in_pages_{readable|writable}().
Namely to return the number of bytes *not* faulted in.
That makes it trivial to test "did I get everything" - becasue zero
means "nothing failed" and remains the "complete success" marker.
And it still allows for the (much less common) case of "ok, I need to
know about partial failures".
So instead of this horror:
- if (!fault_in_pages_writeable(buf_fx, fpu_user_xstate_size))
+ if (fault_in_writeable(buf_fx, fpu_user_xstate_size) ==
+ fpu_user_xstate_size)
you'd just have
- if (!fault_in_pages_writeable(buf_fx, fpu_user_xstate_size))
+ if (!fault_in_writeable(buf_fx, fpu_user_xstate_size))
because zero would continue to be a marker of success.
Linus
Powered by blists - more mailing lists