linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Zi Yan" <ziy@nvidia.com>
To: "Matthew Wilcox" <willy@infradead.org>
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org,
	"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
	"Shuah Khan" <shuah@kernel.org>,
	"John Hubbard" <jhubbard@nvidia.com>,
	"Sandipan Das" <sandipan@linux.ibm.com>,
	"David Hildenbrand" <david@redhat.com>,
	"Yang Shi" <shy828301@gmail.com>,
	"Mika Penttila" <mika.penttila@nextfour.com>,
	"David Rientjes" <rientjes@google.com>
Subject: Re: [PATCH v7 2/2] mm: huge_memory: debugfs for file-backed THP split.
Date: Wed, 31 Mar 2021 13:00:08 -0400	[thread overview]
Message-ID: <B74255A8-0103-4888-830B-0ADC60947E8E@nvidia.com> (raw)
In-Reply-To: <20210331164438.GY351017@casper.infradead.org>

[-- Attachment #1: Type: text/plain, Size: 1347 bytes --]

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

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 854 bytes --]

      reply	other threads:[~2021-03-31 17:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-29 15:39 [PATCH v7 1/2] mm: huge_memory: a new debugfs interface for splitting THP tests Zi Yan
2021-03-29 15:39 ` [PATCH v7 2/2] mm: huge_memory: debugfs for file-backed THP split Zi Yan
2021-03-31 16:44   ` Matthew Wilcox
2021-03-31 17:00     ` Zi Yan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=B74255A8-0103-4888-830B-0ADC60947E8E@nvidia.com \
    --to=ziy@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=jhubbard@nvidia.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mika.penttila@nextfour.com \
    --cc=rientjes@google.com \
    --cc=sandipan@linux.ibm.com \
    --cc=shuah@kernel.org \
    --cc=shy828301@gmail.com \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox