Skip to contentSkip to conversation

rhashtable: Better error message on allocation failure

PATCH In review Kent Overstreet 2 participants 3 messages Nov 22, 2023 – Nov 24, 2023

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

PATCH 1/1 rhashtable: Better error message on allocation failure

Memory allocation failures print backtraces by default, but when we're running out of a rhashtable worker the backtrace is useless - it doesn't tell us which hashtable the allocation failure was for.

This adds a dedicated warning that prints out functions from the rhashtable params, which will be a bit more useful.

---
 lib/rhashtable.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
lib/rhashtable.c +7 -2
index 6ae2ba8e06a2..d3fce9c8989a 100644
@@ -360,9 +360,14 @@ static int rhashtable_rehash_alloc(struct rhashtable *ht,
 
 	ASSERT_RHT_MUTEX(ht);
 
-	new_tbl = bucket_table_alloc(ht, size, GFP_KERNEL);
-	if (new_tbl == NULL)
+	new_tbl = bucket_table_alloc(ht, size, GFP_KERNEL|__GFP_NOWARN);
+	if (new_tbl == NULL) {
+		WARN("rhashtable bucket table allocation failure for %ps",
+		     (void *) ht->p.hashfn ?:
+		     (void *) ht->p.obj_hashfn ?:
+		     (void *) ht->p.obj_cmpfn);
 		return -ENOMEM;
+	}
 
 	err = rhashtable_rehash_attach(ht, old_tbl, new_tbl);
 	if (err)
Signature · 1 line
2.42.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Kent Overstreet

Memory allocation failures print backtraces by default, but when we're running out of a rhashtable worker the backtrace is useless - it doesn't tell us which hashtable the allocation failure was for.

This adds a dedicated warning that prints out functions from the rhashtable params, which will be a bit more useful.

Quoted 6 lines
---
 lib/rhashtable.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

However, you'll need to repost this via [email protected] for it to be merged.

Thanks,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#2 lore raw
Quoted 15 lines · Herbert Xu
Quoted 7 lines · Kent Overstreet

Memory allocation failures print backtraces by default, but when we're running out of a rhashtable worker the backtrace is useless - it doesn't tell us which hashtable the allocation failure was for.

This adds a dedicated warning that prints out functions from the rhashtable params, which will be a bit more useful.

Quoted 6 lines
---
 lib/rhashtable.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
Quoted 4 lines

However, you'll need to repost this via [email protected] for it to be merged.

Thanks!