mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
tools/runqslower: Use libbpf 1.0 API mode instead of RLIMIT_MEMLOCK
Explicitly set libbpf 1.0 API mode, then we can avoid using the deprecated RLIMIT_MEMLOCK. Signed-off-by: Yafang Shao <laoar.shao@gmail.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20220409125958.92629-5-laoar.shao@gmail.com
This commit is contained in:
parent
a777e18f1b
commit
451b5fbc2c
1 changed files with 2 additions and 16 deletions
|
@ -4,7 +4,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/resource.h>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <bpf/libbpf.h>
|
#include <bpf/libbpf.h>
|
||||||
#include <bpf/bpf.h>
|
#include <bpf/bpf.h>
|
||||||
|
@ -88,16 +87,6 @@ int libbpf_print_fn(enum libbpf_print_level level,
|
||||||
return vfprintf(stderr, format, args);
|
return vfprintf(stderr, format, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bump_memlock_rlimit(void)
|
|
||||||
{
|
|
||||||
struct rlimit rlim_new = {
|
|
||||||
.rlim_cur = RLIM_INFINITY,
|
|
||||||
.rlim_max = RLIM_INFINITY,
|
|
||||||
};
|
|
||||||
|
|
||||||
return setrlimit(RLIMIT_MEMLOCK, &rlim_new);
|
|
||||||
}
|
|
||||||
|
|
||||||
void handle_event(void *ctx, int cpu, void *data, __u32 data_sz)
|
void handle_event(void *ctx, int cpu, void *data, __u32 data_sz)
|
||||||
{
|
{
|
||||||
const struct runq_event *e = data;
|
const struct runq_event *e = data;
|
||||||
|
@ -133,11 +122,8 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
libbpf_set_print(libbpf_print_fn);
|
libbpf_set_print(libbpf_print_fn);
|
||||||
|
|
||||||
err = bump_memlock_rlimit();
|
/* Use libbpf 1.0 API mode */
|
||||||
if (err) {
|
libbpf_set_strict_mode(LIBBPF_STRICT_ALL);
|
||||||
fprintf(stderr, "failed to increase rlimit: %d", err);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
obj = runqslower_bpf__open();
|
obj = runqslower_bpf__open();
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue