linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Xiubo Li <xiubli@redhat.com>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 3/3] mm: Clear page->private when splitting or migrating a page
Date: Mon, 20 Jun 2022 14:41:58 +0800	[thread overview]
Message-ID: <2031fee3-e09a-5cea-be26-71360893d161@redhat.com> (raw)
In-Reply-To: <20220619151143.1054746-4-willy@infradead.org>


On 6/19/22 11:11 PM, Matthew Wilcox (Oracle) wrote:
> In our efforts to remove uses of PG_private, we have found folios with
> the private flag clear and folio->private not-NULL.  That is the root
> cause behind 642d51fb0775 ("ceph: check folio PG_private bit instead
> of folio->private").  It can also affect a few other filesystems that
> haven't yet reported a problem.
>
> compaction_alloc() can return a page with uninitialised page->private,
> and rather than checking all the callers of migrate_pages(), just zero
> page->private after calling get_new_page().  Similarly, the tail pages
> from split_huge_page() may also have an uninitialised page->private.
>
> Reported-by: Xiubo Li <xiubli@redhat.com>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>   mm/huge_memory.c | 1 +
>   mm/migrate.c     | 1 +
>   2 files changed, 2 insertions(+)
>
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index f7248002dad9..9b31a50217b5 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -2377,6 +2377,7 @@ static void __split_huge_page_tail(struct page *head, int tail,
>   			page_tail);
>   	page_tail->mapping = head->mapping;
>   	page_tail->index = head->index + tail;
> +	page_tail->private = NULL;

There has a warning when compiling it:

mm/huge_memory.c: In function ‘__split_huge_page_tail’:
mm/huge_memory.c:2380:21: warning: assignment to ‘long unsigned int’ 
from ‘void *’ makes integer from pointer without a cast [-Wint-conversion]
   page_tail->private = NULL;
                      ^
   AR      mm/built-in.a


>   
>   	/* Page flags must be visible before we make the page non-compound. */
>   	smp_wmb();
> diff --git a/mm/migrate.c b/mm/migrate.c
> index e51588e95f57..6c1ea61f39d8 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -1106,6 +1106,7 @@ static int unmap_and_move(new_page_t get_new_page,
>   	if (!newpage)
>   		return -ENOMEM;
>   
> +	newpage->private = 0;
>   	rc = __unmap_and_move(page, newpage, force, mode);
>   	if (rc == MIGRATEPAGE_SUCCESS)
>   		set_page_owner_migrate_reason(newpage, reason);


  reply	other threads:[~2022-06-20  6:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-19 15:11 [PATCH 0/3] Fixes for 5.19b Matthew Wilcox (Oracle)
2022-06-19 15:11 ` [PATCH 1/3] filemap: Correct the conditions for marking a folio as accessed Matthew Wilcox (Oracle)
2022-06-20  6:25   ` Christoph Hellwig
2022-06-27  9:13   ` [filemap] 91fd26c76b: phoronix-test-suite.fio.SequentialRead.LinuxAIO.Yes.No.4KB.DefaultTestDirectory.mb_s -8.9% regression kernel test robot
2022-06-30  7:29   ` Major btrfs fiemap slowdown on file with many extents once in cache (RCU stalls?) (Was: [PATCH 1/3] filemap: Correct the conditions for marking a folio as accessed) Dominique MARTINET
2022-06-30 14:37     ` Theodore Ts'o
2022-06-30 22:43       ` Dominique MARTINET
2022-07-01  1:55     ` Yu Kuai
2022-07-07  8:42       ` Dominique MARTINET
2022-06-19 15:11 ` [PATCH 2/3] filemap: Handle sibling entries in filemap_get_read_batch() Matthew Wilcox (Oracle)
2022-06-20 10:15   ` Brian Foster
2022-06-19 15:11 ` [PATCH 3/3] mm: Clear page->private when splitting or migrating a page Matthew Wilcox (Oracle)
2022-06-20  6:41   ` Xiubo Li [this message]
2022-06-20 23:42   ` Xiubo Li

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=2031fee3-e09a-5cea-be26-71360893d161@redhat.com \
    --to=xiubli@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --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;
as well as URLs for NNTP newsgroup(s).