From patchwork Thu Feb 8 11:31:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 198325 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp100558dyd; Thu, 8 Feb 2024 03:34:54 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUU0Ak/MlwRFcVvG3plbE9PZbX+N/PWvcaqDqyPJVxRsVqNiU12x+ogU1q7v1kc9iuBduYiicZnvTVtMIwTHaVe1UTNPg== X-Google-Smtp-Source: AGHT+IHDQCtL0hIkhPQH7i3D7UWejmcApX5kNhgGX3urPxUTzSJbICoe6LmRkiFalo7HrugMBbMD X-Received: by 2002:a0c:dd0d:0:b0:685:956e:b5d3 with SMTP id u13-20020a0cdd0d000000b00685956eb5d3mr6834156qvk.50.1707392094658; Thu, 08 Feb 2024 03:34:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707392094; cv=pass; d=google.com; s=arc-20160816; b=PjTVSOGXFu2Nesk9krYPCKx1JhIVTyeIFXQgt9h+Jib3i9cpvv2z4X2p50kcpVr96y mxnsFm+hfmesJqQEuux6Y2me05YeWVCCHH8DKC7kveyplvUfROIKkjRSzP+xNzNLx/Bj RP3bBj212HIMFBMywO3/o7UT0o/ZCqa9tx7jvZ+hhHor7CH6IsJOZWH+eu5InMHtI8ku iF/fW9SWreSOAXq4N0F9pn+xhG85ond/3dVcLxljhs6SWs4sE0JYmmNqJRu7NGKLLPGt wWeQhjwgJtZVj5gev0wESOc02GZ+ZN0hPX+E7e8fprT/PPIwzyHy3bRD+sfzYjXpgSw4 /uaA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:organization:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=vafCdf1yibEhLCmVzaQKAeNtSbGjfBKWgjv3J/PZUaU=; fh=Qbnupd4zvMNF8RMJCwqrxEu2ihOGcOdrQQiqCkc5YIg=; b=S7EEEQiPfUKBUVLnb/1nRbyc+6wFsvzzjj5DK61MD27niEQk9x4z8D3YvR3yw5Xglx 1IbWaqxOkYDaU5GxCZZwB7dafRk6LDGN8NsE6ktQ84Nt0JduTxKgSqZ2O7YgkSTHXgmf xP2h2RCGaDnptK7Z4OMeN/E1213zOpW9hsRTqYeLLd0o2Yt/7L/6k5rb/7+WyGI6rrL0 PoY6AA4nxr/P3JvOVfiQ7UFcgirPug6Wd2K7T3EF00WeGfOfKJ/NNWRG1yBXMnkyrZxz UmRHrPBBVSyyYsp6Saq+UbuuSECO9ItFwC3lxy9P2/w56yq9yvptRz4AKDephixLd9iH 0nfQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Wpmqx2D+; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-57968-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57968-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCU2DDijc2/US/A7HMY33xxsM+ofr4sLJiVeUVf4oyigyg9GdDInjzQp65/2NTmoCw4tHK763Rt5NtpT37p375s+Z7NnTg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id q12-20020a05620a038c00b0078543d7d078si3147663qkm.558.2024.02.08.03.34.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 03:34:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57968-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Wpmqx2D+; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-57968-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57968-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 637621C24450 for ; Thu, 8 Feb 2024 11:34:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9FA4E71B2A; Thu, 8 Feb 2024 11:32:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Wpmqx2D+" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F7F16D1C0; Thu, 8 Feb 2024 11:32:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707391956; cv=none; b=D8bEnGzTG5I9XGa3Ze7cR2sp44CkMwsRdoA4BEUEi49v1uOLgkEj1vwdBO7KkgaTh6XV7DOMr1QzszDgtKxO5opQwzuKoZaUev9/7QJhfwkE4rpm2q317eBS5JLQjmdIKMYjnH2z0Ouy8UKzCR2NIOD5Bq6YIDkABF4mlVXv5j4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707391956; c=relaxed/simple; bh=2iSO1ySUyp4r2AkDXYUIRVRUBZzCScMkb5LOJndj9HY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=R25BRF8wgvFeF4L9xJr8q3cUEHkdmNMYLRa2Zmash7TZIMXWXoZi5dulDQ7bkUQYcNgtIjyJzVxKY1ge74H2yEhI92c+ttF6z65ef+HqXrcEUHY03tzsZG7BUlG+NGBG6TgqVpALRrYBq8SqLZou92sC/59GCHWOGlJnr+azM/0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Wpmqx2D+; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707391953; x=1738927953; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2iSO1ySUyp4r2AkDXYUIRVRUBZzCScMkb5LOJndj9HY=; b=Wpmqx2D+/hIuayC3LZQ3HFJ5rXmQOTJ2hETaLdtAiho/Qqx0HirHuw+w uYz1TrlqiGLYVygpHhbhjDG/u+Grez3HN5Zy8y9GRtBXkufMxGu66JMQO DNjyAzSF8ZMT+8xsmDEvKKYRqoZg3ZLEbAIDHfpuDGczOqkhfMqm8PyIe ZCQ6EG2IFwqiDRiqLL+aMpLk2iFJ42Tm3hlmuTu0T9+udUSxXkK0b7+EU F1aW8xIwOsYEXqcUtvQMM690NY93gekdLkfeimijepE0gnPHHFT+MtX75 xKDgC5SQEulbH1jYjbQDl7ZEZ2O1mSDd2fZSlJM64wKz5lPsErX3omQRY g==; X-IronPort-AV: E=McAfee;i="6600,9927,10977"; a="1345682" X-IronPort-AV: E=Sophos;i="6.05,253,1701158400"; d="scan'208";a="1345682" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 03:32:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,253,1701158400"; d="scan'208";a="1957678" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.251.219.88]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 03:32:26 -0800 From: Adrian Hunter To: Peter Zijlstra Cc: Ingo Molnar , Mark Rutland , Alexander Shishkin , Heiko Carstens , Thomas Richter , Hendrik Brueckner , Suzuki K Poulose , Mike Leach , James Clark , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, Yicong Yang , Jonathan Cameron , Will Deacon , Arnaldo Carvalho de Melo , Jiri Olsa , Namhyung Kim , Ian Rogers , Andi Kleen , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: [PATCH V5 08/12] perf tools: Parse aux-action Date: Thu, 8 Feb 2024 13:31:23 +0200 Message-Id: <20240208113127.22216-9-adrian.hunter@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240208113127.22216-1-adrian.hunter@intel.com> References: <20240208113127.22216-1-adrian.hunter@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790330372909691915 X-GMAIL-MSGID: 1790330372909691915 Add parsing for aux-action to accept "pause", "resume" or "start-paused" values. "start-paused" is valid only for AUX area events. "pause" and "resume" are valid only for events grouped with an AUX area event as the group leader. However, like with aux-output, the events will be automatically grouped if they are not currently in a group, and the AUX area event precedes the other events. Signed-off-by: Adrian Hunter Acked-by: Ian Rogers --- tools/perf/Documentation/perf-record.txt | 4 ++ tools/perf/builtin-record.c | 4 +- tools/perf/util/auxtrace.c | 67 ++++++++++++++++++++++-- tools/perf/util/auxtrace.h | 6 ++- tools/perf/util/evsel.c | 1 + 5 files changed, 74 insertions(+), 8 deletions(-) diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt index 6015fdd08fb6..ccdba551e52d 100644 --- a/tools/perf/Documentation/perf-record.txt +++ b/tools/perf/Documentation/perf-record.txt @@ -68,6 +68,10 @@ OPTIONS like this: name=\'CPU_CLK_UNHALTED.THREAD:cmask=0x1\'. - 'aux-output': Generate AUX records instead of events. This requires that an AUX area event is also provided. + - 'aux-action': "pause" or "resume" to pause or resume an AUX + area event (the group leader) when this event occurs. + "start-paused" on an AUX area event itself, will + start in a paused state. - 'aux-sample-size': Set sample size for AUX area sampling. If the '--aux-sample' option has been used, set aux-sample-size=0 to disable AUX area sampling for the event. diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index c310eaad56ce..684a2768cf18 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -850,7 +850,9 @@ static int record__auxtrace_init(struct record *rec) if (err) return err; - auxtrace_regroup_aux_output(rec->evlist); + err = auxtrace_parse_aux_action(rec->evlist); + if (err) + return err; return auxtrace_parse_filters(rec->evlist); } diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index 3684e6009b63..67bd33ea2eaf 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -805,19 +805,76 @@ int auxtrace_parse_sample_options(struct auxtrace_record *itr, return auxtrace_validate_aux_sample_size(evlist, opts); } -void auxtrace_regroup_aux_output(struct evlist *evlist) +static struct aux_action_opt { + const char *str; + u32 aux_action; + bool aux_event_opt; +} aux_action_opts[] = { + {"start-paused", BIT(0), true}, + {"pause", BIT(1), false}, + {"resume", BIT(2), false}, + {NULL}, +}; + +static const struct aux_action_opt *auxtrace_parse_aux_action_str(const char *str) +{ + const struct aux_action_opt *opt; + + if (!str) + return NULL; + + for (opt = aux_action_opts; opt->str; opt++) + if (!strcmp(str, opt->str)) + return opt; + + return NULL; +} + +int auxtrace_parse_aux_action(struct evlist *evlist) { - struct evsel *evsel, *aux_evsel = NULL; struct evsel_config_term *term; + struct evsel *aux_evsel = NULL; + struct evsel *evsel; evlist__for_each_entry(evlist, evsel) { - if (evsel__is_aux_event(evsel)) + bool is_aux_event = evsel__is_aux_event(evsel); + const struct aux_action_opt *opt; + + if (is_aux_event) aux_evsel = evsel; - term = evsel__get_config_term(evsel, AUX_OUTPUT); + term = evsel__get_config_term(evsel, AUX_ACTION); + if (!term) { + if (evsel__get_config_term(evsel, AUX_OUTPUT)) + goto regroup; + continue; + } + opt = auxtrace_parse_aux_action_str(term->val.str); + if (!opt) { + pr_err("Bad aux-action '%s'\n", term->val.str); + return -EINVAL; + } + if (opt->aux_event_opt && !is_aux_event) { + pr_err("aux-action '%s' can only be used with AUX area event\n", + term->val.str); + return -EINVAL; + } + if (!opt->aux_event_opt && is_aux_event) { + pr_err("aux-action '%s' cannot be used for AUX area event itself\n", + term->val.str); + return -EINVAL; + } + evsel->core.attr.aux_action = opt->aux_action; +regroup: /* If possible, group with the AUX event */ - if (term && aux_evsel) + if (aux_evsel) evlist__regroup(evlist, aux_evsel, evsel); + if (!evsel__is_aux_event(evsel__leader(evsel))) { + pr_err("Events with aux-action must have AUX area event group leader\n"); + return -EINVAL; + } } + + return 0; } struct auxtrace_record *__weak diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h index 55702215a82d..35324ad12aad 100644 --- a/tools/perf/util/auxtrace.h +++ b/tools/perf/util/auxtrace.h @@ -579,7 +579,7 @@ int auxtrace_parse_snapshot_options(struct auxtrace_record *itr, int auxtrace_parse_sample_options(struct auxtrace_record *itr, struct evlist *evlist, struct record_opts *opts, const char *str); -void auxtrace_regroup_aux_output(struct evlist *evlist); +int auxtrace_parse_aux_action(struct evlist *evlist); int auxtrace_record__options(struct auxtrace_record *itr, struct evlist *evlist, struct record_opts *opts); @@ -800,8 +800,10 @@ int auxtrace_parse_sample_options(struct auxtrace_record *itr __maybe_unused, } static inline -void auxtrace_regroup_aux_output(struct evlist *evlist __maybe_unused) +int auxtrace_parse_aux_action(struct evlist *evlist __maybe_unused) { + pr_err("AUX area tracing not supported\n"); + return -EINVAL; } static inline diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 866c69f83595..8401685461bf 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -1002,6 +1002,7 @@ static void evsel__apply_config_terms(struct evsel *evsel, attr->aux_output = term->val.aux_output ? 1 : 0; break; case EVSEL__CONFIG_TERM_AUX_ACTION: + /* Already applied by auxtrace */ break; case EVSEL__CONFIG_TERM_AUX_SAMPLE_SIZE: /* Already applied by auxtrace */