netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Graf <tgraf@suug.ch>
To: davem@davemloft.net
Cc: herbert@gondor.apana.org.au, kaber@trash.net, netdev@vger.kernel.org
Subject: [PATCH net 1/2] rhashtable: Schedule async resize when sync realloc fails
Date: Tue, 21 Apr 2015 14:55:34 +0200	[thread overview]
Message-ID: <4f55f5c9abd6b09ed44f0da3f0e72a10040e8278.1429620438.git.tgraf@suug.ch> (raw)
In-Reply-To: <cover.1429620438.git.tgraf@suug.ch>
In-Reply-To: <cover.1429620438.git.tgraf@suug.ch>

When rhashtable_insert_rehash() fails with ENOMEM, this indicates that
we can't allocate the necessary memory in the current context but the
limits as set by the user would still allow to grow.

Thus attempt an async resize in the background where we can allocate
using GFP_KERNEL which is more likely to succeed. The insertion itself
will still fail to indicate pressure.

This fixes a bug where the table would never continue growing once the
utilization is above 100%.

Fixes: ccd57b1bd324 ("rhashtable: Add immediate rehash during insertion")
Signed-off-by: Thomas Graf <tgraf@suug.ch>
---
 include/linux/rhashtable.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/rhashtable.h b/include/linux/rhashtable.h
index e23d242..7040b5c 100644
--- a/include/linux/rhashtable.h
+++ b/include/linux/rhashtable.h
@@ -593,6 +593,8 @@ slow_path:
 		spin_unlock_bh(lock);
 		err = rhashtable_insert_rehash(ht);
 		rcu_read_unlock();
+		if (err == -ENOMEM)
+			schedule_work(&ht->run_work);
 		if (err)
 			return err;
 
-- 
2.3.5

  reply	other threads:[~2015-04-21 12:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-21 12:55 [PATCH net 0/2] rhashtable rehashing fixes Thomas Graf
2015-04-21 12:55 ` Thomas Graf [this message]
2015-04-22  0:36   ` [PATCH net 1/2] rhashtable: Schedule async resize when sync realloc fails Herbert Xu
2015-04-22  2:10     ` David Miller
2015-04-22  7:18       ` Thomas Graf
2015-04-21 12:55 ` [PATCH net 2/2] rhashtable: Do not schedule more than one rehash if we can't grow further Thomas Graf
2015-04-22  0:37   ` Herbert Xu
  -- strict thread matches above, loose matches on Subject: below --
2015-04-22  7:41 [PATCH net 0/2 v2] rhashtable rehashing fixes Thomas Graf
2015-04-22  7:41 ` [PATCH net 1/2] rhashtable: Schedule async resize when sync realloc fails Thomas Graf
2015-04-22  7:43   ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4f55f5c9abd6b09ed44f0da3f0e72a10040e8278.1429620438.git.tgraf@suug.ch \
    --to=tgraf@suug.ch \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=kaber@trash.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).