From mboxrd@z Thu Jan 1 00:00:00 1970 From: Quentin Monnet Subject: Re: [PATCH bpf-next] tools: bpftool: adjust rlimit RLIMIT_MEMLOCK when loading programs, maps Date: Wed, 7 Nov 2018 17:03:14 +0000 Message-ID: <642a6b13-8f11-5cc2-80bc-4e7580824ddb@netronome.com> References: <1541593770-28089-1-git-send-email-quentin.monnet@netronome.com> <20181107165943.x6vj5e4qlsym3jub@kafai-mbp.dhcp.thefacebook.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: Alexei Starovoitov , Daniel Borkmann , "netdev@vger.kernel.org" , "oss-drivers@netronome.com" To: Martin Lau Return-path: Received: from mail-wr1-f68.google.com ([209.85.221.68]:37656 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727576AbeKHCec (ORCPT ); Wed, 7 Nov 2018 21:34:32 -0500 Received: by mail-wr1-f68.google.com with SMTP id o15-v6so14573703wrv.4 for ; Wed, 07 Nov 2018 09:03:17 -0800 (PST) In-Reply-To: <20181107165943.x6vj5e4qlsym3jub@kafai-mbp.dhcp.thefacebook.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: 2018-11-07 16:59 UTC+0000 ~ Martin Lau > On Wed, Nov 07, 2018 at 12:29:30PM +0000, Quentin Monnet wrote: >> The limit for memory locked in the kernel by a process is usually set to >> 64 bytes by default. This can be an issue when creating large BPF maps > hmm... 64 _k_bytes? Ouch. That's true. Thanks! I can respin to fix the commit log if needed. >> and/or loading many programs. A workaround is to raise this limit for >> the current process before trying to create a new BPF map. Changing the >> hard limit requires the CAP_SYS_RESOURCE and can usually only be done by >> root user (for non-root users, a call to setrlimit fails (and sets >> errno) and the program simply goes on with its rlimit unchanged). >> >> There is no API to get the current amount of memory locked for a user, >> therefore we cannot raise the limit only when required. One solution, >> used by bcc, is to try to create the map, and on getting a EPERM error, >> raising the limit to infinity before giving another try. Another >> approach, used in iproute2, is to raise the limit in all cases, before >> trying to create the map. >> >> Here we do the same as in iproute2: the rlimit is raised to infinity >> before trying to load programs or to create maps with bpftool. >> >> Signed-off-by: Quentin Monnet >> Reviewed-by: Jakub Kicinski > Patch LGTM. > > Acked-by: Martin KaFai Lau > Thanks for this as well. Quentin