From: Alistair Popple <apopple@nvidia.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: linux-mm@kvack.org, Matthew Wilcox <willy@infradead.org>,
Jan Kara <jack@suse.cz>, "Darrick J. Wong" <djwong@kernel.org>,
Christoph Hellwig <hch@lst.de>,
John Hubbard <jhubbard@nvidia.com>,
Jason Gunthorpe <jgg@nvidia.com>,
david@fromorbit.com, nvdimm@lists.linux.dev,
akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v3 24/25] mm/meremap_pages: Delete put_devmap_managed_page_refs()
Date: Mon, 17 Oct 2022 18:08:55 +1100 [thread overview]
Message-ID: <87y1tfylfk.fsf@nvidia.com> (raw)
In-Reply-To: <166579195789.2236710.7946318795534242314.stgit@dwillia2-xfh.jf.intel.com>
I didn't spot any issues with this nice clean up so:
Reviewed-by: Alistair Popple <apopple@nvidia.com>
Dan Williams <dan.j.williams@intel.com> writes:
> Now that fsdax DMA-idle detection no longer depends on catching
> transitions of page->_refcount to 1, and all users of pgmap pages get
> access to them via pgmap_request_folios(), remove
> put_devmap_managed_page_refs() and associated infrastructure. This
> includes the pgmap references taken at the beginning of time for each
> page because those @pgmap references are now arbitrated via
> pgmap_request_folios().
>
> Cc: Matthew Wilcox <willy@infradead.org>
> Cc: Jan Kara <jack@suse.cz>
> Cc: "Darrick J. Wong" <djwong@kernel.org>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: John Hubbard <jhubbard@nvidia.com>
> Cc: Alistair Popple <apopple@nvidia.com>
> Cc: Jason Gunthorpe <jgg@nvidia.com>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
> include/linux/mm.h | 30 ------------------------------
> mm/gup.c | 6 ++----
> mm/memremap.c | 38 --------------------------------------
> mm/swap.c | 2 --
> 4 files changed, 2 insertions(+), 74 deletions(-)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 8bbcccbc5565..c63dfc804f1e 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -1082,30 +1082,6 @@ vm_fault_t finish_mkwrite_fault(struct vm_fault *vmf);
> * back into memory.
> */
>
> -#if defined(CONFIG_ZONE_DEVICE) && defined(CONFIG_FS_DAX)
> -DECLARE_STATIC_KEY_FALSE(devmap_managed_key);
> -
> -bool __put_devmap_managed_page_refs(struct page *page, int refs);
> -static inline bool put_devmap_managed_page_refs(struct page *page, int refs)
> -{
> - if (!static_branch_unlikely(&devmap_managed_key))
> - return false;
> - if (!is_zone_device_page(page))
> - return false;
> - return __put_devmap_managed_page_refs(page, refs);
> -}
> -#else /* CONFIG_ZONE_DEVICE && CONFIG_FS_DAX */
> -static inline bool put_devmap_managed_page_refs(struct page *page, int refs)
> -{
> - return false;
> -}
> -#endif /* CONFIG_ZONE_DEVICE && CONFIG_FS_DAX */
> -
> -static inline bool put_devmap_managed_page(struct page *page)
> -{
> - return put_devmap_managed_page_refs(page, 1);
> -}
> -
> /* 127: arbitrary random number, small enough to assemble well */
> #define folio_ref_zero_or_close_to_overflow(folio) \
> ((unsigned int) folio_ref_count(folio) + 127u <= 127u)
> @@ -1202,12 +1178,6 @@ static inline void put_page(struct page *page)
> {
> struct folio *folio = page_folio(page);
>
> - /*
> - * For some devmap managed pages we need to catch refcount transition
> - * from 2 to 1:
> - */
> - if (put_devmap_managed_page(&folio->page))
> - return;
> folio_put(folio);
> }
>
> diff --git a/mm/gup.c b/mm/gup.c
> index ce00a4c40da8..e49b1f46faa5 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -87,8 +87,7 @@ static inline struct folio *try_get_folio(struct page *page, int refs)
> * belongs to this folio.
> */
> if (unlikely(page_folio(page) != folio)) {
> - if (!put_devmap_managed_page_refs(&folio->page, refs))
> - folio_put_refs(folio, refs);
> + folio_put_refs(folio, refs);
> goto retry;
> }
>
> @@ -184,8 +183,7 @@ static void gup_put_folio(struct folio *folio, int refs, unsigned int flags)
> refs *= GUP_PIN_COUNTING_BIAS;
> }
>
> - if (!put_devmap_managed_page_refs(&folio->page, refs))
> - folio_put_refs(folio, refs);
> + folio_put_refs(folio, refs);
> }
>
> /**
> diff --git a/mm/memremap.c b/mm/memremap.c
> index 368ff41c560b..53fe30bb79bb 100644
> --- a/mm/memremap.c
> +++ b/mm/memremap.c
> @@ -94,19 +94,6 @@ bool pgmap_pfn_valid(struct dev_pagemap *pgmap, unsigned long pfn)
> return false;
> }
>
> -static unsigned long pfn_end(struct dev_pagemap *pgmap, int range_id)
> -{
> - const struct range *range = &pgmap->ranges[range_id];
> -
> - return (range->start + range_len(range)) >> PAGE_SHIFT;
> -}
> -
> -static unsigned long pfn_len(struct dev_pagemap *pgmap, unsigned long range_id)
> -{
> - return (pfn_end(pgmap, range_id) -
> - pfn_first(pgmap, range_id)) >> pgmap->vmemmap_shift;
> -}
> -
> static void pageunmap_range(struct dev_pagemap *pgmap, int range_id)
> {
> struct range *range = &pgmap->ranges[range_id];
> @@ -138,10 +125,6 @@ void memunmap_pages(struct dev_pagemap *pgmap)
> int i;
>
> percpu_ref_kill(&pgmap->ref);
> - if (pgmap->type != MEMORY_DEVICE_PRIVATE &&
> - pgmap->type != MEMORY_DEVICE_COHERENT)
> - for (i = 0; i < pgmap->nr_range; i++)
> - percpu_ref_put_many(&pgmap->ref, pfn_len(pgmap, i));
>
> wait_for_completion(&pgmap->done);
>
> @@ -267,9 +250,6 @@ static int pagemap_range(struct dev_pagemap *pgmap, struct mhp_params *params,
> memmap_init_zone_device(&NODE_DATA(nid)->node_zones[ZONE_DEVICE],
> PHYS_PFN(range->start),
> PHYS_PFN(range_len(range)), pgmap);
> - if (pgmap->type != MEMORY_DEVICE_PRIVATE &&
> - pgmap->type != MEMORY_DEVICE_COHERENT)
> - percpu_ref_get_many(&pgmap->ref, pfn_len(pgmap, range_id));
> return 0;
>
> err_add_memory:
> @@ -584,21 +564,3 @@ void pgmap_release_folios(struct folio *folio, int nr_folios)
> for (iter = folio, i = 0; i < nr_folios; iter = folio_next(folio), i++)
> folio_put(iter);
> }
> -
> -#ifdef CONFIG_FS_DAX
> -bool __put_devmap_managed_page_refs(struct page *page, int refs)
> -{
> - if (page->pgmap->type != MEMORY_DEVICE_FS_DAX)
> - return false;
> -
> - /*
> - * fsdax page refcounts are 1-based, rather than 0-based: if
> - * refcount is 1, then the page is free and the refcount is
> - * stable because nobody holds a reference on the page.
> - */
> - if (page_ref_sub_return(page, refs) == 1)
> - wake_up_var(page);
> - return true;
> -}
> -EXPORT_SYMBOL(__put_devmap_managed_page_refs);
> -#endif /* CONFIG_FS_DAX */
> diff --git a/mm/swap.c b/mm/swap.c
> index 955930f41d20..0742b84fbf17 100644
> --- a/mm/swap.c
> +++ b/mm/swap.c
> @@ -1003,8 +1003,6 @@ void release_pages(struct page **pages, int nr)
> unlock_page_lruvec_irqrestore(lruvec, flags);
> lruvec = NULL;
> }
> - if (put_devmap_managed_page(&folio->page))
> - continue;
> if (folio_put_testzero(folio))
> free_zone_device_page(&folio->page);
> continue;
next prev parent reply other threads:[~2022-10-17 7:11 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-14 23:56 [PATCH v3 00/25] Fix the DAX-gup mistake Dan Williams
2022-10-14 23:57 ` [PATCH v3 01/25] fsdax: Wait on @page not @page->_refcount Dan Williams
2022-10-14 23:57 ` [PATCH v3 02/25] fsdax: Use dax_page_idle() to document DAX busy page checking Dan Williams
2022-10-14 23:57 ` [PATCH v3 03/25] fsdax: Include unmapped inodes for page-idle detection Dan Williams
2022-10-14 23:57 ` [PATCH v3 04/25] fsdax: Introduce dax_zap_mappings() Dan Williams
2022-11-02 13:04 ` Aneesh Kumar K.V
2022-10-14 23:57 ` [PATCH v3 05/25] fsdax: Wait for pinned pages during truncate_inode_pages_final() Dan Williams
2022-10-14 23:57 ` [PATCH v3 06/25] fsdax: Validate DAX layouts broken before truncate Dan Williams
2022-10-14 23:57 ` [PATCH v3 07/25] fsdax: Hold dax lock over mapping insertion Dan Williams
2022-10-17 19:31 ` Jason Gunthorpe
2022-10-17 20:17 ` Dan Williams
2022-10-18 5:26 ` Christoph Hellwig
2022-10-18 17:30 ` Dan Williams
2022-10-14 23:57 ` [PATCH v3 08/25] fsdax: Update dax_insert_entry() calling convention to return an error Dan Williams
2022-10-14 23:57 ` [PATCH v3 09/25] fsdax: Rework for_each_mapped_pfn() to dax_for_each_folio() Dan Williams
2022-10-14 23:57 ` [PATCH v3 10/25] fsdax: Introduce pgmap_request_folios() Dan Williams
2022-10-17 6:31 ` Alistair Popple
2022-10-17 20:06 ` Dan Williams
2022-10-17 20:11 ` Jason Gunthorpe
2022-10-17 20:51 ` Dan Williams
2022-10-17 23:57 ` Jason Gunthorpe
2022-10-18 0:19 ` Dan Williams
2022-10-17 19:41 ` Jason Gunthorpe
2022-10-14 23:58 ` [PATCH v3 11/25] fsdax: Rework dax_insert_entry() calling convention Dan Williams
2022-10-14 23:58 ` [PATCH v3 12/25] fsdax: Cleanup dax_associate_entry() Dan Williams
2022-10-14 23:58 ` [PATCH v3 13/25] devdax: Minor warning fixups Dan Williams
2022-10-14 23:58 ` [PATCH v3 14/25] devdax: Fix sparse lock imbalance warning Dan Williams
2022-10-14 23:58 ` [PATCH v3 15/25] libnvdimm/pmem: Support pmem block devices without dax Dan Williams
2022-10-14 23:58 ` [PATCH v3 16/25] devdax: Move address_space helpers to the DAX core Dan Williams
2022-10-14 23:58 ` [PATCH v3 17/25] devdax: Sparse fixes for xarray locking Dan Williams
2022-10-14 23:58 ` [PATCH v3 18/25] devdax: Sparse fixes for vmfault_t / dax-entry conversions Dan Williams
2022-10-14 23:58 ` [PATCH v3 19/25] devdax: Sparse fixes for vm_fault_t in tracepoints Dan Williams
2022-10-14 23:58 ` [PATCH v3 20/25] devdax: add PUD support to the DAX mapping infrastructure Dan Williams
2022-10-14 23:59 ` [PATCH v3 21/25] devdax: Use dax_insert_entry() + dax_delete_mapping_entry() Dan Williams
2022-10-14 23:59 ` [PATCH v3 22/25] mm/memremap_pages: Replace zone_device_page_init() with pgmap_request_folios() Dan Williams
2022-10-17 19:17 ` Lyude Paul
2022-10-14 23:59 ` [PATCH v3 23/25] mm/memremap_pages: Initialize all ZONE_DEVICE pages to start at refcount 0 Dan Williams
2022-10-17 7:04 ` Alistair Popple
2022-10-17 19:48 ` Jason Gunthorpe
2022-10-14 23:59 ` [PATCH v3 24/25] mm/meremap_pages: Delete put_devmap_managed_page_refs() Dan Williams
2022-10-17 7:08 ` Alistair Popple [this message]
2022-10-14 23:59 ` [PATCH v3 25/25] mm/gup: Drop DAX pgmap accounting 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=87y1tfylfk.fsf@nvidia.com \
--to=apopple@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=dan.j.williams@intel.com \
--cc=david@fromorbit.com \
--cc=djwong@kernel.org \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=jgg@nvidia.com \
--cc=jhubbard@nvidia.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nvdimm@lists.linux.dev \
--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