Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp12851477pxu; Sat, 2 Jan 2021 14:08:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJxjclcM09HHjbO63sJKQzoGDKBpXoxZxpYg8Om5M35X05k00dqZINGDqAT74NwiZlPy/Uuu X-Received: by 2002:a17:906:16d6:: with SMTP id t22mr61346652ejd.154.1609625289839; Sat, 02 Jan 2021 14:08:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609625289; cv=none; d=google.com; s=arc-20160816; b=CFp7Y7kV7YVJYjbMfvGutTSQ2WNqrKF8N2vmY5RmtFxEyiTflA8r308RAfCJlGnm6n FPCrgfQZ+FsL9Lypyvk3n1gj+QeFOFdVhaeckQY+chJ2zPGjRj3vmVpG3mZgvoIBfrKJ AINuGDctSQOPngZGIh59nS9YBseBPQGkG+oEhD6cxZEE9GHCOKFQbpaYE7IgcLvc8Jde +aHWZ6GmSOriJYSwwUA6c235OH59vxswT02GvfUUPCPl2mrVWuDPgihZ3g64iQFk1g/1 OAuptQ49SorpLsM5aBTV57zP7uwTEK7Uojs1XA6J61LR3cYuvl8FLAGrEMAu/yIj2cEq IM8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=xTbtq5Y8aMpON0ZwdGZJpBG7X1MntS+PJse+dF9seio=; b=syzUzWwzV1n3lqrAxKonSTtjOPBAWVE5VDgW7ebHI2UIk2TgD1IKiIDMp4GJ7lhlUx qQ4MgnNYsntKY/Ys/ybO5maUlC1ba2INXCbKtaT/80F1McY9kys9kSlBcGub2fo756Ha FoWl11MsXfQtXq8jcAwCGQTrIvZXMDrPCDHA9ntnAHrH7DWBt1zkMmTtLstjsP1SdD17 2NH1yeiOEP7yvy5Du5fsi4tddGRI3X+sf2sOrTlptOyAY1BfpTt9x1UvHT1sepRDGcMc ABXHOhEUYgzwRLXScwWNhrdUYd7iXtPRE2LDUnrINVsUkviwPEiJwvDJWEQRiFLjNz4M QSlw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v25si28074427edt.63.2021.01.02.14.07.47; Sat, 02 Jan 2021 14:08:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727293AbhABWGS convert rfc822-to-8bit (ORCPT + 99 others); Sat, 2 Jan 2021 17:06:18 -0500 Received: from us-smtp-delivery-44.mimecast.com ([205.139.111.44]:49576 "EHLO us-smtp-delivery-44.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727196AbhABWGQ (ORCPT ); Sat, 2 Jan 2021 17:06:16 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-144-JD6mJV6wOO6LXbLw0nBA3w-1; Sat, 02 Jan 2021 17:05:23 -0500 X-MC-Unique: JD6mJV6wOO6LXbLw0nBA3w-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2FAF9180A095; Sat, 2 Jan 2021 22:05:22 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.192.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 72C671A353; Sat, 2 Jan 2021 22:05:19 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , Alexander Shishkin , Michael Petlan , Ian Rogers , Stephane Eranian , Alexei Budankov Subject: [PATCH 11/22] perf daemon: Add stop command Date: Sat, 2 Jan 2021 23:04:30 +0100 Message-Id: <20210102220441.794923-12-jolsa@kernel.org> In-Reply-To: <20210102220441.794923-1-jolsa@kernel.org> References: <20210102220441.794923-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jolsa@kernel.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset=WINDOWS-1252 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add 'perf daemon stop' command to stop daemon process and all running sessions. Example: # cat ~/.perfconfig [daemon] base=/opt/perfdata [session-cycles] run = -m 10M -e cycles --overwrite --switch-output -a [session-sched] run = -m 20M -e sched:* --overwrite --switch-output -a Starting the daemon: # perf daemon start Stopping the daemon # perf daemon stop Daemon is not running, nothing to connect to: # perf daemon connect error: Connection refused Signed-off-by: Jiri Olsa --- tools/perf/builtin-daemon.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tools/perf/builtin-daemon.c b/tools/perf/builtin-daemon.c index a7ffbecf8d14..45748bb471ec 100644 --- a/tools/perf/builtin-daemon.c +++ b/tools/perf/builtin-daemon.c @@ -524,6 +524,7 @@ static int setup_server_socket(struct daemon *daemon) enum { CMD_LIST = 0, CMD_SIGNAL = 1, + CMD_STOP = 2, CMD_MAX, }; @@ -650,6 +651,10 @@ static int handle_server_socket(struct daemon *daemon, int sock_fd) case CMD_SIGNAL: ret = cmd_session_kill(daemon, &cmd, out); break; + case CMD_STOP: + done = 1; + pr_debug("perf daemon is exciting\n"); + break; default: break; } @@ -992,6 +997,27 @@ static int __cmd_signal(struct daemon *daemon, struct option parent_options[], return send_cmd(daemon, &cmd); } +static int __cmd_stop(struct daemon *daemon, struct option parent_options[], + int argc, const char **argv) +{ + struct option start_options[] = { + OPT_PARENT(parent_options), + OPT_END() + }; + union cmd cmd = { .cmd = CMD_STOP, }; + + argc = parse_options(argc, argv, start_options, daemon_usage, 0); + if (argc) + usage_with_options(daemon_usage, start_options); + + if (setup_config(daemon)) { + pr_err("failed: config not found\n"); + return -1; + } + + return send_cmd(daemon, &cmd); +} + int cmd_daemon(int argc, const char **argv) { struct option daemon_options[] = { @@ -1015,6 +1041,8 @@ int cmd_daemon(int argc, const char **argv) if (argc) { if (!strcmp(argv[0], "signal")) return __cmd_signal(&__daemon, daemon_options, argc, argv); + else if (!strcmp(argv[0], "stop")) + return __cmd_stop(&__daemon, daemon_options, argc, argv); pr_err("failed: unknown command '%s'\n", argv[0]); return -1; -- 2.26.2