]> Git Repo - linux.git/commit
lib/rhashtable: guarantee initial hashtable allocation
authorDavidlohr Bueso <[email protected]>
Wed, 22 Aug 2018 05:01:48 +0000 (22:01 -0700)
committerLinus Torvalds <[email protected]>
Wed, 22 Aug 2018 17:52:52 +0000 (10:52 -0700)
commit2d22ecf6db1c390974476758681ba4229018e774
treea3e555c29ee83f0cff4bfded9355802bc9df0850
parent93f976b5190df32793908d49165f78e67fcb66cf
lib/rhashtable: guarantee initial hashtable allocation

rhashtable_init() may fail due to -ENOMEM, thus making the entire api
unusable.  This patch removes this scenario, however unlikely.  In order
to guarantee memory allocation, this patch always ends up doing
GFP_KERNEL|__GFP_NOFAIL for both the tbl as well as
alloc_bucket_spinlocks().

Upon the first table allocation failure, we shrink the size to the
smallest value that makes sense and retry with __GFP_NOFAIL semantics.
With the defaults, this means that from 64 buckets, we retry with only 4.
Any later issues regarding performance due to collisions or larger table
resizing (when more memory becomes available) is the least of our
problems.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Davidlohr Bueso <[email protected]>
Signed-off-by: Manfred Spraul <[email protected]>
Acked-by: Herbert Xu <[email protected]>
Cc: Dmitry Vyukov <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Michael Kerrisk <[email protected]>
Cc: Michal Hocko <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
lib/rhashtable.c
This page took 0.052652 seconds and 4 git commands to generate.