linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Zi Yan <ziy@nvidia.com>
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 17:44:38 +0100	[thread overview]
Message-ID: <20210331164438.GY351017@casper.infradead.org> (raw)
In-Reply-To: <20210329153932.134510-2-zi.yan@sent.com>

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);
...



  reply	other threads:[~2021-03-31 16:45 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 [this message]
2021-03-31 17:00     ` Zi Yan

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=20210331164438.GY351017@casper.infradead.org \
    --to=willy@infradead.org \
    --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=ziy@nvidia.com \
    /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