All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alistair Popple <apopple@nvidia.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: linux-mm@kvack.org, david@fromorbit.com, jhubbard@nvidia.com,
	rcampbell@nvidia.com, willy@infradead.org, jgg@nvidia.com,
	linux-fsdevel@vger.kernel.org, jack@suse.cz, djwong@kernel.org,
	hch@lst.de, david@redhat.com, ruansy.fnst@fujitsu.com,
	nvdimm@lists.linux.dev, linux-xfs@vger.kernel.org,
	linux-ext4@vger.kernel.org, jglisse@redhat.com
Subject: Re: [RFC 04/10] fs/dax: Don't track page mapping/index
Date: Mon, 15 Apr 2024 17:03:48 +1000	[thread overview]
Message-ID: <878r1f2jko.fsf@nvdebian.thelocal> (raw)
In-Reply-To: <66197008db9fc_36222e294b8@dwillia2-xfh.jf.intel.com.notmuch>


Dan Williams <dan.j.williams@intel.com> writes:

> Jan Kara wrote:
>> On Thu 11-04-24 10:57:25, Alistair Popple wrote:
>> > The page->mapping and page->index fields are normally used by the
>> > pagecache and rmap for looking up virtual mappings of pages. FS DAX
>> > implements it's own kind of page cache and rmap look ups so these
>> > fields are unnecessary. They are currently only used to detect
>> > error/warning conditions which should never occur.
>> > 
>> > A future change will change the way shared mappings are detected by
>> > doing normal page reference counting instead, so remove the
>> > unnecessary checks.
>> > 
>> > Signed-off-by: Alistair Popple <apopple@nvidia.com>
>> ...
>> > -/*
>> > - * When it is called in dax_insert_entry(), the shared flag will indicate that
>> > - * whether this entry is shared by multiple files.  If so, set the page->mapping
>> > - * PAGE_MAPPING_DAX_SHARED, and use page->share as refcount.
>> > - */
>> > -static void dax_associate_entry(void *entry, struct address_space *mapping,
>> > -		struct vm_area_struct *vma, unsigned long address, bool shared)
>> > -{
>> > -	unsigned long size = dax_entry_size(entry), pfn, index;
>> > -	int i = 0;
>> > -
>> > -	if (IS_ENABLED(CONFIG_FS_DAX_LIMITED))
>> > -		return;
>> > -
>> > -	index = linear_page_index(vma, address & ~(size - 1));
>> > -	for_each_mapped_pfn(entry, pfn) {
>> > -		struct page *page = pfn_to_page(pfn);
>> > -
>> > -		if (shared) {
>> > -			dax_page_share_get(page);
>> > -		} else {
>> > -			WARN_ON_ONCE(page->mapping);
>> > -			page->mapping = mapping;
>> > -			page->index = index + i++;
>> > -		}
>> > -	}
>> > -}
>> 
>> Hum, but what about existing uses of folio->mapping and folio->index in
>> fs/dax.c? AFAICT this patch breaks them. What am I missing? How can this
>> ever work?

I did feel I was missing something here as well, but nothing obviously
breaks with this change from a test perspective (ie. ndctl tests, manual
tests). Somehow I missed how this was used in code, but Dan provided
enough of a hint below though so now I see the errors of my ways :-)

> Right, as far as I can see every fsdax filesystem would need to be
> converted to use dax_holder_operations() so that the fs can backfill
> ->mapping and ->index.

Oh, that was the hint I needed. Thanks. So basically it's just used for
memory failure like so:

memory_failure()
 -> memory_failure_dev_pagemap()
  -> mf_generic_kill_procs()
   -> dax_lock_page()
    -> mapping = READ_ONCE(page->mapping);
 
Somehow I had missed that bleatingly obvious usage of page->mapping. I
also couldn't understand how it was important if it was safe for it to
be just randomly overwritten in the shared case.

But I think I understand now - shared fs dax pages are only supported on
xfs and the mapping/index fields aren't used there because xfs provides
it's own look up for memory failure using dax_holder_operations.

I was initially concerned about these cases because I was wondering if
folio subpages could ever get different mappings and the shared case
implied they could. But it seems that's xfs specific and there is a
separate mechanism to deal with looking up ->mapping/index for that. So
I guess we should still be able to safely store this on the folio
head. I will double check and update this change.

  reply	other threads:[~2024-04-15  7:04 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-11  0:57 [RFC 00/10] fs/dax: Fix FS DAX page reference counts Alistair Popple
2024-04-11  0:57 ` [RFC 01/10] mm/gup.c: Remove redundant check for PCI P2PDMA page Alistair Popple
2024-04-11 12:59   ` Jason Gunthorpe
2024-04-11 13:47   ` David Hildenbrand
2024-04-12  1:37     ` Alistair Popple
2024-04-11  0:57 ` [RFC 02/10] mm/hmm: Remove dead check for HugeTLB and FS DAX Alistair Popple
2024-04-11 12:25   ` Jason Gunthorpe
2024-04-11 13:37     ` Peter Xu
2024-04-12  1:28       ` Alistair Popple
2024-04-11  0:57 ` [RFC 03/10] pci/p2pdma: Don't initialise page refcount to one Alistair Popple
2024-04-11 12:29   ` Jason Gunthorpe
2024-04-12  5:40     ` Alistair Popple
2024-04-12 17:20   ` Dan Williams
2024-05-09 21:59   ` Logan Gunthorpe
2024-05-09 23:14     ` Alistair Popple
2024-04-11  0:57 ` [RFC 04/10] fs/dax: Don't track page mapping/index Alistair Popple
2024-04-12 15:22   ` Jan Kara
2024-04-12 17:31     ` Dan Williams
2024-04-15  7:03       ` Alistair Popple [this message]
2024-04-15 20:51         ` Dan Williams
2024-04-16  0:07           ` Alistair Popple
2024-04-16  0:36             ` Dan Williams
2024-04-12 17:21   ` Dan Williams
2024-04-11  0:57 ` [RFC 05/10] fs/dax: Refactor wait for dax idle page Alistair Popple
2024-04-12 14:37   ` Jan Kara
2024-04-13 20:19   ` John Hubbard
2024-04-15  8:41     ` Alistair Popple
2024-04-11  0:57 ` [RFC 06/10] fs/dax: Add dax_page_free callback Alistair Popple
2024-04-11 23:34   ` kernel test robot
2024-04-11  0:57 ` [RFC 07/10] mm: Allow compound zone device pages Alistair Popple
2024-04-11 12:32   ` Jason Gunthorpe
2024-04-11 14:10   ` Matthew Wilcox
2024-04-12  1:38     ` Alistair Popple
2024-04-11  0:57 ` [RFC 08/10] fs/dax: Properly refcount fs dax pages Alistair Popple
2024-04-11 21:08   ` kernel test robot
2024-04-11  0:57 ` [RFC 09/10] mm/khugepage.c: Warn if trying to scan devmap pmd Alistair Popple
2024-04-11 13:45   ` David Hildenbrand
2024-04-12  1:34     ` Alistair Popple
2024-04-11  0:57 ` [RFC 10/10] mm: Remove pXX_devmap Alistair Popple
2024-04-11 12:57   ` Jason Gunthorpe
2024-04-12  0:36   ` kernel test robot
2024-04-11 17:28 ` [RFC 00/10] fs/dax: Fix FS DAX page reference counts Dan Williams
2024-04-11 17:35   ` Jason Gunthorpe
2024-04-11 17:56     ` Dan Williams
2024-04-12  3:54   ` Alistair Popple
2024-04-12  6:55     ` Alistair Popple
2024-04-12 11:53       ` Jason Gunthorpe
2024-04-12 17:32         ` 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=878r1f2jko.fsf@nvdebian.thelocal \
    --to=apopple@nvidia.com \
    --cc=dan.j.williams@intel.com \
    --cc=david@fromorbit.com \
    --cc=david@redhat.com \
    --cc=djwong@kernel.org \
    --cc=hch@lst.de \
    --cc=jack@suse.cz \
    --cc=jgg@nvidia.com \
    --cc=jglisse@redhat.com \
    --cc=jhubbard@nvidia.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=nvdimm@lists.linux.dev \
    --cc=rcampbell@nvidia.com \
    --cc=ruansy.fnst@fujitsu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.