Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1896790pxu; Sun, 13 Dec 2020 06:56:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJzRvfc0n5iLmKtl6nLSLPdF/HhYjbfg/TW2Qn0l41VAmoRRGXzxoPgzsPHgl2IPGU1qygEh X-Received: by 2002:a17:907:d09:: with SMTP id gn9mr15661369ejc.349.1607871408928; Sun, 13 Dec 2020 06:56:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607871408; cv=none; d=google.com; s=arc-20160816; b=LgT5E04NM4Cgcod1v1ydcgKe436JstrVyWMXicLY3kh8ewX4UnkYOjUHLr6zCQc7n4 yNxLeCWJTW5m11a8qVUt05pLaIyiTkghMbjBwAvZ0x0bo3PVBu4NMP1Hj0BnggO8z7Rx dI5ezAuY1X+t1wAtDbVY8hA+RVz4a/r6plB9eAXCz4o/G/nvjaQn04ogoHMVL9PknQ+1 oYPEFnYwWOc+LBRIoW62sFUVZSot6yq5cdnlOv9mdFsWiRNMj/dJWSIWEbGvYidTjjYl GgIdT0XiyFK9u0I3cJn6B50IupUlwSN5I8/h8t+T+XxDCC4WRBZH5+sfBZRhxFoVYB1K oY/Q== 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=Baqom5kwjzr6HvuUsmorvhjhZ4c1IBGxyhAnAGtRrSo=; b=tCyJsasjteKQICR0hDCZbcBCbekDsnz+GAH9CI38lfElyTtIqwQOVxL9vIZZvnjgWg Kldnn7BQaxdvAEywIOv3fjUW9lDNA1m5Tw94BUNzD+2kLrJrusl8+3dtBxC1e7HGKlCZ sqTcoC67QGXInxo5azvtklLCT+d2w5ScGLAHV7JVY6ExEc76agLywa+sIHCbBIIP871N IG99HVizHjmaQ1v2xC9qTnjJxt3/0yZejTeQm3832vVNcj0Z5k77x2LzZLQI80HAUHE7 sRVNZDIgB/8FRd/9frNlOMW3QaMq5/NiCsfkqeVKlD3P+x017oqN5IY0CVXjP2pN5p9m sZFQ== 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 n8si8067361edy.54.2020.12.13.06.56.26; Sun, 13 Dec 2020 06:56:48 -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 S2438718AbgLLKqJ convert rfc822-to-8bit (ORCPT + 99 others); Sat, 12 Dec 2020 05:46:09 -0500 Received: from us-smtp-delivery-44.mimecast.com ([205.139.111.44]:20046 "EHLO us-smtp-delivery-44.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407389AbgLLKpV (ORCPT ); Sat, 12 Dec 2020 05:45:21 -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-62-tVdVljN7N3K6hhcWFX1Dbw-1; Sat, 12 Dec 2020 05:44:26 -0500 X-MC-Unique: tVdVljN7N3K6hhcWFX1Dbw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DEDB6801AA5; Sat, 12 Dec 2020 10:44:24 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.192.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id DEE9F7086D; Sat, 12 Dec 2020 10:44:21 +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 6/8] perf daemon: Add stop command Date: Sat, 12 Dec 2020 11:43:56 +0100 Message-Id: <20201212104358.412065-7-jolsa@kernel.org> In-Reply-To: <20201212104358.412065-1-jolsa@kernel.org> References: <20201212104358.412065-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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 Allow 'perf daemon' to stop daemon process: # perf daemon --stop perf daemon is exciting Signed-off-by: Jiri Olsa --- tools/perf/Documentation/perf-daemon.txt | 8 ++++++++ tools/perf/builtin-daemon.c | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/tools/perf/Documentation/perf-daemon.txt b/tools/perf/Documentation/perf-daemon.txt index 203ec4bf704c..87de2c77e4c7 100644 --- a/tools/perf/Documentation/perf-daemon.txt +++ b/tools/perf/Documentation/perf-daemon.txt @@ -35,6 +35,9 @@ OPTIONS Send SIGUSR2 to specific session, if session is not specified, send SIGUSR2 to all sessions. +--stop:: + Stop daemon. + -v:: --verbose:: Be more verbose. @@ -116,6 +119,11 @@ And check that the perf data dump was trigered: [ perf record: Dump /opt/perfdata/2/perf.data.2020120715220385 ] +Stop daemon: + + # perf daemon --stop + perf daemon is exciting + SEE ALSO -------- linkperf:perf-record[1], linkperf:perf-config[1] diff --git a/tools/perf/builtin-daemon.c b/tools/perf/builtin-daemon.c index c53d4ddc2b49..855fed2fe364 100644 --- a/tools/perf/builtin-daemon.c +++ b/tools/perf/builtin-daemon.c @@ -451,6 +451,7 @@ enum cmd { CMD_LIST = 0, CMD_LIST_VERBOSE = 1, CMD_SIGNAL = 2, + CMD_STOP = 3, CMD_MAX, }; @@ -528,6 +529,10 @@ static int handle_server_socket(struct daemon *daemon, int sock_fd) case CMD_SIGNAL: ret = cmd_session_kill(daemon, out, fd); break; + case CMD_STOP: + done = 1; + pr_debug("perf daemon is exciting\n"); + break; default: break; } @@ -811,6 +816,7 @@ int cmd_daemon(int argc, const char **argv) { bool foreground = false; bool signal = false; + bool stop = false; const char *config = NULL; const char *signal_str = NULL; struct daemon daemon = { @@ -821,6 +827,7 @@ int cmd_daemon(int argc, const char **argv) OPT_INCR('v', "verbose", &verbose, "be more verbose"), OPT_STRING(0, "config", &config, "config file", "config file path"), + OPT_BOOLEAN(0, "stop", &stop, "stop daemon"), OPT_BOOLEAN('f', "foreground", &foreground, "stay on console"), OPT_STRING_OPTARG_SET('s', "signal", &signal_str, &signal, "signal", "send signal to session", "all"), @@ -837,5 +844,8 @@ int cmd_daemon(int argc, const char **argv) if (signal) return send_cmd(&daemon, CMD_SIGNAL, signal_str); + if (stop) + return send_cmd(&daemon, CMD_STOP, NULL); + return send_cmd(&daemon, verbose ? CMD_LIST_VERBOSE : CMD_LIST, NULL); } -- 2.26.2