Commit 6d6162d5 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

perf daemon: Use control to stop session

Use the 'stop' control command to stop perf record session.  If that
fails, fall back to current SIGTERM/SIGKILL pair.
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexei Budankov <abudankov@huawei.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: https://lore.kernel.org/r/20210208200908.1019149-17-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent edcaa479
......@@ -870,11 +870,25 @@ static int setup_client_socket(struct daemon *daemon)
static void daemon_session__kill(struct daemon_session *session,
struct daemon *daemon)
{
int how = 0;
do {
switch (how) {
case 0:
daemon_session__control(session, "stop", false);
break;
case 1:
daemon_session__signal(session, SIGTERM);
if (daemon_session__wait(session, daemon, 10)) {
break;
case 2:
daemon_session__signal(session, SIGKILL);
daemon_session__wait(session, daemon, 10);
break;
default:
break;
}
how++;
} while (daemon_session__wait(session, daemon, 10));
}
static void daemon__signal(struct daemon *daemon, int sig)
......@@ -899,13 +913,35 @@ static void daemon_session__remove(struct daemon_session *session)
daemon_session__delete(session);
}
static void daemon__stop(struct daemon *daemon)
{
struct daemon_session *session;
list_for_each_entry(session, &daemon->sessions, list)
daemon_session__control(session, "stop", false);
}
static void daemon__kill(struct daemon *daemon)
{
int how = 0;
do {
switch (how) {
case 0:
daemon__stop(daemon);
break;
case 1:
daemon__signal(daemon, SIGTERM);
if (daemon__wait(daemon, 10)) {
break;
case 2:
daemon__signal(daemon, SIGKILL);
daemon__wait(daemon, 10);
break;
default:
break;
}
how++;
} while (daemon__wait(daemon, 10));
}
static void daemon__exit(struct daemon *daemon)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment