[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d033db53-129d-c031-db78-ba7f9fed5bf4@yandex-team.ru>
Date: Mon, 5 Nov 2018 19:19:28 +0300
From: Konstantin Khlebnikov <khlebnikov@...dex-team.ru>
To: Vlastimil Babka <vbabka@...e.cz>, linux-mm@...ck.org,
Andrew Morton <akpm@...ux-foundation.org>,
Michal Hocko <mhocko@...e.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2] mm/kvmalloc: do not call kmalloc for size >
KMALLOC_MAX_SIZE
On 05.11.2018 16:03, Vlastimil Babka wrote:
> On 11/1/18 11:09 AM, Konstantin Khlebnikov wrote:
>> Allocations over KMALLOC_MAX_SIZE could be served only by vmalloc.
>>
>> Signed-off-by: Konstantin Khlebnikov <khlebnikov@...dex-team.ru>
>
> Makes sense regardless of warnings stuff.
>
> Acked-by: Vlastimil Babka <vbabka@...e.cz>
>
> But it must be moved below the GFP_KERNEL check!
But kmalloc cannot handle it regardless of GFP.
Ok maybe write something like this
if (size > KMALLOC_MAX_SIZE) {
if (WARN_ON_ONCE((flags & GFP_KERNEL) != GFP_KERNEL)
return NULL;
goto do_vmalloc;
}
or fix that uncertainty right in vmalloc
For now comment in vmalloc declares
* Any use of gfp flags outside of GFP_KERNEL should be consulted
* with mm people.
=)
>
>> ---
>> mm/util.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/mm/util.c b/mm/util.c
>> index 8bf08b5b5760..f5f04fa22814 100644
>> --- a/mm/util.c
>> +++ b/mm/util.c
>> @@ -392,6 +392,9 @@ void *kvmalloc_node(size_t size, gfp_t flags, int node)
>> gfp_t kmalloc_flags = flags;
>> void *ret;
>>
>> + if (size > KMALLOC_MAX_SIZE)
>> + goto fallback;
>> +
>> /*
>> * vmalloc uses GFP_KERNEL for some internal allocations (e.g page tables)
>> * so the given set of flags has to be compatible.
>> @@ -422,6 +425,7 @@ void *kvmalloc_node(size_t size, gfp_t flags, int node)
>> if (ret || size <= PAGE_SIZE)
>> return ret;
>>
>> +fallback:
>> return __vmalloc_node_flags_caller(size, node, flags,
>> __builtin_return_address(0));
>> }
>>
>
Powered by blists - more mailing lists