Skip to contentSkip to conversation

lib/rhashtable: cleanup fallback check in bucket_table_alloc()

PATCH Applied Davidlohr Bueso 2 participants 2 messages Aug 6, 2024 – Aug 9, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/rhashtable: cleanup fallback check in bucket_table_alloc()

Upon allocation failure, the current check with the nofail bits is unnecessary, and further stands in the way of discouraging direct use of __GFP_NOFAIL. Remove this and replace with the proper way of determining if doing a non-blocking allocation for the nested table case.

---
 lib/rhashtable.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/rhashtable.c +1 -1
index dbbed19f8fff..6c902639728b 100644
@@ -189,7 +189,7 @@ static struct bucket_table *bucket_table_alloc(struct rhashtable *ht,
 
 	size = nbuckets;
 
-	if (tbl == NULL && (gfp & ~__GFP_NOFAIL) != GFP_KERNEL) {
+	if (tbl == NULL && !gfpflags_allow_blocking(gfp)) {
 		tbl = nested_bucket_table_alloc(ht, nbuckets, gfp);
 		nbuckets = 0;
 	}
Signature · 1 line
2.45.2
#1 lore raw
Quoted 8 lines · Davidlohr Bueso

Upon allocation failure, the current check with the nofail bits is unnecessary, and further stands in the way of discouraging direct use of __GFP_NOFAIL. Remove this and replace with the proper way of determining if doing a non-blocking allocation for the nested table case.

Thanks. This is not really something I feel qualified to ack but the change looks good to me.

Quoted 19 lines
---
 lib/rhashtable.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/rhashtable.c +1 -1
index dbbed19f8fff..6c902639728b 100644
@@ -189,7 +189,7 @@ static struct bucket_table *bucket_table_alloc(struct rhashtable *ht,
 
 	size = nbuckets;
 
-	if (tbl == NULL && (gfp & ~__GFP_NOFAIL) != GFP_KERNEL) {
+	if (tbl == NULL && !gfpflags_allow_blocking(gfp)) {
 		tbl = nested_bucket_table_alloc(ht, nbuckets, gfp);
 		nbuckets = 0;
 	}
Signature · 1 line
2.45.2
Signature · 2 lines
Michal Hocko
SUSE Labs