Skip to content

Commit 542bcea

Browse files
LGA1150davem330
authored andcommitted
net: page_pool: use in_softirq() instead
We use BH context only for synchronization, so we don't care if it's actually serving softirq or not. As a side node, in case of threaded NAPI, in_serving_softirq() will return false because it's in process context with BH off, making page_pool_recycle_in_cache() unreachable. Signed-off-by: Qingfang DENG <qingfang.deng@siflower.com.cn> Tested-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 637bc8f commit 542bcea

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

include/net/page_pool.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ static inline void page_pool_nid_changed(struct page_pool *pool, int new_nid)
386386
static inline void page_pool_ring_lock(struct page_pool *pool)
387387
__acquires(&pool->ring.producer_lock)
388388
{
389-
if (in_serving_softirq())
389+
if (in_softirq())
390390
spin_lock(&pool->ring.producer_lock);
391391
else
392392
spin_lock_bh(&pool->ring.producer_lock);
@@ -395,7 +395,7 @@ static inline void page_pool_ring_lock(struct page_pool *pool)
395395
static inline void page_pool_ring_unlock(struct page_pool *pool)
396396
__releases(&pool->ring.producer_lock)
397397
{
398-
if (in_serving_softirq())
398+
if (in_softirq())
399399
spin_unlock(&pool->ring.producer_lock);
400400
else
401401
spin_unlock_bh(&pool->ring.producer_lock);

net/core/page_pool.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,8 @@ static void page_pool_return_page(struct page_pool *pool, struct page *page)
511511
static bool page_pool_recycle_in_ring(struct page_pool *pool, struct page *page)
512512
{
513513
int ret;
514-
/* BH protection not needed if current is serving softirq */
515-
if (in_serving_softirq())
514+
/* BH protection not needed if current is softirq */
515+
if (in_softirq())
516516
ret = ptr_ring_produce(&pool->ring, page);
517517
else
518518
ret = ptr_ring_produce_bh(&pool->ring, page);
@@ -570,7 +570,7 @@ __page_pool_put_page(struct page_pool *pool, struct page *page,
570570
page_pool_dma_sync_for_device(pool, page,
571571
dma_sync_size);
572572

573-
if (allow_direct && in_serving_softirq() &&
573+
if (allow_direct && in_softirq() &&
574574
page_pool_recycle_in_cache(page, pool))
575575
return NULL;
576576

0 commit comments

Comments
 (0)