lkml.org 
[lkml]   [2020]   [Dec]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 6/8] perf daemon: Add stop command
Em Sat, Dec 12, 2020 at 11:43:56AM +0100, Jiri Olsa escreveu:
> Allow 'perf daemon' to stop daemon process:
>
> # perf daemon --stop
> perf daemon is exciting

It looks exciting, yes, a nice functionality! ;-)

- Arnaldo

> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
> tools/perf/Documentation/perf-daemon.txt | 8 ++++++++
> tools/perf/builtin-daemon.c | 10 ++++++++++
> 2 files changed, 18 insertions(+)
>
> diff --git a/tools/perf/Documentation/perf-daemon.txt b/tools/perf/Documentation/perf-daemon.txt
> index 203ec4bf704c..87de2c77e4c7 100644
> --- a/tools/perf/Documentation/perf-daemon.txt
> +++ b/tools/perf/Documentation/perf-daemon.txt
> @@ -35,6 +35,9 @@ OPTIONS
> Send SIGUSR2 to specific session, if session is not specified,
> send SIGUSR2 to all sessions.
>
> +--stop::
> + Stop daemon.
> +
> -v::
> --verbose::
> Be more verbose.
> @@ -116,6 +119,11 @@ And check that the perf data dump was trigered:
> [ perf record: Dump /opt/perfdata/2/perf.data.2020120715220385 ]
>
>
> +Stop daemon:
> +
> + # perf daemon --stop
> + perf daemon is exciting
> +
> SEE ALSO
> --------
> linkperf:perf-record[1], linkperf:perf-config[1]
> diff --git a/tools/perf/builtin-daemon.c b/tools/perf/builtin-daemon.c
> index c53d4ddc2b49..855fed2fe364 100644
> --- a/tools/perf/builtin-daemon.c
> +++ b/tools/perf/builtin-daemon.c
> @@ -451,6 +451,7 @@ enum cmd {
> CMD_LIST = 0,
> CMD_LIST_VERBOSE = 1,
> CMD_SIGNAL = 2,
> + CMD_STOP = 3,
> CMD_MAX,
> };
>
> @@ -528,6 +529,10 @@ static int handle_server_socket(struct daemon *daemon, int sock_fd)
> case CMD_SIGNAL:
> ret = cmd_session_kill(daemon, out, fd);
> break;
> + case CMD_STOP:
> + done = 1;
> + pr_debug("perf daemon is exciting\n");
> + break;
> default:
> break;
> }
> @@ -811,6 +816,7 @@ int cmd_daemon(int argc, const char **argv)
> {
> bool foreground = false;
> bool signal = false;
> + bool stop = false;
> const char *config = NULL;
> const char *signal_str = NULL;
> struct daemon daemon = {
> @@ -821,6 +827,7 @@ int cmd_daemon(int argc, const char **argv)
> OPT_INCR('v', "verbose", &verbose, "be more verbose"),
> OPT_STRING(0, "config", &config,
> "config file", "config file path"),
> + OPT_BOOLEAN(0, "stop", &stop, "stop daemon"),
> OPT_BOOLEAN('f', "foreground", &foreground, "stay on console"),
> OPT_STRING_OPTARG_SET('s', "signal", &signal_str, &signal,
> "signal", "send signal to session", "all"),
> @@ -837,5 +844,8 @@ int cmd_daemon(int argc, const char **argv)
> if (signal)
> return send_cmd(&daemon, CMD_SIGNAL, signal_str);
>
> + if (stop)
> + return send_cmd(&daemon, CMD_STOP, NULL);
> +
> return send_cmd(&daemon, verbose ? CMD_LIST_VERBOSE : CMD_LIST, NULL);
> }
> --
> 2.26.2
>

--

- Arnaldo

\
 
 \ /
  Last update: 2020-12-15 16:49    [W:1.279 / U:0.272 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site