lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <efeee51e-bb64-333d-7091-5c768c13e5e9@iogearbox.net>
Date:   Mon, 18 Mar 2019 16:52:02 +0100
From:   Daniel Borkmann <daniel@...earbox.net>
To:     Michal Hocko <mhocko@...nel.org>, Martynas Pumputis <m@...bda.lt>
Cc:     netdev@...r.kernel.org, bpf@...r.kernel.org, ast@...nel.org,
        Yonghong Song <yhs@...com>
Subject: Re: [PATCH v3 bpf] bpf: Try harder when allocating memory for large
 maps

On 03/18/2019 04:39 PM, Michal Hocko wrote:
> On Mon 18-03-19 16:10:26, Martynas Pumputis wrote:
>> It has been observed that sometimes a higher order memory allocation
>> for BPF maps fails when there is no obvious memory pressure in a system.
>>
>> E.g. the map (BPF_MAP_TYPE_LRU_HASH, key=38, value=56, max_elems=524288)
>> could not be created due to vmalloc unable to allocate 75497472B,
>> when the system's memory consumption (in MB) was the following:
>>
>>     Total: 3942 Used: 837 (21.24%) Free: 138 Buffers: 239 Cached: 2727
>>
>> Later analysis [1] by Michal Hocko showed that the vmalloc was not trying
>> to reclaim memory from the page cache and was failing prematurely due to
>> __GFP_NORETRY.
>>
>> Considering dcda9b0471 ("mm, tree wide: replace __GFP_REPEAT by
>> __GFP_RETRY_MAYFAIL with more useful semantic") and [1], we can replace
>> __GFP_NORETRY with __GFP_RETRY_MAYFAIL, as it won't invoke OOM killer
>> and will try harder to fulfil allocation requests.
>>
>> Unfortunately, replacing the body of the BPF map memory allocation
>> function with the kvmalloc_node helper function is not an option at this
>> point in time, given 1) kmalloc is non-optional for higher order
>> allocations, and 2) passing __GFP_RETRY_MAYFAIL to the kmalloc would stress
>> the slab allocator too much for large requests.
> 
> Thanks for extending the changelog!
> 
>> The change has been tested with the workloads mentioned above and by
>> observing oom_kill value from /proc/vmstat.
>>
>> [1]: https://lore.kernel.org/bpf/20190310071318.GW5232@dhcp22.suse.cz/
>>
>> Acked-by: Yonghong Song <yhs@...com>
>> Signed-off-by: Martynas Pumputis <m@...bda.lt>
> 
> The patch looks good to me from the allocator usage POV. I wish there
> was a good way to give you a util function to use rather than opencoding
> but this is the only place with this semantic I have seen and I am not
> sure it is generic enough. Let's see what the future has to tell us.

+1, and thanks for your review. Applied to bpf, thanks everyone!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ