Skip to content

Commit 0544f23

Browse files
tohojokernel-patches-bot
authored andcommitted
samples/bpf: Set rlimit for memlock to infinity in all samples
The memlock rlimit is a notorious source of failure for BPF programs. Most of the samples just set it to infinity, but a few used a lower limit. The problem with unconditionally setting a lower limit is that this will also override the limit if the system-wide setting is *higher* than the limit being set, which can lead to failures on systems that lock a lot of memory, but set 'ulimit -l' to unlimited before running a sample. One fix for this is to only conditionally set the limit if the current limit is lower, but it is simpler to just unify all the samples and have them all set the limit to infinity. Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
1 parent d111a24 commit 0544f23

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

samples/bpf/task_fd_query_user.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ static int test_debug_fs_uprobe(char *binary_path, long offset, bool is_return)
290290

291291
int main(int argc, char **argv)
292292
{
293-
struct rlimit r = {1024*1024, RLIM_INFINITY};
293+
struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
294294
extern char __executable_start;
295295
char filename[256], buf[256];
296296
__u64 uprobe_file_offset;

samples/bpf/tracex2_user.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ static void int_exit(int sig)
116116

117117
int main(int ac, char **argv)
118118
{
119-
struct rlimit r = {1024*1024, RLIM_INFINITY};
119+
struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
120120
long key, next_key, value;
121121
struct bpf_link *links[2];
122122
struct bpf_program *prog;

samples/bpf/tracex3_user.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ static void print_hist(int fd)
107107

108108
int main(int ac, char **argv)
109109
{
110-
struct rlimit r = {1024*1024, RLIM_INFINITY};
110+
struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
111111
struct bpf_link *links[2];
112112
struct bpf_program *prog;
113113
struct bpf_object *obj;

samples/bpf/xdp_redirect_cpu_user.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ static int load_cpumap_prog(char *file_name, char *prog_name,
765765

766766
int main(int argc, char **argv)
767767
{
768-
struct rlimit r = {10 * 1024 * 1024, RLIM_INFINITY};
768+
struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
769769
char *prog_name = "xdp_cpu_map5_lb_hash_ip_pairs";
770770
char *mprog_filename = "xdp_redirect_kern.o";
771771
char *redir_interface = NULL, *redir_map = NULL;

samples/bpf/xdp_rxq_info_user.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ static void stats_poll(int interval, int action, __u32 cfg_opt)
450450
int main(int argc, char **argv)
451451
{
452452
__u32 cfg_options= NO_TOUCH ; /* Default: Don't touch packet memory */
453-
struct rlimit r = {10 * 1024 * 1024, RLIM_INFINITY};
453+
struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
454454
struct bpf_prog_load_attr prog_load_attr = {
455455
.prog_type = BPF_PROG_TYPE_XDP,
456456
};

0 commit comments

Comments
 (0)