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] [day] [month] [year] [list]
Message-ID: <20200429081811.GK1476763@krava>
Date:   Wed, 29 Apr 2020 10:18:11 +0200
From:   Jiri Olsa <jolsa@...hat.com>
To:     Arnaldo Carvalho de Melo <arnaldo.melo@...il.com>
Cc:     Jiri Olsa <jolsa@...nel.org>, Namhyung Kim <namhyung@...nel.org>,
        Ingo Molnar <mingo@...nel.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Clark Williams <williams@...hat.com>,
        linux-kernel@...r.kernel.org, linux-perf-users@...r.kernel.org,
        Arnaldo Carvalho de Melo <acme@...hat.com>,
        Adrian Hunter <adrian.hunter@...el.com>,
        Song Liu <songliubraving@...com>,
        Wang Nan <wangnan0@...wei.com>
Subject: Re: [PATCH 7/7] perf record: Introduce --switch-output-event

On Tue, Apr 28, 2020 at 03:05:18PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Tue, Apr 28, 2020 at 03:22:57PM +0200, Jiri Olsa escreveu:
> > On Tue, Apr 28, 2020 at 09:16:01AM -0300, Arnaldo Carvalho de Melo wrote:
> > 
> > SNIP
> > 
> > > > > +				pr_err("Couldn't create side band evlist.\n.");
> > > > > +				goto out_child;
> > > > > +			}
> > > > >  		}
> 
> > > > >  		if (evlist__add_bpf_sb_event(rec->sb_evlist, &session->header.env)) {
> 
> > > > it's getting bigger, I wonder we should put all the sb_* setup in
> > > > separated functions like sb_start/sb_stop
> 
> > > Well, the rec->thread_id = pthread_self(); part is just for reusing a
> > > 'perf record' specific mechanism, what to do when the event appears in
> > > the side band thread ring buffer, the evlist__set_cb() also is related
> > > to that, moving thread_id to evlist seems too much at this time.
> 
> > hum, I meant record specific static functions sb_start/sb_stop,
> > not inside evlist.. just to have it separated
> 
> Ok, so I have the patch below on top of that series, and its all
> available in my perf/switch-output-event, that is on top of more patches
> collected today, all going well, this perf/switch-output-event will turn
> into perf/core ang go upstream soon, then I have to loo at Adrian's
> kernel+tooling patchkit,

ok looks good

thank,
jirka

> 
> - Arnaldo
> 
> commit a25516b4db23ba8f956b990d37ec6728e5221718
> Author: Arnaldo Carvalho de Melo <acme@...hat.com>
> Date:   Tue Apr 28 14:58:29 2020 -0300
> 
>     perf record: Move side band evlist setup to separate routine
>     
>     It is quite big by now, move that code to a separate
>     record__setup_sb_evlist() routine.
>     
>     Suggested-by: Jiri Olsa <jolsa@...hat.com>
>     Cc: Adrian Hunter <adrian.hunter@...el.com>
>     Cc: Namhyung Kim <namhyung@...nel.org>
>     Cc: Song Liu <songliubraving@...com>
>     Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
> 
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index 7a6a89972691..bb3d30616bf3 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -1445,6 +1445,44 @@ static int record__process_signal_event(union perf_event *event __maybe_unused,
>  	return 0;
>  }
>  
> +static int record__setup_sb_evlist(struct record *rec)
> +{
> +	struct record_opts *opts = &rec->opts;
> +
> +	if (rec->sb_evlist != NULL) {
> +		/*
> +		 * We get here if --switch-output-event populated the
> +		 * sb_evlist, so associate a callback that will send a SIGUSR2
> +		 * to the main thread.
> +		 */
> +		evlist__set_cb(rec->sb_evlist, record__process_signal_event, rec);
> +		rec->thread_id = pthread_self();
> +	}
> +
> +	if (!opts->no_bpf_event) {
> +		if (rec->sb_evlist == NULL) {
> +			rec->sb_evlist = evlist__new();
> +
> +			if (rec->sb_evlist == NULL) {
> +				pr_err("Couldn't create side band evlist.\n.");
> +				return -1;
> +			}
> +		}
> +
> +		if (evlist__add_bpf_sb_event(rec->sb_evlist, &rec->session->header.env)) {
> +			pr_err("Couldn't ask for PERF_RECORD_BPF_EVENT side band events.\n.");
> +			return -1;
> +		}
> +	}
> +
> +	if (perf_evlist__start_sb_thread(rec->sb_evlist, &rec->opts.target)) {
> +		pr_debug("Couldn't start the BPF side band thread:\nBPF programs starting from now on won't be annotatable\n");
> +		opts->no_bpf_event = true;
> +	}
> +
> +	return 0;
> +}
> +
>  static int __cmd_record(struct record *rec, int argc, const char **argv)
>  {
>  	int err;
> @@ -1589,36 +1627,9 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
>  		goto out_child;
>  	}
>  
> -	if (rec->sb_evlist != NULL) {
> -		/*
> -		 * We get here if --switch-output-event populated the
> -		 * sb_evlist, so associate a callback that will send a SIGUSR2
> -		 * to the main thread.
> -		 */
> -		evlist__set_cb(rec->sb_evlist, record__process_signal_event, rec);
> -		rec->thread_id = pthread_self();
> -	}
> -
> -	if (!opts->no_bpf_event) {
> -		if (rec->sb_evlist == NULL) {
> -			rec->sb_evlist = evlist__new();
> -
> -			if (rec->sb_evlist == NULL) {
> -				pr_err("Couldn't create side band evlist.\n.");
> -				goto out_child;
> -			}
> -		}
> -
> -		if (evlist__add_bpf_sb_event(rec->sb_evlist, &session->header.env)) {
> -			pr_err("Couldn't ask for PERF_RECORD_BPF_EVENT side band events.\n.");
> -			goto out_child;
> -		}
> -	}
> -
> -	if (perf_evlist__start_sb_thread(rec->sb_evlist, &rec->opts.target)) {
> -		pr_debug("Couldn't start the BPF side band thread:\nBPF programs starting from now on won't be annotatable\n");
> -		opts->no_bpf_event = true;
> -	}
> +	err = record__setup_sb_evlist(rec);
> +	if (err)
> +		goto out_child;
>  
>  	err = record__synthesize(rec, false);
>  	if (err < 0)
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ