[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YaVeafjbutiVXavv@arm.com>
Date: Mon, 29 Nov 2021 23:12:41 +0000
From: Catalin Marinas <catalin.marinas@....com>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Andreas Gruenbacher <agruenba@...hat.com>,
Matthew Wilcox <willy@...radead.org>,
Josef Bacik <josef@...icpanda.com>,
David Sterba <dsterba@...e.com>,
Al Viro <viro@...iv.linux.org.uk>,
Andrew Morton <akpm@...ux-foundation.org>,
Will Deacon <will@...nel.org>,
linux-fsdevel <linux-fsdevel@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>,
Linux ARM <linux-arm-kernel@...ts.infradead.org>,
linux-btrfs <linux-btrfs@...r.kernel.org>
Subject: Re: [PATCH 3/3] btrfs: Avoid live-lock in search_ioctl() on hardware
with sub-page faults
On Mon, Nov 29, 2021 at 01:53:01PM -0800, Linus Torvalds wrote:
> On Mon, Nov 29, 2021 at 12:56 PM Catalin Marinas
> <catalin.marinas@....com> wrote:
> > I think that would be useful, though it doesn't solve the potential
> > livelock with sub-page faults.
>
> I was assuming we'd just do the sub-page faults.
>
> In fact, I was assuming we'd basically just replace all the PAGE_ALIGN
> and PAGE_SIZE with SUBPAGE_{ALIGN,SIZE}, together with something like
>
> if (size > PAGE_SIZE)
> size = PAGE_SIZE;
>
> to limit that size thing (or possibly make that "min size" be a
> parameter, so that people who have things like that "I need at least
> this initial structure to be copied" issue can document their minimum
> size needs).
Ah, so fault_in_writeable() would never fault in the whole range (if too
large). When copy_to_user() goes beyond the faulted in range, it may
fail and we go back to fault in a bit more of the range. A copy loop
would be equivalent to:
fault_addr = ubuf;
end = ubuf + size;
while (1) {
if (fault_in_writeable(fault_addr,
min(PAGE_SIZE, end - fault_addr)))
break;
left = copy_to_user(ubuf, kbuf, size);
if (!left)
break;
fault_addr = end - left;
}
That should work. I'll think about it tomorrow, getting late over here.
(I may still keep the sub-page probing in the arch code, see my earlier
exchanges with Andreas)
--
Catalin
Powered by blists - more mailing lists