Skip to content

Commit

Permalink
samples/bpf: adjust rlimit RLIMIT_MEMLOCK for traceex2, tracex3 and t…
Browse files Browse the repository at this point in the history
…racex4

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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
netoptimizer authored and davem330 committed May 3, 2017
1 parent 89c9fea commit 55de170
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions samples/bpf/tracex2_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <signal.h>
#include <linux/bpf.h>
#include <string.h>
#include <sys/resource.h>

#include "libbpf.h"
#include "bpf_load.h"
Expand Down Expand Up @@ -112,13 +113,19 @@ static void int_exit(int sig)

int main(int ac, char **argv)
{
struct rlimit r = {1024*1024, RLIM_INFINITY};
char filename[256];
long key, next_key, value;
FILE *f;
int i;

snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);

if (setrlimit(RLIMIT_MEMLOCK, &r)) {
perror("setrlimit(RLIMIT_MEMLOCK)");
return 1;
}

signal(SIGINT, int_exit);

/* start 'ping' in the background to have some kfree_skb events */
Expand Down
7 changes: 7 additions & 0 deletions samples/bpf/tracex3_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <stdbool.h>
#include <string.h>
#include <linux/bpf.h>
#include <sys/resource.h>

#include "libbpf.h"
#include "bpf_load.h"
Expand Down Expand Up @@ -112,11 +113,17 @@ static void print_hist(int fd)

int main(int ac, char **argv)
{
struct rlimit r = {1024*1024, RLIM_INFINITY};
char filename[256];
int i;

snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);

if (setrlimit(RLIMIT_MEMLOCK, &r)) {
perror("setrlimit(RLIMIT_MEMLOCK)");
return 1;
}

if (load_bpf_file(filename)) {
printf("%s", bpf_log_buf);
return 1;
Expand Down
8 changes: 8 additions & 0 deletions samples/bpf/tracex4_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include <string.h>
#include <time.h>
#include <linux/bpf.h>
#include <sys/resource.h>

#include "libbpf.h"
#include "bpf_load.h"

Expand Down Expand Up @@ -50,11 +52,17 @@ static void print_old_objects(int fd)

int main(int ac, char **argv)
{
struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
char filename[256];
int i;

snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);

if (setrlimit(RLIMIT_MEMLOCK, &r)) {
perror("setrlimit(RLIMIT_MEMLOCK, RLIM_INFINITY)");
return 1;
}

if (load_bpf_file(filename)) {
printf("%s", bpf_log_buf);
return 1;
Expand Down

0 comments on commit 55de170

Please sign in to comment.