Re: [LSF/MM/BPF TOPIC] Measuring limits and enhancing buffered IO

Matthew Wilcox
2024-02-28T04:22:47Z

On Wed, Feb 28, 2024 at 03:00:36AM +0000, Matthew Wilcox wrote:
> On Tue, Feb 27, 2024 at 09:22:26PM -0500, Kent Overstreet wrote:
> > Which does raise the question of if we've ever attempted to define a
> > lock ordering on folios. I suspect not, since folio lock doesn't even
> > seem to have lockdep support.
>
> We even wrote it down!
>
> /*
> * To avoid deadlocks between range_cyclic writeback and callers
> * that hold pages in PageWriteback to aggregate I/O until
> * the writeback iteration finishes, we do not loop back to the
> * start of the file. Doing so causes a page lock/page
> * writeback access order inversion - we should only ever lock
> * multiple pages in ascending page->index order, and looping
> * back to the start of the file violates that rule and causes
> * deadlocks.
> */
>
> (I'll take the AR to put this somewhere better like in the folio_lock()
> kernel-doc)

Um. I already did.

* Context: May sleep. If you need to acquire the locks of two or
* more folios, they must be in order of ascending index, if they are
* in the same address_space. If they are in different address_spaces,
* acquire the lock of the folio which belongs to the address_space which
* has the lowest address in memory first.

Where should I have put this information that you would have found it,
if not in the kernel-doc for folio_lock()?