linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Song Liu <songliubraving@fb.com>
Cc: <linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>,
	<matthew.wilcox@oracle.com>, <kernel-team@fb.com>,
	<william.kucharski@oracle.com>, <kirill.shutemov@linux.intel.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Hugh Dickins <hughd@google.com>
Subject: Re: [PATCH v3] mm,thp: recheck each page before collapsing file THP
Date: Fri, 18 Oct 2019 18:17:12 -0700	[thread overview]
Message-ID: <20191018181712.91dd9e9f9941642300e1b8d9@linux-foundation.org> (raw)
In-Reply-To: <20191018180345.4188310-1-songliubraving@fb.com>

On Fri, 18 Oct 2019 11:03:45 -0700 Song Liu <songliubraving@fb.com> wrote:

> In collapse_file(), after locking the page, it is necessary to recheck
> that the page is up-to-date. Add PageUptodate() check for both shmem THP
> and file THP.
> 
> Current khugepaged should not try to collapse dirty file THP, because it
> is limited to read only text. Add a PageDirty check and warning for file
> THP. This is added after page_mapping() check, because if the page is
> truncated, it might be dirty.

When fixing a bug, please always fully describe the end-user visible
effects of that bug.  This is vital information for people who are
considering the fix for backporting.

I'm suspecting that you've found a race condition which can trigger a
VM_BUG_ON_PAGE(), which is rather serious.  But that was just a wild
guess.  Please don't make us wildly guess :(

The old code looked rather alarming:

			} else if (!PageUptodate(page)) {
				xas_unlock_irq(&xas);
				wait_on_page_locked(page);
				if (!trylock_page(page)) {
					result = SCAN_PAGE_LOCK;
					goto xa_unlocked;
				}
				get_page(page);

We don't have a ref on that page.  After we've released the xarray lock
we have no business playing with *page at all, correct?



  reply	other threads:[~2019-10-19  1:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-18 18:03 Song Liu
2019-10-19  1:17 ` Andrew Morton [this message]
2019-10-19  5:24   ` Song Liu
2019-10-21 18:03     ` Johannes Weiner
2019-11-06  4:58     ` Andrew Morton
2019-11-06  5:45       ` Song Liu

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=20191018181712.91dd9e9f9941642300e1b8d9@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=hughd@google.com \
    --cc=kernel-team@fb.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=matthew.wilcox@oracle.com \
    --cc=songliubraving@fb.com \
    --cc=william.kucharski@oracle.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