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: Jiri 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.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Jiri Olsa 2021-02-08 21:09:00 +01:00 committed by Arnaldo Carvalho de Melo
parent edcaa47958
commit 6d6162d51c
1 changed files with 46 additions and 10 deletions

View File

@ -870,11 +870,25 @@ static int setup_client_socket(struct daemon *daemon)
static void daemon_session__kill(struct daemon_session *session,
struct daemon *daemon)
{
daemon_session__signal(session, SIGTERM);
if (daemon_session__wait(session, daemon, 10)) {
daemon_session__signal(session, SIGKILL);
daemon_session__wait(session, daemon, 10);
}
int how = 0;
do {
switch (how) {
case 0:
daemon_session__control(session, "stop", false);
break;
case 1:
daemon_session__signal(session, SIGTERM);
break;
case 2:
daemon_session__signal(session, SIGKILL);
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)
{
daemon__signal(daemon, SIGTERM);
if (daemon__wait(daemon, 10)) {
daemon__signal(daemon, SIGKILL);
daemon__wait(daemon, 10);
}
int how = 0;
do {
switch (how) {
case 0:
daemon__stop(daemon);
break;
case 1:
daemon__signal(daemon, SIGTERM);
break;
case 2:
daemon__signal(daemon, SIGKILL);
break;
default:
break;
}
how++;
} while (daemon__wait(daemon, 10));
}
static void daemon__exit(struct daemon *daemon)