Skip to content

Commit

Permalink
perf daemon: Use control to stop session
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Alexei Budankov <[email protected]>
Cc: Ian Rogers <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Michael Petlan <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
olsajiri authored and acmel committed Feb 11, 2021
1 parent edcaa47 commit 6d6162d
Showing 1 changed file with 46 additions and 10 deletions.
56 changes: 46 additions & 10 deletions tools/perf/builtin-daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 6d6162d

Please sign in to comment.