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: <20201209155552.GC69683@krava>
Date:   Wed, 9 Dec 2020 16:55:52 +0100
From:   Jiri Olsa <jolsa@...hat.com>
To:     Song Liu <songliubraving@...com>
Cc:     lkml <linux-kernel@...r.kernel.org>,
        Kernel Team <Kernel-team@...com>,
        "peterz@...radead.org" <peterz@...radead.org>,
        "mingo@...hat.com" <mingo@...hat.com>,
        "acme@...nel.org" <acme@...nel.org>,
        "mark.rutland@....com" <mark.rutland@....com>,
        "alexander.shishkin@...ux.intel.com" 
        <alexander.shishkin@...ux.intel.com>,
        "namhyung@...nel.org" <namhyung@...nel.org>
Subject: Re: [PATCH v2 2/2] perf-stat: enable counting events for BPF programs

On Tue, Dec 08, 2020 at 01:36:57AM +0000, Song Liu wrote:

SNIP

> > SNIP
> > 
> >> +static int bpf_program_profiler__read(struct evsel *evsel)
> >> +{
> >> +	int num_cpu = evsel__nr_cpus(evsel);
> >> +	struct bpf_perf_event_value values[num_cpu];
> >> +	struct bpf_counter *counter;
> >> +	int reading_map_fd;
> >> +	__u32 key = 0;
> >> +	int err, cpu;
> >> +
> >> +	if (list_empty(&evsel->bpf_counter_list))
> >> +		return -EAGAIN;
> >> +
> >> +	for (cpu = 0; cpu < num_cpu; cpu++) {
> >> +		perf_counts(evsel->counts, cpu, 0)->val = 0;
> >> +		perf_counts(evsel->counts, cpu, 0)->ena = 0;
> >> +		perf_counts(evsel->counts, cpu, 0)->run = 0;
> >> +	}
> >> +	list_for_each_entry(counter, &evsel->bpf_counter_list, list) {
> >> +		struct bpf_prog_profiler_bpf *skel = counter->skel;
> >> +
> >> +		reading_map_fd = bpf_map__fd(skel->maps.accum_readings);
> >> +
> >> +		err = bpf_map_lookup_elem(reading_map_fd, &key, values);
> >> +		if (err) {
> >> +			fprintf(stderr, "failed to read value\n");
> >> +			return err;
> >> +		}
> >> +
> >> +		for (cpu = 0; cpu < num_cpu; cpu++) {
> >> +			perf_counts(evsel->counts, cpu, 0)->val += values[cpu].counter;
> >> +			perf_counts(evsel->counts, cpu, 0)->ena += values[cpu].enabled;
> >> +			perf_counts(evsel->counts, cpu, 0)->run += values[cpu].running;
> >> +		}
> > 
> > so we sum everything up for all provided bpf IDs,
> > should we count/display them separately?
> 
> I think that's the default behavior with --pid x,y,z or --cpu a,b,c. 
> Do we need to separate them?

ah right, and we have --per-thread that splits the output
for specified pids

I think we should add something like that for bpf, so we
could see stats for specific programs

it's ok to do this as a follow up patch in future

thanks,
jirka

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ