Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp218357rdb; Thu, 8 Feb 2024 04:11:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXbY3CjlfPrH3CvDgo7bv0X5+U8WekA9bPq8Brr8Dl/T0y3dn0Lanm12sw4Uw1F1V4MKfsMWF6D9mfcN1l0fM0VZIpzsTDlum3fFNwvYw== X-Google-Smtp-Source: AGHT+IG+8W0iWYLqn13zhI1wR+yzUpuwJMvcCG/3X0IyQktTkzAyqJJNvAVAcvHAoLjQIo8f2GPJ X-Received: by 2002:a62:5fc6:0:b0:6e0:5281:e0d1 with SMTP id t189-20020a625fc6000000b006e05281e0d1mr5328488pfb.1.1707394285111; Thu, 08 Feb 2024 04:11:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707394285; cv=pass; d=google.com; s=arc-20160816; b=rLSfgTQ7k03wca2y+wS/gIvMWTDw32q4VP9Nv+NMMtQl1jX0njAYFilXHRD27K4lbo WM08BPgz337XCgm6sPvRVh1RUBPBydAobu+wVI+DSibm1u9th26AdALLq2lOpFo78/Ri fnZn8fYJJiwaVXO8lctHv1/7S8hGsmfZRblaTipqumzc62jlvVQ6y8tT5iIS2OWjIWg1 TOI+TF5D+511RYT8NAioVTug1znrNFShlomwJ6JcVsu6WO+GiB0NA+MHKo/hxP11wSz/ dv8QaD45aBWjaY8Q45jwu+PJmZF4dhSBLjfTfRuQdwT9kOk3lVWNDA2CebN4QdjtzZSj mAMw== 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=Pz55SEbo+1TY53uZkSoFvt7PtRIUSK9X41fROSL/Lls=; b=DxgpeXVQg0cw2JkLU317xcDrClYXwjJOENPt6539Qc8n9ZJLSQWn2v6X7SdN9YlAb3 9vegU1djagUkmdBj1SMK1FtNtKeGCHerUgvmqjfmtxnCHch+54qMK1OdqxBdEbhV8jUs NNWMf7Ljlvs0R3HKUrzvpBUzNkVfjjl0n7zonbT2J34HDzI3pmwHiAXv2hL0PHGVBelv idbFTVk3lwuUH6XL5dZL0yQemulyecFAipUKBujF6TBAwtC/aADh7YXG1J2daIClSF2Q OmIYOc9Bo8Nw3Jv8s74V7+f2O59dV5Cf65iVJuRGQx/dvg59AMB5fAqrlBk374jYxWF8 9yUg==; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57968-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCX3e89ebeurJ3x6iu+Y50KMFxz0262Kg8OuE36R/b5Bbzxy3Z9pm1Mi8GEiMfiDMqxqZY30/3NoJ/rUcXvRLUgN/GsTCLzAGjky2k4hWg== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id v15-20020aa7850f000000b006dd8a272463si3758541pfn.246.2024.02.08.04.11.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 04:11:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57968-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57968-linux.lists.archive=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 168E0B28717 for ; Thu, 8 Feb 2024 11:34:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 194CE76405; Thu, 8 Feb 2024 11:32:37 +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 Content-Transfer-Encoding: 8bit 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 */ -- 2.34.1