Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2540769pxb; Mon, 18 Jan 2021 22:50:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJx8g6HdoNG3U0CySsVaPPh2vFSIqABJBnqkb2+FFKb+xqZUzviLuiHXedIGEtLutdDrL7et X-Received: by 2002:a05:6402:388:: with SMTP id o8mr2191409edv.359.1611039055075; Mon, 18 Jan 2021 22:50:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611039055; cv=none; d=google.com; s=arc-20160816; b=cfx2UksrmIRu9bnN6SXuw4MQSKThBb+CimWlawyr4s334VeJrEzgYJFLXmr/SXgawS +wx2Z7RhkcUH1XH0cor5HnKQnQuybsYL6sEEzx7EKvrrG17hVg27VXauRA+c3Vry1Wwq bD2GZiFFL87LBZgMRyec7ZEEgaUeHl2lRrFys8XRSPVUy3GdGA30xv0uBv1HFPjKCzOO x5KWix8xep6TlbP6oQAr/eLQvvA56uyDHApdD/zfjvmiH8SDV0vota+vqQRX6BV1BkoK Zx++ZppF546kKDap07k7IRVbuegxB1P9zp0IvyZ21ZJhyukIhMbehP9DptJ2vxLqkly2 cV4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=qOs2goba3DgXyxRMi81zAzSo7zeJdk9mzQns1ZLy/GU=; b=y+DAHPNybLcM5a98iVWFBD4jmZnDr1lDkduKqPgNOYilZIsVi6ey1cuPRZJr5S/ExE TdIc+8d3UHYNVhozDBB+w5RdBhkKx2mSHVF5kiCSAgXiTrCIo2/HhM0vNqdeOrbsuNwR gfTqQk3K1DlWtUJ7LkmlD2woR9okMuyVw6hXauphXmENGUMwV5aP+6XT2yNqYVdFpPYF Ub7nHbTRuDNF2b/npinJMky0aJNMfAXDzUF7y1og95ku6zAIfIyo+qRloFdStt+zVKfD LS6WxS3ow7mrDLBTt0YYfW++1guMjF45wUwB4kejUh1J2Fx3zaW9yiYwXWdEbOmcFg1P Lc0A== 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 d17si4939656edj.264.2021.01.18.22.50.32; Mon, 18 Jan 2021 22:50:55 -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 S1727329AbhASGtR (ORCPT + 99 others); Tue, 19 Jan 2021 01:49:17 -0500 Received: from mail-lf1-f41.google.com ([209.85.167.41]:41211 "EHLO mail-lf1-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732081AbhASFgB (ORCPT ); Tue, 19 Jan 2021 00:36:01 -0500 Received: by mail-lf1-f41.google.com with SMTP id s26so27325305lfc.8 for ; Mon, 18 Jan 2021 21:35:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qOs2goba3DgXyxRMi81zAzSo7zeJdk9mzQns1ZLy/GU=; b=V0WT6WDbm+X5+XxAwDpiJ3++tTSuIj8hYTjZHx3pqqcmEz0hL37LPt0hqxdGeHXDDo 7rQ/+3gOgBLidpSSa095KBPQvFvkLbgmVoNRCaj6CcKbXVXOWooL6XvYgWLhCsQ4JcSL V6KGLdUslo9V3UiBvDyCOV4kUBi8BfxnVMaidwEt/g8S9UpUgYpmHTidp8GJoCXuekN6 jzn1JizPAWjSatAaugxV7OrBCk5Q0iPnBht7JZXBy6/eO7jI/nUVO1+HUyJGKVGgheqh sXHsYQUQRvVOozZMuXpC4v3XXvZSYt/ti9+cy/O9lzPTdIBUozlJ3RpHWrmGbo/OFME7 6E8g== X-Gm-Message-State: AOAM531EUR4GWUZjKRZTjhBejRHyvvIshhvlux+xWcfBToeJmxMG/44Z Xd6/k2DgV8NcD2kYGxoPO02JELC5RIrLNR9+WBg= X-Received: by 2002:a19:8584:: with SMTP id h126mr1165258lfd.152.1611034518994; Mon, 18 Jan 2021 21:35:18 -0800 (PST) MIME-Version: 1.0 References: <20210102220441.794923-1-jolsa@kernel.org> <20210102220441.794923-12-jolsa@kernel.org> In-Reply-To: <20210102220441.794923-12-jolsa@kernel.org> From: Namhyung Kim Date: Tue, 19 Jan 2021 14:35:06 +0900 Message-ID: Subject: Re: [PATCH 11/22] perf daemon: Add stop command To: Jiri Olsa Cc: Arnaldo Carvalho de Melo , lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Michael Petlan , Ian Rogers , Stephane Eranian , Alexei Budankov Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jan 3, 2021 at 7:05 AM Jiri Olsa wrote: > > 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"); I can see how much you are excited. ;-) Thanks, Namhyung > + 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 >