diff options
Diffstat (limited to 'tools/lib/bpf/libbpf.c')
| -rw-r--r-- | tools/lib/bpf/libbpf.c | 47 | 
1 files changed, 9 insertions, 38 deletions
| diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index c6d84b01a59e..684c34ce1a26 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -187,42 +187,6 @@ const char *libbpf_version_string(void)  #undef __S  } -enum kern_feature_id { -	/* v4.14: kernel support for program & map names. */ -	FEAT_PROG_NAME, -	/* v5.2: kernel support for global data sections. */ -	FEAT_GLOBAL_DATA, -	/* BTF support */ -	FEAT_BTF, -	/* BTF_KIND_FUNC and BTF_KIND_FUNC_PROTO support */ -	FEAT_BTF_FUNC, -	/* BTF_KIND_VAR and BTF_KIND_DATASEC support */ -	FEAT_BTF_DATASEC, -	/* BTF_FUNC_GLOBAL is supported */ -	FEAT_BTF_GLOBAL_FUNC, -	/* BPF_F_MMAPABLE is supported for arrays */ -	FEAT_ARRAY_MMAP, -	/* kernel support for expected_attach_type in BPF_PROG_LOAD */ -	FEAT_EXP_ATTACH_TYPE, -	/* bpf_probe_read_{kernel,user}[_str] helpers */ -	FEAT_PROBE_READ_KERN, -	/* BPF_PROG_BIND_MAP is supported */ -	FEAT_PROG_BIND_MAP, -	/* Kernel support for module BTFs */ -	FEAT_MODULE_BTF, -	/* BTF_KIND_FLOAT support */ -	FEAT_BTF_FLOAT, -	/* BPF perf link support */ -	FEAT_PERF_LINK, -	/* BTF_KIND_DECL_TAG support */ -	FEAT_BTF_DECL_TAG, -	/* BTF_KIND_TYPE_TAG support */ -	FEAT_BTF_TYPE_TAG, -	__FEAT_CNT, -}; - -static bool kernel_supports(const struct bpf_object *obj, enum kern_feature_id feat_id); -  enum reloc_type {  	RELO_LD64,  	RELO_CALL, @@ -4352,6 +4316,10 @@ bpf_object__probe_loading(struct bpf_object *obj)  	if (obj->gen_loader)  		return 0; +	ret = bump_rlimit_memlock(); +	if (ret) +		pr_warn("Failed to bump RLIMIT_MEMLOCK (err = %d), you might need to do it explicitly!\n", ret); +  	/* make sure basic loading works */  	ret = bpf_prog_load(BPF_PROG_TYPE_SOCKET_FILTER, NULL, "GPL", insns, insn_cnt, NULL);  	if (ret < 0) @@ -4718,14 +4686,17 @@ static struct kern_feature_desc {  	[FEAT_BTF_TYPE_TAG] = {  		"BTF_KIND_TYPE_TAG support", probe_kern_btf_type_tag,  	}, +	[FEAT_MEMCG_ACCOUNT] = { +		"memcg-based memory accounting", probe_memcg_account, +	},  }; -static bool kernel_supports(const struct bpf_object *obj, enum kern_feature_id feat_id) +bool kernel_supports(const struct bpf_object *obj, enum kern_feature_id feat_id)  {  	struct kern_feature_desc *feat = &feature_probes[feat_id];  	int ret; -	if (obj->gen_loader) +	if (obj && obj->gen_loader)  		/* To generate loader program assume the latest kernel  		 * to avoid doing extra prog_load, map_create syscalls.  		 */ | 
