lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YmLf3PQ9ws2C/Myu@kernel.org>
Date:   Fri, 22 Apr 2022 14:03:24 -0300
From:   Arnaldo Carvalho de Melo <acme@...nel.org>
To:     Jiri Olsa <jolsa@...nel.org>
Cc:     Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Andrii Nakryiko <andrii@...nel.org>,
        linux-perf-users@...r.kernel.org, netdev@...r.kernel.org,
        bpf@...r.kernel.org, Ingo Molnar <mingo@...nel.org>,
        Namhyung Kim <namhyung@...nel.org>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Peter Zijlstra <a.p.zijlstra@...llo.nl>,
        Martin KaFai Lau <kafai@...com>,
        Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
        John Fastabend <john.fastabend@...il.com>,
        Ian Rogers <irogers@...gle.com>
Subject: Re: [PATCH perf/core 3/5] perf tools: Move libbpf init in
 libbpf_init function

Em Fri, Apr 22, 2022 at 12:00:23PM +0200, Jiri Olsa escreveu:
> Moving the libbpf init code into single function,
> so we have single place doing that.

Cherry picked this one, waiting for Andrii to chime in wrt the libbpf
changes, if its acceptable, how to proceed, i.e. in what tree to carry
these?

- Arnaldo
 
> Signed-off-by: Jiri Olsa <jolsa@...nel.org>
> ---
>  tools/perf/util/bpf-loader.c | 27 ++++++++++++++++++---------
>  1 file changed, 18 insertions(+), 9 deletions(-)
> 
> diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
> index b72cef1ae959..f8ad581ea247 100644
> --- a/tools/perf/util/bpf-loader.c
> +++ b/tools/perf/util/bpf-loader.c
> @@ -99,16 +99,26 @@ static int bpf_perf_object__add(struct bpf_object *obj)
>  	return perf_obj ? 0 : -ENOMEM;
>  }
>  
> +static int libbpf_init(void)
> +{
> +	if (libbpf_initialized)
> +		return 0;
> +
> +	libbpf_set_print(libbpf_perf_print);
> +	libbpf_initialized = true;
> +	return 0;
> +}
> +
>  struct bpf_object *
>  bpf__prepare_load_buffer(void *obj_buf, size_t obj_buf_sz, const char *name)
>  {
>  	LIBBPF_OPTS(bpf_object_open_opts, opts, .object_name = name);
>  	struct bpf_object *obj;
> +	int err;
>  
> -	if (!libbpf_initialized) {
> -		libbpf_set_print(libbpf_perf_print);
> -		libbpf_initialized = true;
> -	}
> +	err = libbpf_init();
> +	if (err)
> +		return ERR_PTR(err);
>  
>  	obj = bpf_object__open_mem(obj_buf, obj_buf_sz, &opts);
>  	if (IS_ERR_OR_NULL(obj)) {
> @@ -135,14 +145,13 @@ struct bpf_object *bpf__prepare_load(const char *filename, bool source)
>  {
>  	LIBBPF_OPTS(bpf_object_open_opts, opts, .object_name = filename);
>  	struct bpf_object *obj;
> +	int err;
>  
> -	if (!libbpf_initialized) {
> -		libbpf_set_print(libbpf_perf_print);
> -		libbpf_initialized = true;
> -	}
> +	err = libbpf_init();
> +	if (err)
> +		return ERR_PTR(err);
>  
>  	if (source) {
> -		int err;
>  		void *obj_buf;
>  		size_t obj_buf_sz;
>  
> -- 
> 2.35.1

-- 

- Arnaldo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ