[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YNTIr/UGVrTOZD3f@casper.infradead.org>
Date: Thu, 24 Jun 2021 19:02:23 +0100
From: Matthew Wilcox <willy@...radead.org>
To: Christoph Hellwig <hch@...radead.org>
Cc: akpm@...ux-foundation.org, linux-fsdevel@...r.kernel.org,
linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 20/46] mm/migrate: Add folio_migrate_copy()
On Wed, Jun 23, 2021 at 10:35:00AM +0200, Christoph Hellwig wrote:
> > +void folio_migrate_copy(struct folio *newfolio, struct folio *folio)
> > {
> > + unsigned int i = folio_nr_pages(folio) - 1;
> >
> > + copy_highpage(folio_page(newfolio, i), folio_page(folio, i));
> > + while (i-- > 0) {
> > + cond_resched()a
> > + /* folio_page() handles discontinuities in memmap */
> > + copy_highpage(folio_page(newfolio, i), folio_page(folio, i));
> > + }
> > +
>
> What is the advantage of copying backwards here to start with?
Easier to write the loop this way? I suppose we could do it as ...
unsigned int i, nr = folio_nr_pages(folio);
for (i = 0; i < nr; i++) {
/* folio_page() handles discontinuities in memmap */
copy_highpage(folio_page(newfolio, i), folio_page(folio, i));
cond_resched();
}
I'm not really bothered. As long as we don't call folio_nr_pages() for
each iteration of the loop ... I've actually been wondering about
marking that as __pure, but I don't quite have the nerve to do it yet.
Powered by blists - more mailing lists