From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Fastabend Subject: [bpf-next PATCH v2 7/7] bpf: sockmap set rlimit Date: Wed, 10 Jan 2018 10:40:43 -0800 Message-ID: <20180110184043.5930.91692.stgit@john-Precision-Tower-5810> References: <20180110183600.5930.68261.stgit@john-Precision-Tower-5810> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org To: borkmann@iogearbox.net, john.fastabend@gmail.com, ast@kernel.org Return-path: Received: from mail-pg0-f65.google.com ([74.125.83.65]:46965 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752596AbeAJSkx (ORCPT ); Wed, 10 Jan 2018 13:40:53 -0500 Received: by mail-pg0-f65.google.com with SMTP id r2so11543092pgq.13 for ; Wed, 10 Jan 2018 10:40:53 -0800 (PST) In-Reply-To: <20180110183600.5930.68261.stgit@john-Precision-Tower-5810> Sender: netdev-owner@vger.kernel.org List-ID: Avoid extra step of setting limit from cmdline and do it directly in the program. Signed-off-by: John Fastabend --- samples/sockmap/sockmap_user.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/samples/sockmap/sockmap_user.c b/samples/sockmap/sockmap_user.c index 9496b2c..16c19c5 100644 --- a/samples/sockmap/sockmap_user.c +++ b/samples/sockmap/sockmap_user.c @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -437,6 +438,7 @@ enum { int main(int argc, char **argv) { int iov_count = 1, length = 1024, rate = 1, verbose = 0; + struct rlimit r = {10 * 1024 * 1024, RLIM_INFINITY}; int opt, longindex, err, cg_fd = 0; int test = PING_PONG; char filename[256]; @@ -490,6 +492,11 @@ int main(int argc, char **argv) return -1; } + if (setrlimit(RLIMIT_MEMLOCK, &r)) { + perror("setrlimit(RLIMIT_MEMLOCK)"); + return 1; + } + snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]); running = 1;