Re: [PATCH 4/8] perf daemon: Add daemon command

From: Namhyung Kim
Date: Fri Dec 18 2020 - 08:26:06 EST


Hi Jiri,

On Wed, Dec 16, 2020 at 4:44 AM Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
>
> On Tue, Dec 15, 2020 at 06:40:26PM +0300, Alexei Budankov wrote:
> > Hi,
> >
> > On 12.12.2020 13:43, Jiri Olsa wrote:
> > > Adding daemon command that allows to run record sessions
> > > on background. Each session represents one perf record
> > > process and is configured in config file.
> > >
> > > Example:
> > >
> > > # cat config.daemon
> > > [daemon]
> > > base=/opt/perfdata
> >
> > It could probably make sense to consider using locations at /var/
> > directory, similar to other already existing daemon processes in
> > system so admin and user experience would be easily reusabe for
> > performance monitoring daemon (service).
>
> hm, you can specify any /var path in there if you like,
> do you suggest to hardcode it?
>
> >
> > >
> > > [session-1]
> > > run = -m 10M -e cycles -o /opt/perfdata/1/perf.data --overwrite --switch-output -a
> > >
> > > [session-2]
> > > run = -m 20M -e sched:* -o /opt/perfdata/2/perf.data --overwrite --switch-output -a
> > >
> > > Default perf config has the same daemon base:
> > >
> > > # cat ~/.perfconfig
> > > [daemon]
> > > base=/opt/perfdata
> > >
> > > Starting the daemon:
> > >
> > > # perf daemon --config config.daemon
> >
> > It could make sense to name daemon config file similar to .perfconfig
> > e.g. like .perfconfig.daemon. perf daemon command would then assume, by
> > default, usage of .perfconfig.daemon config or the one specified on the
> > command line via --config option. It also would be helpfull have loaded
> > config file path printed into console:
> > # perf daemon
> > Daemon process <pid> started with config /path/to/.perfconfig.daemon
>
> so the current way is, that following creates daemon:
>
> # perf daemon --config <CONFIG>
>
> and any other 'non --config' option' is used to 'query/control' daemon:
>
> # perf daemon
> # perf daemon --signal
> # perf daemon --stop
> ...

My opinion is that it'd be better having sub-commands for essential
operations like start, stop. Also daemons tend to have 'status' or
'reload' operations too.

# perf daemon start --config ...
# perf daemon stop

As a system daemon, I agree it should follow the standard location
for the default base directory and config file.

Thanks,
Namhyung