Remove some redundant assignment in page allocation process.
Signed-off-by: Yunsheng Lin <linyunsheng(a)huawei.com>
---
net/core/page_pool.c | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/net/core/page_pool.c b/net/core/page_pool.c
index 9b203d8660e4..afc6878b3b5b 100644
--- a/net/core/page_pool.c
+++ b/net/core/page_pool.c
@@ -278,18 +278,14 @@ static struct page *page_pool_refill_alloc_cache(struct page_pool *pool)
/* fast path */
static struct page *__page_pool_get_cached(struct page_pool *pool)
{
- struct page *page;
-
/* Caller MUST guarantee safe non-concurrent access, e.g. softirq */
if (likely(pool->alloc.count)) {
/* Fast-path */
- page = pool->alloc.cache[--pool->alloc.count];
alloc_stat_inc(pool, fast);
- } else {
- page = page_pool_refill_alloc_cache(pool);
+ return pool->alloc.cache[--pool->alloc.count];
}
- return page;
+ return page_pool_refill_alloc_cache(pool);
}
static void page_pool_dma_sync_for_device(struct page_pool *pool,
@@ -415,14 +411,11 @@ static struct page *__page_pool_alloc_pages_slow(struct page_pool *pool,
/* Return last page */
if (likely(pool->alloc.count > 0)) {
- page = pool->alloc.cache[--pool->alloc.count];
alloc_stat_inc(pool, slow);
- } else {
- page = NULL;
+ return pool->alloc.cache[--pool->alloc.count];
}
- /* When page just alloc'ed is should/must have refcnt 1. */
- return page;
+ return NULL;
}
/* For using page_pool replace: alloc_pages() API calls, but provide
@@ -438,8 +431,7 @@ struct page *page_pool_alloc_pages(struct page_pool *pool, gfp_t gfp)
return page;
/* Slow-path: cache empty, do real allocation */
- page = __page_pool_alloc_pages_slow(pool, gfp);
- return page;
+ return __page_pool_alloc_pages_slow(pool, gfp);
}
EXPORT_SYMBOL(page_pool_alloc_pages);
--
2.33.0