summaryrefslogtreecommitdiff
path: root/tools/perf/builtin-daemon.c
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2021-02-08 23:09:00 +0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2021-02-11 16:19:52 +0300
commit6d6162d51cb1481a34396ff73dc489da73bf63b5 (patch)
tree2d7c3ea2d06caff5eea1267369be28ad5a5cc1d9 /tools/perf/builtin-daemon.c
parentedcaa47958c7438b56fc528d4e242f16a249003f (diff)
downloadlinux-6d6162d51cb1481a34396ff73dc489da73bf63b5.tar.xz
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>
Diffstat (limited to 'tools/perf/builtin-daemon.c')
-rw-r--r--tools/perf/builtin-daemon.c56
1 files changed, 46 insertions, 10 deletions
diff --git a/tools/perf/builtin-daemon.c b/tools/perf/builtin-daemon.c
index fac8605492fe..c36f521d9727 100644
--- a/tools/perf/builtin-daemon.c
+++ b/tools/perf/builtin-daemon.c
@@ -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)