[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <B74255A8-0103-4888-830B-0ADC60947E8E@nvidia.com>
Date: Wed, 31 Mar 2021 13:00:08 -0400
From: "Zi Yan" <ziy@...dia.com>
To: "Matthew Wilcox" <willy@...radead.org>
Cc: "Andrew Morton" <akpm@...ux-foundation.org>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org,
"Kirill A . Shutemov" <kirill.shutemov@...ux.intel.com>,
"Shuah Khan" <shuah@...nel.org>,
"John Hubbard" <jhubbard@...dia.com>,
"Sandipan Das" <sandipan@...ux.ibm.com>,
"David Hildenbrand" <david@...hat.com>,
"Yang Shi" <shy828301@...il.com>,
"Mika Penttila" <mika.penttila@...tfour.com>,
"David Rientjes" <rientjes@...gle.com>
Subject: Re: [PATCH v7 2/2] mm: huge_memory: debugfs for file-backed THP
split.
On 31 Mar 2021, at 12:44, Matthew Wilcox wrote:
> On Mon, Mar 29, 2021 at 11:39:32AM -0400, Zi Yan wrote:
>> + for (off_cur = off_start; off_cur < off_end;) {
>> + struct page *fpage = pagecache_get_page(mapping, off_cur,
>> + FGP_ENTRY | FGP_HEAD, 0);
>> +
>> + if (xa_is_value(fpage) || !fpage) {
>> + off_cur += PAGE_SIZE;
>> + continue;
>> + }
>> +
>> + if (!is_transparent_hugepage(fpage)) {
>> + off_cur += PAGE_SIZE;
>> + goto next;
>> + }
>> + total++;
>> + off_cur = fpage->index + thp_size(fpage);
>
> That can't be right. fpage->index is in units of pages and thp_size is
> in units of bytes. I wish C had a better type system.
> I think you meant:
>
> off_cur = fpage->index + thp_nr_pages(fpage);
>
> Also, I think this loop would read better as ...
>
> for (index = off_start; index < off_end; index += nr_pages) {
> struct page *fpage = pagecache_get_page(mapping, index,
> FGP_ENTRY | FGP_HEAD, 0);
> nr_pages = 1;
> if (xa_is_value(fpage) || !fpage)
> continue;
> if (!is_transparent_hugepage(fpage))
> goto next;
> total++;
> nr_pages = thp_nr_pages(fpage);
> ...
Thanks for catching this! I mixed this with looping through VMA, which
is in units of bytes. I will fix this and use your suggested loop code.
—
Best Regards,
Yan Zi
Download attachment "signature.asc" of type "application/pgp-signature" (855 bytes)
Powered by blists - more mailing lists