[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231221112812.fkjumae6xexnw2lk@quack3>
Date: Thu, 21 Dec 2023 12:28:12 +0100
From: Jan Kara <jack@...e.cz>
To: Christoph Hellwig <hch@....de>
Cc: linux-mm@...ck.org, "Matthew Wilcox (Oracle)" <willy@...radead.org>,
Jan Kara <jack@...e.com>, David Howells <dhowells@...hat.com>,
Brian Foster <bfoster@...hat.com>, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 11/17] writeback: Use the folio_batch queue iterator
On Mon 18-12-23 16:35:47, Christoph Hellwig wrote:
> From: "Matthew Wilcox (Oracle)" <willy@...radead.org>
>
> Instead of keeping our own local iterator variable, use the one just
> added to folio_batch.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@...radead.org>
> Signed-off-by: Christoph Hellwig <hch@....de>
Nice. Feel free to add:
Reviewed-by: Jan Kara <jack@...e.cz>
Honza
> ---
> mm/page-writeback.c | 19 +++++++++----------
> 1 file changed, 9 insertions(+), 10 deletions(-)
>
> diff --git a/mm/page-writeback.c b/mm/page-writeback.c
> index c7983ea3040be4..70f42fd9a95b5d 100644
> --- a/mm/page-writeback.c
> +++ b/mm/page-writeback.c
> @@ -2397,13 +2397,19 @@ static pgoff_t wbc_end(struct writeback_control *wbc)
> return wbc->range_end >> PAGE_SHIFT;
> }
>
> -static void writeback_get_batch(struct address_space *mapping,
> +static struct folio *writeback_get_next(struct address_space *mapping,
> struct writeback_control *wbc)
> {
> + struct folio *folio = folio_batch_next(&wbc->fbatch);
> +
> + if (folio)
> + return folio;
> +
> folio_batch_release(&wbc->fbatch);
> cond_resched();
> filemap_get_folios_tag(mapping, &wbc->index, wbc_end(wbc),
> wbc_to_tag(wbc), &wbc->fbatch);
> + return folio_batch_next(&wbc->fbatch);
> }
>
> static bool should_writeback_folio(struct address_space *mapping,
> @@ -2473,7 +2479,6 @@ int write_cache_pages(struct address_space *mapping,
> {
> int error;
> pgoff_t end; /* Inclusive */
> - int i = 0;
>
> if (wbc->range_cyclic) {
> wbc->index = mapping->writeback_index; /* prev offset */
> @@ -2489,18 +2494,12 @@ int write_cache_pages(struct address_space *mapping,
> wbc->err = 0;
>
> for (;;) {
> - struct folio *folio;
> + struct folio *folio = writeback_get_next(mapping, wbc);
> unsigned long nr;
>
> - if (i == wbc->fbatch.nr) {
> - writeback_get_batch(mapping, wbc);
> - i = 0;
> - }
> - if (wbc->fbatch.nr == 0)
> + if (!folio)
> break;
>
> - folio = wbc->fbatch.folios[i++];
> -
> folio_lock(folio);
> if (!should_writeback_folio(mapping, wbc, folio)) {
> folio_unlock(folio);
> --
> 2.39.2
>
--
Jan Kara <jack@...e.com>
SUSE Labs, CR
Powered by blists - more mailing lists