mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] rhashtable: Better error message on allocation failure
@ 2023-11-22 23:32 Kent Overstreet
  2023-11-23  8:32 ` Herbert Xu
  0 siblings, 1 reply; 3+ messages in thread
From: Kent Overstreet @ 2023-11-22 23:32 UTC (permalink / raw)
  To: linux-kernel; +Cc: Kent Overstreet, Thomas Graf, Herbert Xu

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.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Cc: Thomas Graf <tgraf@suug.ch>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
---
 lib/rhashtable.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/rhashtable.c b/lib/rhashtable.c
index 6ae2ba8e06a2..d3fce9c8989a 100644
--- a/lib/rhashtable.c
+++ b/lib/rhashtable.c
@@ -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)
-- 
2.42.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] rhashtable: Better error message on allocation failure
  2023-11-22 23:32 [PATCH] rhashtable: Better error message on allocation failure Kent Overstreet
@ 2023-11-23  8:32 ` Herbert Xu
  2023-11-23 23:58   ` Kent Overstreet
  0 siblings, 1 reply; 3+ messages in thread
From: Herbert Xu @ 2023-11-23  8:32 UTC (permalink / raw)
  To: Kent Overstreet; +Cc: linux-kernel, Thomas Graf

On Wed, Nov 22, 2023 at 06:32:16PM -0500, Kent Overstreet wrote:
> 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.
> 
> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
> Cc: Thomas Graf <tgraf@suug.ch>
> Cc: Herbert Xu <herbert@gondor.apana.org.au>
> ---
>  lib/rhashtable.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)

Acked-by: Herbert Xu <herbert@gondor.apana.org.au>

However, you'll need to repost this via netdev@vger.kernel.org for
it to be merged.

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] rhashtable: Better error message on allocation failure
  2023-11-23  8:32 ` Herbert Xu
@ 2023-11-23 23:58   ` Kent Overstreet
  0 siblings, 0 replies; 3+ messages in thread
From: Kent Overstreet @ 2023-11-23 23:58 UTC (permalink / raw)
  To: Herbert Xu; +Cc: linux-kernel, Thomas Graf

On Thu, Nov 23, 2023 at 04:32:47PM +0800, Herbert Xu wrote:
> On Wed, Nov 22, 2023 at 06:32:16PM -0500, Kent Overstreet wrote:
> > 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.
> > 
> > Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
> > Cc: Thomas Graf <tgraf@suug.ch>
> > Cc: Herbert Xu <herbert@gondor.apana.org.au>
> > ---
> >  lib/rhashtable.c | 9 +++++++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
> 
> However, you'll need to repost this via netdev@vger.kernel.org for
> it to be merged.

Thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-11-24  0:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-22 23:32 [PATCH] rhashtable: Better error message on allocation failure Kent Overstreet
2023-11-23  8:32 ` Herbert Xu
2023-11-23 23:58   ` Kent Overstreet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®