diff mbox series

[01/10] highmem: Add folio_release_kmap()

Message ID 20230921200746.3303942-1-willy@infradead.org
State Not Applicable
Headers show
Series [01/10] highmem: Add folio_release_kmap() | expand

Commit Message

Matthew Wilcox Sept. 21, 2023, 8:07 p.m. UTC
This is the folio equivalent of unmap_and_put_page(), which remains as
a wrapper for it.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 include/linux/highmem.h | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

Comments

Jan Kara Oct. 3, 2023, 10:41 a.m. UTC | #1
On Thu 21-09-23 21:07:38, Matthew Wilcox (Oracle) wrote:
> This is the folio equivalent of unmap_and_put_page(), which remains as
> a wrapper for it.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>

I'm missing a patch 10/10 in this series (and a coverletter would be nice
as well)... What's there ;)?

								Honza

> ---
>  include/linux/highmem.h | 18 ++++++++++++++++--
>  1 file changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/highmem.h b/include/linux/highmem.h
> index 99c474de800d..4cacc0e43b51 100644
> --- a/include/linux/highmem.h
> +++ b/include/linux/highmem.h
> @@ -551,10 +551,24 @@ static inline void folio_zero_range(struct folio *folio,
>  	zero_user_segments(&folio->page, start, start + length, 0, 0);
>  }
>  
> -static inline void unmap_and_put_page(struct page *page, void *addr)
> +/**
> + * folio_release_kmap - Unmap a folio and drop a refcount.
> + * @folio: The folio to release.
> + * @addr: The address previously returned by a call to kmap_local_folio().
> + *
> + * It is common, eg in directory handling to kmap a folio.  This function
> + * unmaps the folio and drops the refcount that was being held to keep the
> + * folio alive while we accessed it.
> + */
> +static inline void folio_release_kmap(struct folio *folio, void *addr)
>  {
>  	kunmap_local(addr);
> -	put_page(page);
> +	folio_put(folio);
> +}
> +
> +static inline void unmap_and_put_page(struct page *page, void *addr)
> +{
> +	folio_release_kmap(page_folio(page), addr);
>  }
>  
>  #endif /* _LINUX_HIGHMEM_H */
> -- 
> 2.40.1
>
Matthew Wilcox Oct. 3, 2023, 11:55 a.m. UTC | #2
On Tue, Oct 03, 2023 at 12:41:28PM +0200, Jan Kara wrote:
> On Thu 21-09-23 21:07:38, Matthew Wilcox (Oracle) wrote:
> > This is the folio equivalent of unmap_and_put_page(), which remains as
> > a wrapper for it.
> > 
> > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> 
> I'm missing a patch 10/10 in this series (and a coverletter would be nice
> as well)... What's there ;)?

Email sucks!  https://www.infradead.org/~willy/linux/ext2-dir-20230921/
diff mbox series

Patch

diff --git a/include/linux/highmem.h b/include/linux/highmem.h
index 99c474de800d..4cacc0e43b51 100644
--- a/include/linux/highmem.h
+++ b/include/linux/highmem.h
@@ -551,10 +551,24 @@  static inline void folio_zero_range(struct folio *folio,
 	zero_user_segments(&folio->page, start, start + length, 0, 0);
 }
 
-static inline void unmap_and_put_page(struct page *page, void *addr)
+/**
+ * folio_release_kmap - Unmap a folio and drop a refcount.
+ * @folio: The folio to release.
+ * @addr: The address previously returned by a call to kmap_local_folio().
+ *
+ * It is common, eg in directory handling to kmap a folio.  This function
+ * unmaps the folio and drops the refcount that was being held to keep the
+ * folio alive while we accessed it.
+ */
+static inline void folio_release_kmap(struct folio *folio, void *addr)
 {
 	kunmap_local(addr);
-	put_page(page);
+	folio_put(folio);
+}
+
+static inline void unmap_and_put_page(struct page *page, void *addr)
+{
+	folio_release_kmap(page_folio(page), addr);
 }
 
 #endif /* _LINUX_HIGHMEM_H */