diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-12-30 20:26:09 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2022-01-01 21:14:28 -0500 |
commit | 617dc6dd68f9fc4a65334de6ad499be29fcdaba4 (patch) | |
tree | cb877fb1d68d21dc8f9ce25b79ef55b0d4d895a7 /include/linux/vmalloc.h | |
parent | a6390a80126b9a16406d2a6de31778abd652844d (diff) |
Retry memory allocation failures
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'include/linux/vmalloc.h')
-rw-r--r-- | include/linux/vmalloc.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index c674d9a2..ccb319eb 100644 --- a/include/linux/vmalloc.h +++ b/include/linux/vmalloc.h @@ -14,18 +14,18 @@ static inline void *__vmalloc(unsigned long size, gfp_t gfp_mask) { + unsigned i = 0; void *p; size = round_up(size, PAGE_SIZE); - run_shrinkers(); + do { + run_shrinkers(); - p = aligned_alloc(PAGE_SIZE, size); - if (!p) - return NULL; - - if (gfp_mask & __GFP_ZERO) - memset(p, 0, size); + p = aligned_alloc(PAGE_SIZE, size); + if (p && gfp_mask & __GFP_ZERO) + memset(p, 0, size); + } while (!p && i++ < 10); return p; } |