Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2811740pxb; Sat, 30 Jan 2021 15:55:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJy8b5vf/2V1wsZ0/7pS1mObGmFe+Emu4hZWQ9Ku7xxxIc0RJ4CMX8N3iO4QjSHuDU/Osi03 X-Received: by 2002:a50:e8c1:: with SMTP id l1mr11987322edn.168.1612050949341; Sat, 30 Jan 2021 15:55:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612050949; cv=none; d=google.com; s=arc-20160816; b=TS/it3uN/RG2hSX7p0D3lUDSNmFP7N4uARWhcPOn0k68BW7b7cBsKTCrryeDROM8sN vWza1tBrMLRl4mdZ6D17lyv7uOqb36/+5R/Fc8B7mop85TCONqU7oE/mdU/lVu6aaO/P 7+L2GBg8f1IMZisslcH+k1HoLjAcDGWfdOuSXIgDUfvai9e2pe1MUQpkgwPOXTegYesL 9yZ5kL70tHmFstkDr8/tdtFxEPyG1OPESMZS8AcyYJdvr7QHZIVgCR9y/8j2xulYlsT6 InlXg6ofonIVzm/Yt/UEVsSzyN+QYgK9mdwiNiHJ45F4IoS48KPW6tfgTCxDzM7vk91u vJ4g== 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=A++BjKOpS+x/jUn3a0fFegzUYE/csFOYFPqMWn1qL/o=; b=ybwWi8Jm1Gc0et/PoLzwcsxaypxqdhR3t4pxP4wO57CyXET2zcS9EOoDBNGmXKnded AGn4TQXe89Md1kCe1B6nrphZPGC0qd0mtdFZfD4OVBbaE+pGf/1mORfR1UbWYCsEG+jR C9ICIwXmst+qFQRVHot9Z8ztG1vGs/U4vIzvnq7HNUGe7dwSDiUM8KXFi1fI764i5YP8 697YXV+oWY/QJOsgR4dO8ZJlzE3fU38Aff3qqYRbtlMz3GZpdBbRM6PDtGdjAYOr7ml9 Uudo8GhnbBs6fSjO9aKb0vlHZF0Es6yvNSIUmgLxDvgcexfzWVwXfWc7pdNong9kZPbG NH/A== 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 l14si7463385ejr.33.2021.01.30.15.55.25; Sat, 30 Jan 2021 15:55:49 -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 S232577AbhA3Xwz convert rfc822-to-8bit (ORCPT + 99 others); Sat, 30 Jan 2021 18:52:55 -0500 Received: from us-smtp-delivery-44.mimecast.com ([207.211.30.44]:54342 "EHLO us-smtp-delivery-44.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232585AbhA3Xur (ORCPT ); Sat, 30 Jan 2021 18:50:47 -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-167-9luKGOLhPxiIQote7aqnqg-1; Sat, 30 Jan 2021 18:49:52 -0500 X-MC-Unique: 9luKGOLhPxiIQote7aqnqg-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 C044E801817; Sat, 30 Jan 2021 23:49:50 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.192.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 196E860DA0; Sat, 30 Jan 2021 23:49:44 +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 16/24] perf daemon: Use control to stop session Date: Sun, 31 Jan 2021 00:48:48 +0100 Message-Id: <20210130234856.271282-17-jolsa@kernel.org> In-Reply-To: <20210130234856.271282-1-jolsa@kernel.org> References: <20210129134855.195810-1-jolsa@redhat.com> <20210130234856.271282-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 Using 'stop' control command to stop perf record session. If that fails, falling back to current SIGTERM/SIGKILL pair. Signed-off-by: Jiri Olsa --- tools/perf/builtin-daemon.c | 56 ++++++++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 10 deletions(-) diff --git a/tools/perf/builtin-daemon.c b/tools/perf/builtin-daemon.c index a5a71e0a706c..92dba933027d 100644 --- a/tools/perf/builtin-daemon.c +++ b/tools/perf/builtin-daemon.c @@ -821,11 +821,25 @@ static int setup_client_socket(struct daemon *daemon) static void session__kill(struct session *session, struct daemon *daemon) { - session__signal(session, SIGTERM); - if (session__wait(session, daemon, 10)) { - session__signal(session, SIGKILL); - session__wait(session, daemon, 10); - } + int how = 0; + + do { + switch (how) { + case 0: + session__control(session, "stop", false); + break; + case 1: + session__signal(session, SIGTERM); + break; + case 2: + session__signal(session, SIGKILL); + break; + default: + break; + } + how++; + + } while (session__wait(session, daemon, 10)); } static void daemon__signal(struct daemon *daemon, int sig) @@ -850,13 +864,35 @@ static void session__remove(struct session *session) session__free(session); } +static void daemon__stop(struct daemon *daemon) +{ + struct session *session; + + list_for_each_entry(session, &daemon->sessions, list) + 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__free(struct daemon *daemon) -- 2.29.2