lkml.org 
[lkml]   [2023]   [Dec]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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@infradead.org>
>
> Instead of keeping our own local iterator variable, use the one just
> added to folio_batch.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Nice. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.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@suse.com>
SUSE Labs, CR

\
 
 \ /
  Last update: 2023-12-21 12:29    [W:0.171 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site