diff mbox series

[03/17] mm: Add folio_pincount_ptr()

Message ID 20220102215729.2943705-4-willy@infradead.org (mailing list archive)
State New
Headers show
Series Convert GUP to folios | expand

Commit Message

Matthew Wilcox Jan. 2, 2022, 9:57 p.m. UTC
This is the folio equivalent of compound_pincount_ptr().

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

Comments

Christoph Hellwig Jan. 4, 2022, 8:02 a.m. UTC | #1
On Sun, Jan 02, 2022 at 09:57:15PM +0000, Matthew Wilcox (Oracle) wrote:
> This is the folio equivalent of compound_pincount_ptr().
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>  include/linux/mm_types.h | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
> index c3a6e6209600..09d9e2c4a2c5 100644
> --- a/include/linux/mm_types.h
> +++ b/include/linux/mm_types.h
> @@ -309,6 +309,12 @@ static inline atomic_t *compound_mapcount_ptr(struct page *page)
>  	return &page[1].compound_mapcount;
>  }
>  
> +static inline atomic_t *folio_pincount_ptr(struct folio *folio)
> +{
> +	struct page *tail = &folio->page + 2;
> +	return &tail->hpage_pinned_refcount;

Missing empty line?  Except for that and the fact that I dislike the
pre-existing magic numbers this looks fine.

Reviewed-by: Christoph Hellwig <hch@lst.de>
John Hubbard Jan. 4, 2022, 9:43 p.m. UTC | #2
On 1/2/22 13:57, Matthew Wilcox (Oracle) wrote:
> This is the folio equivalent of compound_pincount_ptr().
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>   include/linux/mm_types.h | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
> index c3a6e6209600..09d9e2c4a2c5 100644
> --- a/include/linux/mm_types.h
> +++ b/include/linux/mm_types.h
> @@ -309,6 +309,12 @@ static inline atomic_t *compound_mapcount_ptr(struct page *page)
>   	return &page[1].compound_mapcount;
>   }
>   
> +static inline atomic_t *folio_pincount_ptr(struct folio *folio)
> +{
> +	struct page *tail = &folio->page + 2;
> +	return &tail->hpage_pinned_refcount;
> +}
> +
>   static inline atomic_t *compound_pincount_ptr(struct page *page)
>   {
>   	return &page[2].hpage_pinned_refcount;


Reviewed-by: John Hubbard <jhubbard@nvidia.com>


thanks,
William Kucharski Jan. 6, 2022, 9:57 p.m. UTC | #3
Comment inline.

> On Jan 2, 2022, at 2:57 PM, Matthew Wilcox (Oracle) <willy@infradead.org> wrote:
> 
> This is the folio equivalent of compound_pincount_ptr().
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
> include/linux/mm_types.h | 6 ++++++
> 1 file changed, 6 insertions(+)
> 
> diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
> index c3a6e6209600..09d9e2c4a2c5 100644
> --- a/include/linux/mm_types.h
> +++ b/include/linux/mm_types.h
> @@ -309,6 +309,12 @@ static inline atomic_t *compound_mapcount_ptr(struct page *page)
> 	return &page[1].compound_mapcount;
> }
> 
> +static inline atomic_t *folio_pincount_ptr(struct folio *folio)
> +{
> +	struct page *tail = &folio->page + 2;

Please add a comment explaining why this is "2."

> +	return &tail->hpage_pinned_refcount;
> +}
> +
> static inline atomic_t *compound_pincount_ptr(struct page *page)
> {
> 	return &page[2].hpage_pinned_refcount;
> -- 
> 2.33.0
>
diff mbox series

Patch

diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index c3a6e6209600..09d9e2c4a2c5 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -309,6 +309,12 @@  static inline atomic_t *compound_mapcount_ptr(struct page *page)
 	return &page[1].compound_mapcount;
 }
 
+static inline atomic_t *folio_pincount_ptr(struct folio *folio)
+{
+	struct page *tail = &folio->page + 2;
+	return &tail->hpage_pinned_refcount;
+}
+
 static inline atomic_t *compound_pincount_ptr(struct page *page)
 {
 	return &page[2].hpage_pinned_refcount;