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

Reply via email to