All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Hubbard <jhubbard@nvidia.com>
To: Yunsheng Lin <linyunsheng@huawei.com>,
	davem@davemloft.net, kuba@kernel.org
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linuxarm@openeuler.org, akpm@linux-foundation.org,
	hawk@kernel.org, ilias.apalodimas@linaro.org,
	peterz@infradead.org, yuzhao@google.com, will@kernel.org,
	willy@infradead.org, jgg@ziepe.ca, mcroce@microsoft.com,
	willemb@google.com, cong.wang@bytedance.com, pabeni@redhat.com,
	haokexin@gmail.com, nogikh@google.com, elver@google.com,
	memxor@gmail.com, vvs@virtuozzo.com, linux-mm@kvack.org,
	edumazet@google.com, alexander.duyck@gmail.com,
	dsahern@gmail.com
Subject: Re: [PATCH net-next -v5 3/4] mm: introduce __get_page() and __put_page()
Date: Sat, 9 Oct 2021 12:49:29 -0700	[thread overview]
Message-ID: <62106771-7d2a-3897-c318-79578360a88a@nvidia.com> (raw)
In-Reply-To: <20211009093724.10539-4-linyunsheng@huawei.com>

On 10/9/21 02:37, Yunsheng Lin wrote:
> Introduce __get_page() and __put_page() to operate on the
> base page or head of a compound page for the cases when a
> page is known to be a base page or head of a compound page.

Hi,

I wonder if you are aware of a much larger, 137-patch seriesto do that:
folio/pageset [1]?

The naming you are proposing here does not really improve clarity. There
is nothing about __get_page() that makes it clear that it's meant only
for head/base pages, while get_page() tail pages as well. And the
well-known and widely used get_page() and put_page() get their meaning
shifted.

This area is hard to get right, and that's why there have been 15
versions, and a lot of contention associated with [1]. If you have an
alternate approach, I think it would be better in its own separate
series, with a cover letter that, at a minimum, explains how it compares
to folios/pagesets.

So in case it's not clear, I'd like to request that you drop this one
patch from your series.


[1] https://lore.kernel.org/r/YSPwmNNuuQhXNToQ@casper.infradead.org

thanks,
-- 
John Hubbard
NVIDIA

> 
> Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
> ---
>   include/linux/mm.h | 21 ++++++++++++++-------
>   mm/swap.c          |  6 +++---
>   2 files changed, 17 insertions(+), 10 deletions(-)
> 
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 73a52aba448f..5683313c3e9d 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -902,7 +902,7 @@ static inline struct page *virt_to_head_page(const void *x)
>   	return compound_head(page);
>   }
>   
> -void __put_page(struct page *page);
> +void __put_single_or_compound_page(struct page *page);
>   
>   void put_pages_list(struct list_head *pages);
>   
> @@ -1203,9 +1203,8 @@ static inline bool is_pci_p2pdma_page(const struct page *page)
>   #define page_ref_zero_or_close_to_overflow(page) \
>   	((unsigned int) page_ref_count(page) + 127u <= 127u)
>   
> -static inline void get_page(struct page *page)
> +static inline void __get_page(struct page *page)
>   {
> -	page = compound_head(page);
>   	/*
>   	 * Getting a normal page or the head of a compound page
>   	 * requires to already have an elevated page->_refcount.
> @@ -1214,6 +1213,11 @@ static inline void get_page(struct page *page)
>   	page_ref_inc(page);
>   }
>   
> +static inline void get_page(struct page *page)
> +{
> +	__get_page(compound_head(page));
> +}
> +
>   bool __must_check try_grab_page(struct page *page, unsigned int flags);
>   struct page *try_grab_compound_head(struct page *page, int refs,
>   				    unsigned int flags);
> @@ -1228,10 +1232,8 @@ static inline __must_check bool try_get_page(struct page *page)
>   	return true;
>   }
>   
> -static inline void put_page(struct page *page)
> +static inline void __put_page(struct page *page)
>   {
> -	page = compound_head(page);
> -
>   	/*
>   	 * For devmap managed pages we need to catch refcount transition from
>   	 * 2 to 1, when refcount reach one it means the page is free and we
> @@ -1244,7 +1246,12 @@ static inline void put_page(struct page *page)
>   	}
>   
>   	if (put_page_testzero(page))
> -		__put_page(page);
> +		__put_single_or_compound_page(page);
> +}
> +
> +static inline void put_page(struct page *page)
> +{
> +	__put_page(compound_head(page));
>   }
>   
>   /*
> diff --git a/mm/swap.c b/mm/swap.c
> index af3cad4e5378..565cbde1caea 100644
> --- a/mm/swap.c
> +++ b/mm/swap.c
> @@ -111,7 +111,7 @@ static void __put_compound_page(struct page *page)
>   	destroy_compound_page(page);
>   }
>   
> -void __put_page(struct page *page)
> +void __put_single_or_compound_page(struct page *page)
>   {
>   	if (is_zone_device_page(page)) {
>   		put_dev_pagemap(page->pgmap);
> @@ -128,7 +128,7 @@ void __put_page(struct page *page)
>   	else
>   		__put_single_page(page);
>   }
> -EXPORT_SYMBOL(__put_page);
> +EXPORT_SYMBOL(__put_single_or_compound_page);
>   
>   /**
>    * put_pages_list() - release a list of pages
> @@ -1153,7 +1153,7 @@ void put_devmap_managed_page(struct page *page)
>   	if (count == 1)
>   		free_devmap_managed_page(page);
>   	else if (!count)
> -		__put_page(page);
> +		__put_single_or_compound_page(page);
>   }
>   EXPORT_SYMBOL(put_devmap_managed_page);
>   #endif
> 


  reply	other threads:[~2021-10-09 19:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-09  9:37 [PATCH net-next -v5 0/4] some optimization for page pool Yunsheng Lin
2021-10-09  9:37 ` [PATCH net-next -v5 1/4] page_pool: disable dma mapping support for 32-bit arch with 64-bit DMA Yunsheng Lin
2021-10-09  9:37 ` [PATCH net-next -v5 2/4] page_pool: change BIAS_MAX to support incrementing Yunsheng Lin
2021-10-09  9:37 ` [PATCH net-next -v5 3/4] mm: introduce __get_page() and __put_page() Yunsheng Lin
2021-10-09 19:49   ` John Hubbard [this message]
2021-10-09 20:15     ` Matthew Wilcox
2021-10-11  6:37       ` Yunsheng Lin
2021-10-11 12:25     ` Jesper Dangaard Brouer
2021-10-11 12:29       ` Ilias Apalodimas
2021-10-12  7:38         ` Yunsheng Lin
2021-10-12  7:49           ` Ilias Apalodimas
2021-10-09  9:37 ` [PATCH net-next -v5 4/4] skbuff: keep track of pp page when pp_frag_count is used Yunsheng Lin
2021-10-09 12:11   ` kernel test robot
2021-10-09 12:11     ` kernel test robot
2021-10-09 12:12   ` kernel test robot
2021-10-09 12:12     ` kernel test robot

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=62106771-7d2a-3897-c318-79578360a88a@nvidia.com \
    --to=jhubbard@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=alexander.duyck@gmail.com \
    --cc=cong.wang@bytedance.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@gmail.com \
    --cc=edumazet@google.com \
    --cc=elver@google.com \
    --cc=haokexin@gmail.com \
    --cc=hawk@kernel.org \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jgg@ziepe.ca \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linuxarm@openeuler.org \
    --cc=linyunsheng@huawei.com \
    --cc=mcroce@microsoft.com \
    --cc=memxor@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=nogikh@google.com \
    --cc=pabeni@redhat.com \
    --cc=peterz@infradead.org \
    --cc=vvs@virtuozzo.com \
    --cc=will@kernel.org \
    --cc=willemb@google.com \
    --cc=willy@infradead.org \
    --cc=yuzhao@google.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 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.