From: Jesper Dangaard Brouer <brouer@redhat.com>
To: netdev@vger.kernel.org, Andy Gospodarek <andy@greyhouse.net>
Cc: Daniel Borkmann <borkmann@iogearbox.net>,
Alexei Starovoitov <alexei.starovoitov@gmail.com>,
Jesper Dangaard Brouer <brouer@redhat.com>
Subject: [net-next PATCH 3/3] samples/bpf: xdp_monitor increase memory rlimit
Date: Fri, 06 Oct 2017 10:41:51 +0200 [thread overview]
Message-ID: <150727931167.4460.6190697015268732941.stgit@firesoul> (raw)
In-Reply-To: <150727927390.4460.3200093291677318710.stgit@firesoul>
Other concurrent running programs, like perf or the XDP program what
needed to be monitored, might take up part of the max locked memory
limit. Thus, the xdp_monitor tool have to set the RLIMIT_MEMLOCK to
RLIM_INFINITY, as it cannot determine a more sane limit.
Using the man exit(3) specified EXIT_FAILURE return exit code, and
correct other users too.
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
---
samples/bpf/xdp_monitor_user.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/samples/bpf/xdp_monitor_user.c b/samples/bpf/xdp_monitor_user.c
index 97c3456c11b2..eaba165b3549 100644
--- a/samples/bpf/xdp_monitor_user.c
+++ b/samples/bpf/xdp_monitor_user.c
@@ -20,6 +20,7 @@ static const char *__doc_err_only__=
#include <unistd.h>
#include <locale.h>
+#include <sys/resource.h>
#include <getopt.h>
#include <net/if.h>
#include <time.h>
@@ -295,6 +296,7 @@ static void print_bpf_prog_info(void)
int main(int argc, char **argv)
{
+ struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
int longindex = 0, opt;
int ret = EXIT_SUCCESS;
char bpf_obj_file[256];
@@ -325,13 +327,18 @@ int main(int argc, char **argv)
}
}
+ if (setrlimit(RLIMIT_MEMLOCK, &r)) {
+ perror("setrlimit(RLIMIT_MEMLOCK)");
+ return EXIT_FAILURE;
+ }
+
if (load_bpf_file(bpf_obj_file)) {
printf("ERROR - bpf_log_buf: %s", bpf_log_buf);
- return 1;
+ return EXIT_FAILURE;
}
if (!prog_fd[0]) {
printf("ERROR - load_bpf_file: %s\n", strerror(errno));
- return 1;
+ return EXIT_FAILURE;
}
if (debug) {
next prev parent reply other threads:[~2017-10-06 8:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-06 8:41 [net-next PATCH 0/3] Improve xdp_monitor samples/bpf Jesper Dangaard Brouer
2017-10-06 8:41 ` [net-next PATCH 1/3] samples/bpf: xdp_monitor first 8 bytes are not accessible by bpf Jesper Dangaard Brouer
2017-10-06 16:13 ` Alexei Starovoitov
2017-10-06 8:41 ` [net-next PATCH 2/3] samples/bpf: xdp_monitor also record xdp_exception tracepoint Jesper Dangaard Brouer
2017-10-06 8:41 ` Jesper Dangaard Brouer [this message]
2017-10-06 17:10 ` [net-next PATCH 0/3] Improve xdp_monitor samples/bpf David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=150727931167.4460.6190697015268732941.stgit@firesoul \
--to=brouer@redhat.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andy@greyhouse.net \
--cc=borkmann@iogearbox.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox