diff mbox series

[07/13] lightnvm: pblk: Cleanly fail when there is not enough memory

Message ID 20190227171442.11853-8-igor.j.konopko@intel.com (mailing list archive)
State New, archived
Headers show
Series lightnvm: bugfixes and improvements | expand

Commit Message

Igor Konopko Feb. 27, 2019, 5:14 p.m. UTC
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

Signed-off-by: Igor Konopko <igor.j.konopko@intel.com>
---
 drivers/lightnvm/pblk-init.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Javier González March 4, 2019, 7:53 a.m. UTC | #1
> On 27 Feb 2019, at 18.14, Igor Konopko <igor.j.konopko@intel.com> wrote:
> 
> 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
> 
> Signed-off-by: Igor Konopko <igor.j.konopko@intel.com>
> ---
> drivers/lightnvm/pblk-init.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
> index 8b643d0bffae..e553105b7ba1 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)
> 	int ret = 0;
> 
> 	map_size = pblk_trans_map_size(pblk);
> -	pblk->trans_map = vmalloc(map_size);
> -	if (!pblk->trans_map)
> +	pblk->trans_map = __vmalloc(map_size, GFP_KERNEL | __GFP_NOWARN
> +					| __GFP_RETRY_MAYFAIL | __GFP_HIGHMEM,
> +					PAGE_KERNEL);
> +	if (!pblk->trans_map) {
> +		pblk_err(pblk, "failed to allocate L2P (need %ld of memory)\n",
> +				map_size);
> 		return -ENOMEM;
> +	}
> 
> 	pblk_ppa_set_empty(&ppa);
> 
> --
> 2.17.1

Is there any extra consideration we should take when enabling high
memory for the L2P table? If not, looks good to me.

Reviewed-by: Javier González <javier@javigon.com>
Hans Holmberg March 4, 2019, 9:24 a.m. UTC | #2
Hi Igor,

I think you need to motivate (and document) why each of the new flags
are needed.

Thanks,
Hans

On Mon, Mar 4, 2019 at 8:53 AM Javier González <javier@javigon.com> wrote:
>
> > On 27 Feb 2019, at 18.14, Igor Konopko <igor.j.konopko@intel.com> wrote:
> >
> > 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
> >
> > Signed-off-by: Igor Konopko <igor.j.konopko@intel.com>
> > ---
> > drivers/lightnvm/pblk-init.c | 9 +++++++--
> > 1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
> > index 8b643d0bffae..e553105b7ba1 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)
> >       int ret = 0;
> >
> >       map_size = pblk_trans_map_size(pblk);
> > -     pblk->trans_map = vmalloc(map_size);
> > -     if (!pblk->trans_map)
> > +     pblk->trans_map = __vmalloc(map_size, GFP_KERNEL | __GFP_NOWARN
> > +                                     | __GFP_RETRY_MAYFAIL | __GFP_HIGHMEM,
> > +                                     PAGE_KERNEL);
> > +     if (!pblk->trans_map) {
> > +             pblk_err(pblk, "failed to allocate L2P (need %ld of memory)\n",
> > +                             map_size);
> >               return -ENOMEM;
> > +     }
> >
> >       pblk_ppa_set_empty(&ppa);
> >
> > --
> > 2.17.1
>
> Is there any extra consideration we should take when enabling high
> memory for the L2P table? If not, looks good to me.
>
> Reviewed-by: Javier González <javier@javigon.com>
Igor Konopko March 4, 2019, 12:46 p.m. UTC | #3
On 04.03.2019 10:24, Hans Holmberg wrote:
> Hi Igor,
> 
> I think you need to motivate (and document) why each of the new flags
> are needed.

Sure, will add such a description to v2 of the patch.
> 
> Thanks,
> Hans
> 
> On Mon, Mar 4, 2019 at 8:53 AM Javier González <javier@javigon.com> wrote:
>>
>>> On 27 Feb 2019, at 18.14, Igor Konopko <igor.j.konopko@intel.com> wrote:
>>>
>>> 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
>>>
>>> Signed-off-by: Igor Konopko <igor.j.konopko@intel.com>
>>> ---
>>> drivers/lightnvm/pblk-init.c | 9 +++++++--
>>> 1 file changed, 7 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
>>> index 8b643d0bffae..e553105b7ba1 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)
>>>        int ret = 0;
>>>
>>>        map_size = pblk_trans_map_size(pblk);
>>> -     pblk->trans_map = vmalloc(map_size);
>>> -     if (!pblk->trans_map)
>>> +     pblk->trans_map = __vmalloc(map_size, GFP_KERNEL | __GFP_NOWARN
>>> +                                     | __GFP_RETRY_MAYFAIL | __GFP_HIGHMEM,
>>> +                                     PAGE_KERNEL);
>>> +     if (!pblk->trans_map) {
>>> +             pblk_err(pblk, "failed to allocate L2P (need %ld of memory)\n",
>>> +                             map_size);
>>>                return -ENOMEM;
>>> +     }
>>>
>>>        pblk_ppa_set_empty(&ppa);
>>>
>>> --
>>> 2.17.1
>>
>> Is there any extra consideration we should take when enabling high
>> memory for the L2P table? If not, looks good to me.
>>
>> Reviewed-by: Javier González <javier@javigon.com>
diff mbox series

Patch

diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
index 8b643d0bffae..e553105b7ba1 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)
 	int ret = 0;
 
 	map_size = pblk_trans_map_size(pblk);
-	pblk->trans_map = vmalloc(map_size);
-	if (!pblk->trans_map)
+	pblk->trans_map = __vmalloc(map_size, GFP_KERNEL | __GFP_NOWARN
+					| __GFP_RETRY_MAYFAIL | __GFP_HIGHMEM,
+					PAGE_KERNEL);
+	if (!pblk->trans_map) {
+		pblk_err(pblk, "failed to allocate L2P (need %ld of memory)\n",
+				map_size);
 		return -ENOMEM;
+	}
 
 	pblk_ppa_set_empty(&ppa);