Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4314141pxb; Mon, 8 Feb 2021 13:15:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJzyiQmuwguzWx2XcEBuukk+ePzMCDKjsRVl1SlHAn4lYu1UCa50kMtTiJV04VxzZ8aDtYY8 X-Received: by 2002:a17:906:c010:: with SMTP id e16mr18525644ejz.91.1612818944057; Mon, 08 Feb 2021 13:15:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612818944; cv=none; d=google.com; s=arc-20160816; b=gPLGk5Q5omIUOGdQiikjjoxq9Q6Ua1GL5LFXoSxkQHC+7FLeAkN5qrMNSRv0phyoqV ESVXj17x8zb9uy7JevuvvMlO5k3EruTAsQ4IW2IckUCiUjueCZAjH9F4E7ikuE81ooWZ wDT5B1/FBGqGRQO5RQvK0RbJYJ4sCEo3WTBj8Nkd0mEOvbPQPf9CZ6eU1kkgYCcEr/Pg GdYsli/MkzrxrT78idwkkNCGy2GKgwqgmxV4KvkNvNURN+HDt0V0+sqh55yix8scam4U 45SS2N4eHnbim8NNf8jkaG7KOp+AXTRpglSmmFMQRN+GUnU1meeymHdD0Hb5F7E1Jj6t Cf4w== 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=Rb3BJWRU9hFgCQwR0dKztcK4ygSdtfQeFCiGloWiCAM=; b=WZwWXSWskLKAZNcB8DD1lP1fUqYtn0/h0xTsiUir1i6YG0y3bI/YQJdei0eITiyri7 z01jjDQyvndW+uQWOH1HCAHN4PLjv75zmf5fXHfXe/+lyS6ewCpZXE4vGQSWTzE7lUV6 v5xhos7FZwypiA+3fbd6waJcqb0wBppDTXfHxWg158EIkeNY+bTvMP3j1jRBXcdkPnz5 M1Sefv32vSTyc872mmcP1cKtIAZ23bPH7oFKTmNKceIYvGIesi9LeU9/hLKY4bvrimmk lMvG2XH23jzqUXvqRmrKG3Gq78H+h/9HTtKkiQknlE+ARshoX7Y61b+xBIqg1WjiwrpU ZJMQ== 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 b22si4408704eds.547.2021.02.08.13.15.20; Mon, 08 Feb 2021 13:15:44 -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 S236307AbhBHVOo convert rfc822-to-8bit (ORCPT + 99 others); Mon, 8 Feb 2021 16:14:44 -0500 Received: from us-smtp-delivery-44.mimecast.com ([207.211.30.44]:34737 "EHLO us-smtp-delivery-44.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236643AbhBHUKm (ORCPT ); Mon, 8 Feb 2021 15:10:42 -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-243-3CsvaeD5PsitDz5OBI9X9Q-1; Mon, 08 Feb 2021 15:09:45 -0500 X-MC-Unique: 3CsvaeD5PsitDz5OBI9X9Q-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 9CEB510082F6; Mon, 8 Feb 2021 20:09:43 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.194.115]) by smtp.corp.redhat.com (Postfix) with ESMTP id 60C6519C59; Mon, 8 Feb 2021 20:09:41 +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 , Alexei Budankov Subject: [PATCH 12/24] perf daemon: Add stop command Date: Mon, 8 Feb 2021 21:08:56 +0100 Message-Id: <20210208200908.1019149-13-jolsa@kernel.org> In-Reply-To: <20210208200908.1019149-1-jolsa@kernel.org> References: <20210208200908.1019149-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/Documentation/perf-daemon.txt | 6 +++++ tools/perf/builtin-daemon.c | 29 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/tools/perf/Documentation/perf-daemon.txt b/tools/perf/Documentation/perf-daemon.txt index 9cd47ec959e9..94d5e09a1e17 100644 --- a/tools/perf/Documentation/perf-daemon.txt +++ b/tools/perf/Documentation/perf-daemon.txt @@ -13,6 +13,7 @@ SYNOPSIS 'perf daemon' 'perf daemon' [] 'perf daemon start' [] +'perf daemon stop' [] 'perf daemon signal' [] @@ -62,6 +63,11 @@ The start command creates the daemon process. Do not put the process in background. +STOP COMMAND +------------ +The stop command stops all the session and the daemon process. + + SIGNAL COMMAND -------------- The signal command sends signal to configured sessions. diff --git a/tools/perf/builtin-daemon.c b/tools/perf/builtin-daemon.c index 027e1e58b67b..2ef7fe9200f3 100644 --- a/tools/perf/builtin-daemon.c +++ b/tools/perf/builtin-daemon.c @@ -532,6 +532,7 @@ static int setup_server_socket(struct daemon *daemon) enum { CMD_LIST = 0, CMD_SIGNAL = 1, + CMD_STOP = 2, CMD_MAX, }; @@ -665,6 +666,11 @@ 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; + ret = 0; + pr_debug("perf daemon is exciting\n"); + break; default: break; } @@ -1149,6 +1155,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[] = { @@ -1173,6 +1200,8 @@ int cmd_daemon(int argc, const char **argv) return __cmd_start(&__daemon, daemon_options, argc, argv); 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.29.2