summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesper Dangaard Brouer <brouer@redhat.com>2017-05-02 08:31:50 -0400
committerDavid S. Miller <davem@davemloft.net>2017-05-03 09:30:23 -0400
commit55de170382a92d6da6fc9f23efc21eb2f3d25126 (patch)
treefcb84ec0ae4fac1fcc8e40f0e68be42dba784868
parent89c9fea3c8034cdb2fd745f551cde0b507fd6893 (diff)
samples/bpf: adjust rlimit RLIMIT_MEMLOCK for traceex2, tracex3 and tracex4
Needed to adjust max locked memory RLIMIT_MEMLOCK for testing these bpf samples as these are using more and larger maps than can fit in distro default 64Kbytes limit. Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--samples/bpf/tracex2_user.c7
-rw-r--r--samples/bpf/tracex3_user.c7
-rw-r--r--samples/bpf/tracex4_user.c8
3 files changed, 22 insertions, 0 deletions
diff --git a/samples/bpf/tracex2_user.c b/samples/bpf/tracex2_user.c
index ded9804c5034..7fee0f1ba9a3 100644
--- a/samples/bpf/tracex2_user.c
+++ b/samples/bpf/tracex2_user.c
@@ -4,6 +4,7 @@
4#include <signal.h> 4#include <signal.h>
5#include <linux/bpf.h> 5#include <linux/bpf.h>
6#include <string.h> 6#include <string.h>
7#include <sys/resource.h>
7 8
8#include "libbpf.h" 9#include "libbpf.h"
9#include "bpf_load.h" 10#include "bpf_load.h"
@@ -112,6 +113,7 @@ static void int_exit(int sig)
112 113
113int main(int ac, char **argv) 114int main(int ac, char **argv)
114{ 115{
116 struct rlimit r = {1024*1024, RLIM_INFINITY};
115 char filename[256]; 117 char filename[256];
116 long key, next_key, value; 118 long key, next_key, value;
117 FILE *f; 119 FILE *f;
@@ -119,6 +121,11 @@ int main(int ac, char **argv)
119 121
120 snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]); 122 snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
121 123
124 if (setrlimit(RLIMIT_MEMLOCK, &r)) {
125 perror("setrlimit(RLIMIT_MEMLOCK)");
126 return 1;
127 }
128
122 signal(SIGINT, int_exit); 129 signal(SIGINT, int_exit);
123 130
124 /* start 'ping' in the background to have some kfree_skb events */ 131 /* start 'ping' in the background to have some kfree_skb events */
diff --git a/samples/bpf/tracex3_user.c b/samples/bpf/tracex3_user.c
index 8f7d199d5945..fe372239d505 100644
--- a/samples/bpf/tracex3_user.c
+++ b/samples/bpf/tracex3_user.c
@@ -11,6 +11,7 @@
11#include <stdbool.h> 11#include <stdbool.h>
12#include <string.h> 12#include <string.h>
13#include <linux/bpf.h> 13#include <linux/bpf.h>
14#include <sys/resource.h>
14 15
15#include "libbpf.h" 16#include "libbpf.h"
16#include "bpf_load.h" 17#include "bpf_load.h"
@@ -112,11 +113,17 @@ static void print_hist(int fd)
112 113
113int main(int ac, char **argv) 114int main(int ac, char **argv)
114{ 115{
116 struct rlimit r = {1024*1024, RLIM_INFINITY};
115 char filename[256]; 117 char filename[256];
116 int i; 118 int i;
117 119
118 snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]); 120 snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
119 121
122 if (setrlimit(RLIMIT_MEMLOCK, &r)) {
123 perror("setrlimit(RLIMIT_MEMLOCK)");
124 return 1;
125 }
126
120 if (load_bpf_file(filename)) { 127 if (load_bpf_file(filename)) {
121 printf("%s", bpf_log_buf); 128 printf("%s", bpf_log_buf);
122 return 1; 129 return 1;
diff --git a/samples/bpf/tracex4_user.c b/samples/bpf/tracex4_user.c
index 03449f773cb1..22c644f1f4c3 100644
--- a/samples/bpf/tracex4_user.c
+++ b/samples/bpf/tracex4_user.c
@@ -12,6 +12,8 @@
12#include <string.h> 12#include <string.h>
13#include <time.h> 13#include <time.h>
14#include <linux/bpf.h> 14#include <linux/bpf.h>
15#include <sys/resource.h>
16
15#include "libbpf.h" 17#include "libbpf.h"
16#include "bpf_load.h" 18#include "bpf_load.h"
17 19
@@ -50,11 +52,17 @@ static void print_old_objects(int fd)
50 52
51int main(int ac, char **argv) 53int main(int ac, char **argv)
52{ 54{
55 struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
53 char filename[256]; 56 char filename[256];
54 int i; 57 int i;
55 58
56 snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]); 59 snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
57 60
61 if (setrlimit(RLIMIT_MEMLOCK, &r)) {
62 perror("setrlimit(RLIMIT_MEMLOCK, RLIM_INFINITY)");
63 return 1;
64 }
65
58 if (load_bpf_file(filename)) { 66 if (load_bpf_file(filename)) {
59 printf("%s", bpf_log_buf); 67 printf("%s", bpf_log_buf);
60 return 1; 68 return 1;