From: Jesper Dangaard Brouer <jbrouer@redhat.com>
To: Yunsheng Lin <linyunsheng@huawei.com>,
davem@davemloft.net, kuba@kernel.org
Cc: brouer@redhat.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, hawk@kernel.org,
ilias.apalodimas@linaro.org,
"Michael S. Tsirkin" <mst@redhat.com>,
Linux-MM <linux-mm@kvack.org>
Subject: Re: [PATCH net-next] page_pool: remove spinlock in page_pool_refill_alloc_cache()
Date: Fri, 7 Jan 2022 14:32:10 +0100 [thread overview]
Message-ID: <3b7780d5-8f0b-0388-37e2-51ee8b282ab0@redhat.com> (raw)
In-Reply-To: <20220107090042.13605-1-linyunsheng@huawei.com>
On 07/01/2022 10.00, Yunsheng Lin wrote:
> As page_pool_refill_alloc_cache() is only called by
> __page_pool_get_cached(), which assumes non-concurrent access
> as suggested by the comment in __page_pool_get_cached(), and
> ptr_ring allows concurrent access between consumer and producer,
> so remove the spinlock in page_pool_refill_alloc_cache().
This should be okay as __ptr_ring_consume() have a memory barrier via
READ_ONCE in __ptr_ring_peek(). The code page_pool_empty_ring() also
does ptr_ring consume, but drivers should already take care that this
will not be called concurrently, as it is part of the teardown code path
(which can only run concurrently with ptr_ring producer side).
Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>
The original reason behind this lock was that I was planning to allow
the memory subsystem to reclaim pages sitting in page_pool's cache.
Unfortunately I never got around to implement this.
> Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
> ---
> net/core/page_pool.c | 4 ----
> 1 file changed, 4 deletions(-)
>
> diff --git a/net/core/page_pool.c b/net/core/page_pool.c
> index 1a6978427d6c..6efad8b29e9c 100644
> --- a/net/core/page_pool.c
> +++ b/net/core/page_pool.c
> @@ -130,9 +130,6 @@ static struct page *page_pool_refill_alloc_cache(struct page_pool *pool)
> pref_nid = numa_mem_id(); /* will be zero like page_to_nid() */
> #endif
>
> - /* Slower-path: Get pages from locked ring queue */
> - spin_lock(&r->consumer_lock);
> -
> /* Refill alloc array, but only if NUMA match */
> do {
> page = __ptr_ring_consume(r);
> @@ -157,7 +154,6 @@ static struct page *page_pool_refill_alloc_cache(struct page_pool *pool)
> if (likely(pool->alloc.count > 0))
> page = pool->alloc.cache[--pool->alloc.count];
>
> - spin_unlock(&r->consumer_lock);
> return page;
> }
>
>
parent reply other threads:[~2022-01-07 13:32 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20220107090042.13605-1-linyunsheng@huawei.com>]
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=3b7780d5-8f0b-0388-37e2-51ee8b282ab0@redhat.com \
--to=jbrouer@redhat.com \
--cc=brouer@redhat.com \
--cc=davem@davemloft.net \
--cc=hawk@kernel.org \
--cc=ilias.apalodimas@linaro.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linyunsheng@huawei.com \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.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