Skip to contentSkip to conversation

net: page_pool: rename page_pool_is_last_ref()

PATCH Superseded Jakub Kicinski 3 participants 3 messages Dec 13, 2024

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH 1/1 net: page_pool: rename page_pool_is_last_ref()

page_pool_is_last_ref() releases a reference while the name, to me at least, suggests it just checks if the refcount is 1. The semantics of the function are the same as those of atomic_dec_and_test() and refcount_dec_and_test(), so just use the _and_test() suffix.

---
Hopefully this doesn't conflict with anyone's work, I've been deferring sending this rename forever because I always look at it while reviewing an in-flight series and then I'm worried it will conflict.

---
 include/net/page_pool/helpers.h | 4 ++--
 net/core/page_pool.c            | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
include/net/page_pool/helpers.h +2 -2
index 26caa2c20912..ef0e496bcd93 100644
@@ -299,7 +299,7 @@ static inline void page_pool_ref_page(struct page *page)
 	page_pool_ref_netmem(page_to_netmem(page));
 }
 
-static inline bool page_pool_is_last_ref(netmem_ref netmem)
+static inline bool page_pool_unref_and_test(netmem_ref netmem)
 {
 	/* If page_pool_unref_page() returns 0, we were the last user */
 	return page_pool_unref_netmem(netmem, 1) == 0;
@@ -314,7 +314,7 @@ static inline void page_pool_put_netmem(struct page_pool *pool,
 	 * allow registering MEM_TYPE_PAGE_POOL, but shield linker.
 	 */
 #ifdef CONFIG_PAGE_POOL
-	if (!page_pool_is_last_ref(netmem))
+	if (!page_pool_unref_and_test(netmem))
 		return;
 
 	page_pool_put_unrefed_netmem(pool, netmem, dma_sync_size, allow_direct);
net/core/page_pool.c +1 -1
index 4c85b77cfdac..56efe3f8140b 100644
@@ -867,7 +867,7 @@ void page_pool_put_netmem_bulk(struct page_pool *pool, netmem_ref *data,
 		netmem_ref netmem = netmem_compound_head(data[i]);
 
 		/* It is not the last user for the page frag case */
-		if (!page_pool_is_last_ref(netmem))
+		if (!page_pool_unref_and_test(netmem))
 			continue;
 
 		netmem = __page_pool_put_page(pool, netmem, -1, allow_direct);
Signature · 1 line
2.47.1
Reviewed-by on v1 1/1
#1 lore raw

From: Jakub Kicinski <[email protected]>
Date: Fri, 13 Dec 2024 07:37:59 -0800

Quoted 7 lines

page_pool_is_last_ref() releases a reference while the name, to me at least, suggests it just checks if the refcount is 1. The semantics of the function are the same as those of atomic_dec_and_test() and refcount_dec_and_test(), so just use the _and_test() suffix.

Makes sense to me, I think I had issues in the past with references while developing stuff, as I thought this function doesn't modify anything :D

Quoted 5 lines

---
Hopefully this doesn't conflict with anyone's work, I've been deferring sending this rename forever because I always look at it while reviewing an in-flight series and then I'm worried it will conflict.

Thanks,
Olek

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Jakub Kicinski
Quoted 60 lines · Jakub Kicinski

page_pool_is_last_ref() releases a reference while the name, to me at least, suggests it just checks if the refcount is 1. The semantics of the function are the same as those of atomic_dec_and_test() and refcount_dec_and_test(), so just use the _and_test() suffix.

---
Hopefully this doesn't conflict with anyone's work, I've been deferring sending this rename forever because I always look at it while reviewing an in-flight series and then I'm worried it will conflict.

---
 include/net/page_pool/helpers.h | 4 ++--
 net/core/page_pool.c            | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
include/net/page_pool/helpers.h +2 -2
index 26caa2c20912..ef0e496bcd93 100644
@@ -299,7 +299,7 @@ static inline void page_pool_ref_page(struct page *page)
        page_pool_ref_netmem(page_to_netmem(page));
 }
 
-static inline bool page_pool_is_last_ref(netmem_ref netmem)
+static inline bool page_pool_unref_and_test(netmem_ref netmem)
 {
        /* If page_pool_unref_page() returns 0, we were the last user */
        return page_pool_unref_netmem(netmem, 1) == 0;
@@ -314,7 +314,7 @@ static inline void page_pool_put_netmem(struct page_pool *pool,
         * allow registering MEM_TYPE_PAGE_POOL, but shield linker.
         */
 #ifdef CONFIG_PAGE_POOL
-       if (!page_pool_is_last_ref(netmem))
+       if (!page_pool_unref_and_test(netmem))
                return;
 
        page_pool_put_unrefed_netmem(pool, netmem, dma_sync_size, allow_direct);
net/core/page_pool.c +1 -2
index 4c85b77cfdac..56efe3f8140b 100644
@@ -867,7 +867,7 @@ void page_pool_put_netmem_bulk(struct page_pool *pool, netmem_ref *data,
                netmem_ref netmem = netmem_compound_head(data[i]);
 
                /* It is not the last user for the page frag case */
-               if (!page_pool_is_last_ref(netmem))
+               if (!page_pool_unref_and_test(netmem))
                        continue;
 
                netmem = __page_pool_put_page(pool, netmem, -1, allow_direct);
--
Quoted 2 lines

2.47.1