nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Shiyang Ruan <ruansy.fnst@fujitsu.com>
Cc: linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org,
	nvdimm@lists.linux.dev, linux-mm@kvack.org,
	linux-fsdevel@vger.kernel.org, djwong@kernel.org,
	dan.j.williams@intel.com, david@fromorbit.com, hch@infradead.org,
	jane.chu@oracle.com, Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH v10 2/9] mm: factor helpers for memory_failure_dev_pagemap
Date: Tue, 1 Feb 2022 21:03:51 +0000	[thread overview]
Message-ID: <YfmgNyG3mfxD/3nS@casper.infradead.org> (raw)
In-Reply-To: <20220127124058.1172422-3-ruansy.fnst@fujitsu.com>

On Thu, Jan 27, 2022 at 08:40:51PM +0800, Shiyang Ruan wrote:
> +static int mf_generic_kill_procs(unsigned long long pfn, int flags,
> +		struct dev_pagemap *pgmap)
> +{
> +	struct page *page = pfn_to_page(pfn);
> +	LIST_HEAD(to_kill);
> +	dax_entry_t cookie;
> +
> +	/*
> +	 * Prevent the inode from being freed while we are interrogating
> +	 * the address_space, typically this would be handled by
> +	 * lock_page(), but dax pages do not use the page lock. This
> +	 * also prevents changes to the mapping of this pfn until
> +	 * poison signaling is complete.
> +	 */
> +	cookie = dax_lock_page(page);
> +	if (!cookie)
> +		return -EBUSY;
> +
> +	if (hwpoison_filter(page))
> +		return 0;
> +
> +	if (pgmap->type == MEMORY_DEVICE_PRIVATE) {
> +		/*
> +		 * TODO: Handle HMM pages which may need coordination
> +		 * with device-side memory.
> +		 */
> +		return -EBUSY;
> +	}
> +
> +	/*
> +	 * Use this flag as an indication that the dax page has been
> +	 * remapped UC to prevent speculative consumption of poison.
> +	 */
> +	SetPageHWPoison(page);
> +
> +	/*
> +	 * Unlike System-RAM there is no possibility to swap in a
> +	 * different physical page at a given virtual address, so all
> +	 * userspace consumption of ZONE_DEVICE memory necessitates
> +	 * SIGBUS (i.e. MF_MUST_KILL)
> +	 */
> +	flags |= MF_ACTION_REQUIRED | MF_MUST_KILL;
> +	collect_procs(page, &to_kill, true);
> +
> +	unmap_and_kill(&to_kill, pfn, page->mapping, page->index, flags);
> +	dax_unlock_page(page, cookie);
> +	return 0;
> +}

There's an assumption here that fsdax only has order-0 pages.
pfn_to_page() is going to return the precise page for that pfn, but then
page->mapping and page->index are not valid for tail pages.

I'm currently trying to folio-ise memory-failure.c, and it is not
going well!  There are several places where it's hard to tell
what should happen.


  reply	other threads:[~2022-02-01 21:04 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-27 12:40 [PATCH v10 0/9] fsdax: introduce fs query to support reflink Shiyang Ruan
2022-01-27 12:40 ` [PATCH v10 1/9] dax: Introduce holder for dax_device Shiyang Ruan
2022-01-27 16:13   ` kernel test robot
2022-01-27 16:44   ` kernel test robot
2022-02-02 13:03   ` Christoph Hellwig
2022-02-13 12:58     ` [PATCH v10.1 " Shiyang Ruan
2022-02-15 22:06       ` Dan Williams
2022-01-27 12:40 ` [PATCH v10 2/9] mm: factor helpers for memory_failure_dev_pagemap Shiyang Ruan
2022-02-01 21:03   ` Matthew Wilcox [this message]
2022-02-15 22:11   ` Dan Williams
2022-01-27 12:40 ` [PATCH v10 3/9] pagemap,pmem: Introduce ->memory_failure() Shiyang Ruan
2022-02-15 22:38   ` Dan Williams
2022-01-27 12:40 ` [PATCH v10 4/9] fsdax: fix function description Shiyang Ruan
2022-02-02 13:04   ` Christoph Hellwig
2022-02-15 23:51     ` Dan Williams
2022-01-27 12:40 ` [PATCH v10 5/9] fsdax: Introduce dax_load_page() Shiyang Ruan
2022-02-16  1:34   ` Dan Williams
2022-02-16  3:02     ` Shiyang Ruan
2022-02-16  3:07       ` Dan Williams
2022-01-27 12:40 ` [PATCH v10 6/9] mm: move pgoff_address() to vma_pgoff_address() Shiyang Ruan
2022-02-16  1:37   ` Dan Williams
2022-01-27 12:40 ` [PATCH v10 7/9] mm: Introduce mf_dax_kill_procs() for fsdax case Shiyang Ruan
2022-02-16  1:47   ` Dan Williams
2022-02-16  1:49   ` Dan Williams
2022-01-27 12:40 ` [PATCH v10 8/9] xfs: Implement ->notify_failure() for XFS Shiyang Ruan
2022-01-27 17:56   ` kernel test robot
2022-01-27 19:39   ` kernel test robot
2022-02-01 20:41   ` Darrick J. Wong
2022-02-13 13:02     ` [PATCH v10.1 " Shiyang Ruan
2022-02-15  1:46       ` Darrick J. Wong
2022-02-15  9:42         ` Shiyang Ruan
2022-02-16  1:56   ` [PATCH v10 " Dan Williams
2022-01-27 12:40 ` [PATCH v10 9/9] fsdax: set a CoW flag when associate reflink mappings Shiyang Ruan
2022-02-16  2:09   ` Dan Williams
2022-02-16  2:55     ` Shiyang Ruan
2022-02-16  3:09       ` Dan Williams

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=YfmgNyG3mfxD/3nS@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=dan.j.williams@intel.com \
    --cc=david@fromorbit.com \
    --cc=djwong@kernel.org \
    --cc=hch@infradead.org \
    --cc=hch@lst.de \
    --cc=jane.chu@oracle.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=nvdimm@lists.linux.dev \
    --cc=ruansy.fnst@fujitsu.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;
as well as URLs for NNTP newsgroup(s).