diff options
author | Davidlohr Bueso <dave@stgolabs.net> | 2018-08-22 01:01:45 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-22 13:52:52 -0400 |
commit | 93f976b5190df32793908d49165f78e67fcb66cf (patch) | |
tree | 1ea0ab13c02e21d479ecdc2118f27769cd9cbd5d /lib | |
parent | 82061c57ce93caa50fd01c11f8eb30ddc4c4bd75 (diff) |
lib/rhashtable: simplify bucket_table_alloc()
As of ce91f6ee5b3b ("mm: kvmalloc does not fallback to vmalloc for
incompatible gfp flags") we can simplify the caller and trust kvzalloc()
to just do the right thing. For the case of the GFP_ATOMIC context, we
can drop the __GFP_NORETRY flag for obvious reasons, and for the
__GFP_NOWARN case, however, it is changed such that the caller passes the
flag instead of making bucket_table_alloc() handle it.
This slightly changes the gfp flags passed on to nested_table_alloc() as
it will now also use GFP_ATOMIC | __GFP_NOWARN. However, I consider this
a positive consequence as for the same reasons we want nowarn semantics in
bucket_table_alloc().
[manfred@colorfullife.com: commit id extended to 12 digits, line wraps updated]
Link: http://lkml.kernel.org/r/20180712185241.4017-8-manfred@colorfullife.com
Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
Signed-off-by: Manfred Spraul <manfred@colorfullife.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Kees Cook <keescook@chromium.org>
Cc: Michael Kerrisk <mtk.manpages@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rhashtable.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/rhashtable.c b/lib/rhashtable.c index ae4223e0f5bc..238c8daa9852 100644 --- a/lib/rhashtable.c +++ b/lib/rhashtable.c | |||
@@ -174,10 +174,7 @@ static struct bucket_table *bucket_table_alloc(struct rhashtable *ht, | |||
174 | int i; | 174 | int i; |
175 | 175 | ||
176 | size = sizeof(*tbl) + nbuckets * sizeof(tbl->buckets[0]); | 176 | size = sizeof(*tbl) + nbuckets * sizeof(tbl->buckets[0]); |
177 | if (gfp != GFP_KERNEL) | 177 | tbl = kvzalloc(size, gfp); |
178 | tbl = kzalloc(size, gfp | __GFP_NOWARN | __GFP_NORETRY); | ||
179 | else | ||
180 | tbl = kvzalloc(size, gfp); | ||
181 | 178 | ||
182 | size = nbuckets; | 179 | size = nbuckets; |
183 | 180 | ||
@@ -450,7 +447,7 @@ static int rhashtable_insert_rehash(struct rhashtable *ht, | |||
450 | 447 | ||
451 | err = -ENOMEM; | 448 | err = -ENOMEM; |
452 | 449 | ||
453 | new_tbl = bucket_table_alloc(ht, size, GFP_ATOMIC); | 450 | new_tbl = bucket_table_alloc(ht, size, GFP_ATOMIC | __GFP_NOWARN); |
454 | if (new_tbl == NULL) | 451 | if (new_tbl == NULL) |
455 | goto fail; | 452 | goto fail; |
456 | 453 | ||