Re: [PATCH 47/48] perf record: Spread maps for --threads option

From: Jiri Olsa
Date: Wed Sep 26 2018 - 02:23:32 EST


On Mon, Sep 24, 2018 at 11:22:54AM -0300, Arnaldo Carvalho de Melo wrote:
> Em Sun, Sep 23, 2018 at 09:44:32PM +0200, Jiri Olsa escreveu:
> > On Mon, Sep 17, 2018 at 08:40:48PM +0900, Namhyung Kim wrote:
> > > On Thu, Sep 13, 2018 at 02:54:49PM +0200, Jiri Olsa wrote:
> > > > Currently we assign all maps to main thread. Adding
> > > > code that spreads maps for --threads option.
> > > >
> > > > For --thread option we create as many threads as there
> > > > are memory maps in evlist, which is the number of CPUs
> > > > in the system or CPUs we monitor. Each thread gets a
> > > > single data mmap to read.
> > > >
> > > > In addition we have also same amount of tracking mmaps
> > > > for auxiliary events which we don't create special thread
> > > > for. Instead we assign the to the main thread, because
> > > > there's not much traffic expected there.
> > > >
> > > > The assignment is visible from --thread-stats output:
> > > >
> > > > pid write poll skip maps (size 20K)
> > > > 1s 9770 144B 1 0 19K 19K 19K 18K 19K
> > > > 9772 0B 1 0 18K
> > > > 9773 0B 1 0 19K
> > > > 9774 0B 1 0 19K
> > > >
> > > > There are 5 maps for thread 9770 (1 data map and 4 auxiliary)
> > > > and one data map for every other thread. Each thread writes
> > > > data to the separate data file.
> > >
> > > Hmm.. not sure it'll work well for large machines with 1000+ cpus.
> > > What about giving each thread a data mmap and a tracking mmap?
> >
> > well currently we store the tracking data in single file,
> > thats why we need just one thread to write them down
>
> I agree with Namhyung, with a slight difference: perhaps we should set
> perf_event_attr.mmap on one of the events of the per-cpu mmap, that way
> we don't need that dummy event, right?

currently it's all based on having tracking data separated
in single file which is read/processed first, so when we
read the sample data files, we can read them separately,
because we have the tracking data ready

>
> > with the *_time API, we should be able to properly read the
> > tracking data separately for each cpu
>
> That may end up making the *_time API not needed (assuming the kernel
> keeps the per-cpu mmap events in order, barring that, using the
> ordered_events in batches, prior to consuming the events) and would help
> with things like 'perf top' and 'perf trace', that want to consume
> events right away.

if we dont want to use *_by_time API, we need to find a way
to sort evevrything out before we start processing.. and that
seems too costly to me

jirka