Re: [PATCHv6 13/37] mm: make write_cache_pages() work on huge pages

Matthew Wilcox
2017-02-10T17:46:10Z

On Thu, Jan 26, 2017 at 02:57:55PM +0300, Kirill A. Shutemov wrote:
> We writeback whole huge page a time. Let's adjust iteration this way.
>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>

I think a lot of the complexity in this patch is from pagevec_lookup_tag
giving you subpages rather than head pages...

> @@ -2268,7 +2273,8 @@ int write_cache_pages(struct address_space *mapping,
> * not be suitable for data integrity
> * writeout).
> */
> - done_index = page->index + 1;
> + done_index = compound_head(page)->index
> + + hpage_nr_pages(page);
> done = 1;
> break;
> }

you'd still need this line, but it'd only be:

done_index = page->index +
(1 << compound_order(page));

I think we want:

#define nr_pages(page) (1 << compound_order(page))

because we seem to be repeating that idiom quite a lot in these patches.

done_index = page->index +
nr_pages(page);

Still doesn't quite fit on one line, but it's closer, and it's the
ridiculous indentation in that function that's the real problem.