aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/lightnvm/pblk-init.c
diff options
context:
space:
mode:
authorIgor Konopko <igor.j.konopko@intel.com>2019-05-04 14:37:53 -0400
committerJens Axboe <axboe@kernel.dk>2019-05-06 12:19:17 -0400
commit6e46b8b24ffbc4ecb5b606094dbc8ed5d6281f59 (patch)
tree4216e3f6367e9162c0b9cf87d01a6ed8dad854c5 /drivers/lightnvm/pblk-init.c
parent75c89bef6a54943ea0053dc3d27479edfb31b699 (diff)
lightnvm: pblk: cleanly fail when there is not enough memory
L2P table can be huge in many cases, since it typically requires 1GB of DRAM for 1TB of drive. When there is not enough memory available, OOM killer turns on and kills random processes, which can be very annoying for users. This patch changes the flag for L2P table allocation on order to handle this situation in more user friendly way. GFP_KERNEL and __GPF_HIGHMEM are default flags used in parameterless vmalloc() calls, so they are also keeped in that patch. Additionally __GFP_NOWARN flag is added in order to hide very long dmesg warn in case of the allocation failures. The most important flag introduced in that patch is __GFP_RETRY_MAYFAIL, which would cause allocator to try use free memory and if not available to drop caches, but not to run OOM killer. Signed-off-by: Igor Konopko <igor.j.konopko@intel.com> Reviewed-by: Hans Holmberg <hans.holmberg@cnexlabs.com> Reviewed-by: Javier González <javier@javigon.com> Signed-off-by: Matias Bjørling <mb@lightnvm.io> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/lightnvm/pblk-init.c')
-rw-r--r--drivers/lightnvm/pblk-init.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
index 81e8ed4d31ea..e0df3de1ce83 100644
--- a/drivers/lightnvm/pblk-init.c
+++ b/drivers/lightnvm/pblk-init.c
@@ -164,9 +164,14 @@ static int pblk_l2p_init(struct pblk *pblk, bool factory_init)
164 int ret = 0; 164 int ret = 0;
165 165
166 map_size = pblk_trans_map_size(pblk); 166 map_size = pblk_trans_map_size(pblk);
167 pblk->trans_map = vmalloc(map_size); 167 pblk->trans_map = __vmalloc(map_size, GFP_KERNEL | __GFP_NOWARN
168 if (!pblk->trans_map) 168 | __GFP_RETRY_MAYFAIL | __GFP_HIGHMEM,
169 PAGE_KERNEL);
170 if (!pblk->trans_map) {
171 pblk_err(pblk, "failed to allocate L2P (need %zu of memory)\n",
172 map_size);
169 return -ENOMEM; 173 return -ENOMEM;
174 }
170 175
171 pblk_ppa_set_empty(&ppa); 176 pblk_ppa_set_empty(&ppa);
172 177