From patchwork Thu Feb 8 11:31:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 198318 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp99452dyd; Thu, 8 Feb 2024 03:32:24 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUvWLYI7zcAFIkuyxMEle/eSoo7AmkQzVP6p0itZZf7eIq77P0AJ3Jii8ut8hTLS19i7Cjsv+5nqmlao2hP2j3R1ayUZg== X-Google-Smtp-Source: AGHT+IGllq/Pp+3iBEA/uhwYjPKv8G96Q+88eSYk6b+W4w42jWVzC5RiPShY4DnoAIMcawCRk/ov X-Received: by 2002:aa7:c342:0:b0:560:12cf:c83 with SMTP id j2-20020aa7c342000000b0056012cf0c83mr5996993edr.22.1707391944645; Thu, 08 Feb 2024 03:32:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707391944; cv=pass; d=google.com; s=arc-20160816; b=pD1TUHgD8rRUMAnG4izw+NLoMoiLbljdL3X6GOvOwVld/H1HP6zTvEripxJsxMALkf UvAw/R3A3IYl8qXz9CkQF6irBAABdm8rCvPrATx4nudNCWfur9ae1kt7jtyeKIVCaDZX Z9XWG+bOPmBvYFfCaoByHzKU6OS8v5rPgmgtvpuovCTTapRxFil7nz9tt1H8npRJvk4h vzNuRU62t/IweFY7GKcv2sZTHN8gMDVpe/u7WZXPHQB7EL5ohI5JNAkChEetd4p0qq21 x7jw+yGhOP0gs0t6aauTTejmao+GdhV6hALIGc7t9JDF+PsT9zdT6gJyInkTmnLMeAka 1ugw== 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=CbfoUjDicxFId4yWxr6OB+u9sG5l7I4TumF2YbuxttA=; fh=QoJZnmP8TQ30dfMoch1ueQAIdWM58SoOCRPtZARhA+0=; b=K0U7fjyBR8jb3CNPOva3z7jQXiPsF3O+BcfJ8nN+MOhjM61YmIh7U+wWEnHwRv7XPM xO+wFpvukg1cN+Da4RYCNZcVUqv1nGdpBlNVDFiBRg5v8ANdq5gSKTkEFrZuI7ZXRCgL aMWTvkjrR0DPVps1STQyoEo7l+PLceUauG3DhgpcuuJUYI4j9sqRg98APR3lJWzvMaD2 5Sh5RXS1lOl//iXcFIxufAvvoLIJnpEfO1Y9euw9M1VAZiGSRc2oFU2/O1WpigU9SpyX 8/VImofBB2RREI3EfQKDId3ql6LtXI6aEGGRz6sDtrrRbnhulJdyiVJ8wfWosy8Q9or/ fxIg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ym9f7o9C; 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-57960-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57960-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCVMYjJLE6WcOGW/9LpVJqFIuAIUA82lB4y+rIPg6FR86h4dfFjdbsR8I5Fxck2vlgAbB9/TYZsPWMZpOzyVKCppGG+Dkw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id h4-20020a50ed84000000b00560e8c52074si778941edr.454.2024.02.08.03.32.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 03:32:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57960-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ym9f7o9C; 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-57960-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57960-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 18D271F283BA for ; Thu, 8 Feb 2024 11:32:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F1A671DFCE; Thu, 8 Feb 2024 11:31:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Ym9f7o9C" 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 5019A6F51E; Thu, 8 Feb 2024 11:31:50 +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=1707391913; cv=none; b=N1HlWQ0QBVP/v04oZCvgA68Dc2osuYbPzQ8O34xDrxGLeJ/rYawVqsLWZz4vhy64erF4HhMQn9xO+n4UPsyCyhnpW+8/A+2OtKn1pj7ernocTNWEwQo9OBDSwZZhGIo0Lu0IrY40NHbz5pGBNdo0j33rh6bYjIhhDRpMEKY4c3Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707391913; c=relaxed/simple; bh=cZM1w1SKDny69+A93iB/1D8/a1VKdkgLdhEhZzavNc0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qePgojdxx/ssQq4tm0Qitl4b6frZ8B06R2rAoaDubtf9M1OOpSQG7vVRB8sSJNiXZ8gwjJk2yctEhj5tkg2f9jwct/Utesb3eas0YUb2ufSYk7h/tAXEYX0qETltPb98KTPpWbY0WOVjjSftedAFgA7pzw1QoOvRQp6meM6UB8w= 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=Ym9f7o9C; 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=1707391912; x=1738927912; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cZM1w1SKDny69+A93iB/1D8/a1VKdkgLdhEhZzavNc0=; b=Ym9f7o9CPWXb7bFgrXzPy9uaPMRqR+uRdTyBDMrvdHkeEQe+O7SWfpdn 8vE13xqxl2CPN1stG4LOMcmOY4FPnDzkgLKwJ5bxOgpzmPOnjCYpfwCXb Mb2fqW81TWupOdxVyeQJj/W8CHzHwKKDO0iuo1vPZKrT/rlW57QCSPslB KOjOF7mXSquFEp3Ck0FMJFLzgDXKfqwZTVfw1dDWw7emXIrBc5IfePwOU C5Zt7l2T6gWsWHF0Bqoo7Ym8/c8uicfGKEyRG+CZO/rgGlpKntNMd4dmK cuSWs8l65nWIVE24vql+0Vi8FRSuIOt9wnNfIx0vzBRSIiLDs6HAevfPZ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10977"; a="1345428" X-IronPort-AV: E=Sophos;i="6.05,253,1701158400"; d="scan'208";a="1345428" 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:31:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,253,1701158400"; d="scan'208";a="1957425" 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:31:44 -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 01/12] perf/core: Add aux_pause, aux_resume, aux_start_paused Date: Thu, 8 Feb 2024 13:31:16 +0200 Message-Id: <20240208113127.22216-2-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: 1790330215289910922 X-GMAIL-MSGID: 1790330215289910922 Hardware traces, such as instruction traces, can produce a vast amount of trace data, so being able to reduce tracing to more specific circumstances can be useful. The ability to pause or resume tracing when another event happens, can do that. Add ability for an event to "pause" or "resume" AUX area tracing. Add aux_pause bit to perf_event_attr to indicate that, if the event happens, the associated AUX area tracing should be paused. Ditto aux_resume. Do not allow aux_pause and aux_resume to be set together. Add aux_start_paused bit to perf_event_attr to indicate to an AUX area event that it should start in a "paused" state. Add aux_paused to struct perf_event for AUX area events to keep track of the "paused" state. aux_paused is initialized to aux_start_paused. Add PERF_EF_PAUSE and PERF_EF_RESUME modes for ->stop() and ->start() callbacks. Call as needed, during __perf_event_output(). Add aux_in_pause_resume to struct perf_buffer to prevent races with the NMI handler. Pause/resume in NMI context will miss out if it coincides with another pause/resume. To use aux_pause or aux_resume, an event must be in a group with the AUX area event as the group leader. Example (requires Intel PT and tools patches also): $ perf record --kcore -e intel_pt/aux-action=start-paused/k,syscalls:sys_enter_newuname/aux-action=resume/,syscalls:sys_exit_newuname/aux-action=pause/ uname Linux [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.043 MB perf.data ] $ perf script --call-trace uname 30805 [000] 24001.058782799: name: 0x7ffc9c1865b0 uname 30805 [000] 24001.058784424: psb offs: 0 uname 30805 [000] 24001.058784424: cbr: 39 freq: 3904 MHz (139%) uname 30805 [000] 24001.058784629: ([kernel.kallsyms]) debug_smp_processor_id uname 30805 [000] 24001.058784629: ([kernel.kallsyms]) __x64_sys_newuname uname 30805 [000] 24001.058784629: ([kernel.kallsyms]) down_read uname 30805 [000] 24001.058784629: ([kernel.kallsyms]) __cond_resched uname 30805 [000] 24001.058784629: ([kernel.kallsyms]) preempt_count_add uname 30805 [000] 24001.058784629: ([kernel.kallsyms]) in_lock_functions uname 30805 [000] 24001.058784629: ([kernel.kallsyms]) preempt_count_sub uname 30805 [000] 24001.058784629: ([kernel.kallsyms]) up_read uname 30805 [000] 24001.058784629: ([kernel.kallsyms]) preempt_count_add uname 30805 [000] 24001.058784838: ([kernel.kallsyms]) in_lock_functions uname 30805 [000] 24001.058784838: ([kernel.kallsyms]) preempt_count_sub uname 30805 [000] 24001.058784838: ([kernel.kallsyms]) _copy_to_user uname 30805 [000] 24001.058784838: ([kernel.kallsyms]) syscall_exit_to_user_mode uname 30805 [000] 24001.058784838: ([kernel.kallsyms]) syscall_exit_work uname 30805 [000] 24001.058784838: ([kernel.kallsyms]) perf_syscall_exit uname 30805 [000] 24001.058784838: ([kernel.kallsyms]) debug_smp_processor_id uname 30805 [000] 24001.058785046: ([kernel.kallsyms]) perf_trace_buf_alloc uname 30805 [000] 24001.058785046: ([kernel.kallsyms]) perf_swevent_get_recursion_context uname 30805 [000] 24001.058785046: ([kernel.kallsyms]) debug_smp_processor_id uname 30805 [000] 24001.058785046: ([kernel.kallsyms]) debug_smp_processor_id uname 30805 [000] 24001.058785046: ([kernel.kallsyms]) perf_tp_event uname 30805 [000] 24001.058785046: ([kernel.kallsyms]) perf_trace_buf_update uname 30805 [000] 24001.058785046: ([kernel.kallsyms]) tracing_gen_ctx_irq_test uname 30805 [000] 24001.058785046: ([kernel.kallsyms]) perf_swevent_event uname 30805 [000] 24001.058785046: ([kernel.kallsyms]) __perf_event_account_interrupt uname 30805 [000] 24001.058785046: ([kernel.kallsyms]) __this_cpu_preempt_check uname 30805 [000] 24001.058785046: ([kernel.kallsyms]) perf_event_output_forward uname 30805 [000] 24001.058785046: ([kernel.kallsyms]) perf_event_aux_pause uname 30805 [000] 24001.058785046: ([kernel.kallsyms]) ring_buffer_get uname 30805 [000] 24001.058785046: ([kernel.kallsyms]) __rcu_read_lock uname 30805 [000] 24001.058785046: ([kernel.kallsyms]) __rcu_read_unlock uname 30805 [000] 24001.058785254: ([kernel.kallsyms]) pt_event_stop uname 30805 [000] 24001.058785254: ([kernel.kallsyms]) debug_smp_processor_id uname 30805 [000] 24001.058785254: ([kernel.kallsyms]) debug_smp_processor_id uname 30805 [000] 24001.058785254: ([kernel.kallsyms]) native_write_msr uname 30805 [000] 24001.058785463: ([kernel.kallsyms]) native_write_msr uname 30805 [000] 24001.058785639: 0x0 Signed-off-by: Adrian Hunter Acked-by: James Clark --- Changes in V5: Added James' Ack Changes in V4: Rename aux_output_cfg -> aux_action Reorder aux_action bits from: aux_pause, aux_resume, aux_start_paused to: aux_start_paused, aux_pause, aux_resume Fix aux_action bits __u64 -> __u32 include/linux/perf_event.h | 15 +++++++ include/uapi/linux/perf_event.h | 11 ++++- kernel/events/core.c | 72 +++++++++++++++++++++++++++++++-- kernel/events/internal.h | 1 + 4 files changed, 95 insertions(+), 4 deletions(-) diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index d2a15c0c6f8a..6c1600b9bdb3 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -291,6 +291,7 @@ struct perf_event_pmu_context; #define PERF_PMU_CAP_NO_EXCLUDE 0x0040 #define PERF_PMU_CAP_AUX_OUTPUT 0x0080 #define PERF_PMU_CAP_EXTENDED_HW_TYPE 0x0100 +#define PERF_PMU_CAP_AUX_PAUSE 0x0200 struct perf_output_handle; @@ -363,6 +364,8 @@ struct pmu { #define PERF_EF_START 0x01 /* start the counter when adding */ #define PERF_EF_RELOAD 0x02 /* reload the counter when starting */ #define PERF_EF_UPDATE 0x04 /* update the counter when stopping */ +#define PERF_EF_PAUSE 0x08 /* AUX area event, pause tracing */ +#define PERF_EF_RESUME 0x10 /* AUX area event, resume tracing */ /* * Adds/Removes a counter to/from the PMU, can be done inside a @@ -402,6 +405,15 @@ struct pmu { * * ->start() with PERF_EF_RELOAD will reprogram the counter * value, must be preceded by a ->stop() with PERF_EF_UPDATE. + * + * ->stop() with PERF_EF_PAUSE will stop as simply as possible. Will not + * overlap another ->stop() with PERF_EF_PAUSE nor ->start() with + * PERF_EF_RESUME. + * + * ->start() with PERF_EF_RESUME will start as simply as possible but + * only if the counter is not otherwise stopped. Will not overlap + * another ->start() with PERF_EF_RESUME nor ->stop() with + * PERF_EF_PAUSE. */ void (*start) (struct perf_event *event, int flags); void (*stop) (struct perf_event *event, int flags); @@ -798,6 +810,9 @@ struct perf_event { /* for aux_output events */ struct perf_event *aux_event; + /* for AUX area events */ + unsigned int aux_paused; + void (*destroy)(struct perf_event *); struct rcu_head rcu_head; diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h index 3a64499b0f5d..0c557f0a17b3 100644 --- a/include/uapi/linux/perf_event.h +++ b/include/uapi/linux/perf_event.h @@ -511,7 +511,16 @@ struct perf_event_attr { __u16 sample_max_stack; __u16 __reserved_2; __u32 aux_sample_size; - __u32 __reserved_3; + + union { + __u32 aux_action; + struct { + __u32 aux_start_paused : 1, /* start AUX area tracing paused */ + aux_pause : 1, /* on overflow, pause AUX area tracing */ + aux_resume : 1, /* on overflow, resume AUX area tracing */ + __reserved_3 : 29; + }; + }; /* * User provided data if sigtrap=1, passed back to user via diff --git a/kernel/events/core.c b/kernel/events/core.c index f0f0f71213a1..00f6d0a327e8 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -2097,7 +2097,8 @@ static void perf_put_aux_event(struct perf_event *event) static bool perf_need_aux_event(struct perf_event *event) { - return !!event->attr.aux_output || !!event->attr.aux_sample_size; + return event->attr.aux_output || event->attr.aux_sample_size || + event->attr.aux_pause || event->attr.aux_resume; } static int perf_get_aux_event(struct perf_event *event, @@ -2122,6 +2123,10 @@ static int perf_get_aux_event(struct perf_event *event, !perf_aux_output_match(event, group_leader)) return 0; + if ((event->attr.aux_pause || event->attr.aux_resume) && + !(group_leader->pmu->capabilities & PERF_PMU_CAP_AUX_PAUSE)) + return 0; + if (event->attr.aux_sample_size && !group_leader->pmu->snapshot_aux) return 0; @@ -7854,6 +7859,47 @@ void perf_prepare_header(struct perf_event_header *header, WARN_ON_ONCE(header->size & 7); } +static void __perf_event_aux_pause(struct perf_event *event, bool pause) +{ + if (pause) { + if (!READ_ONCE(event->aux_paused)) { + WRITE_ONCE(event->aux_paused, 1); + event->pmu->stop(event, PERF_EF_PAUSE); + } + } else { + if (READ_ONCE(event->aux_paused)) { + WRITE_ONCE(event->aux_paused, 0); + event->pmu->start(event, PERF_EF_RESUME); + } + } +} + +static void perf_event_aux_pause(struct perf_event *event, bool pause) +{ + struct perf_buffer *rb; + unsigned long flags; + + if (WARN_ON_ONCE(!event)) + return; + + rb = ring_buffer_get(event); + if (!rb) + return; + + local_irq_save(flags); + /* Guard against NMI, NMI loses here */ + if (READ_ONCE(rb->aux_in_pause_resume)) + goto out_restore; + WRITE_ONCE(rb->aux_in_pause_resume, 1); + barrier(); + __perf_event_aux_pause(event, pause); + barrier(); + WRITE_ONCE(rb->aux_in_pause_resume, 0); +out_restore: + local_irq_restore(flags); + ring_buffer_put(rb); +} + static __always_inline int __perf_event_output(struct perf_event *event, struct perf_sample_data *data, @@ -7867,6 +7913,9 @@ __perf_event_output(struct perf_event *event, struct perf_event_header header; int err; + if (event->attr.aux_pause) + perf_event_aux_pause(event->aux_event, true); + /* protect the callchain buffers */ rcu_read_lock(); @@ -7883,6 +7932,10 @@ __perf_event_output(struct perf_event *event, exit: rcu_read_unlock(); + + if (event->attr.aux_resume) + perf_event_aux_pause(event->aux_event, false); + return err; } @@ -12036,10 +12089,23 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu, } if (event->attr.aux_output && - !(pmu->capabilities & PERF_PMU_CAP_AUX_OUTPUT)) { + (!(pmu->capabilities & PERF_PMU_CAP_AUX_OUTPUT) || + event->attr.aux_pause || event->attr.aux_resume)) { + err = -EOPNOTSUPP; + goto err_pmu; + } + + if (event->attr.aux_pause && event->attr.aux_resume) { + err = -EINVAL; + goto err_pmu; + } + + if (event->attr.aux_start_paused && + !(pmu->capabilities & PERF_PMU_CAP_AUX_PAUSE)) { err = -EOPNOTSUPP; goto err_pmu; } + event->aux_paused = event->attr.aux_start_paused; if (cgroup_fd != -1) { err = perf_cgroup_connect(cgroup_fd, event, attr, group_leader); @@ -12836,7 +12902,7 @@ perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu, * Grouping is not supported for kernel events, neither is 'AUX', * make sure the caller's intentions are adjusted. */ - if (attr->aux_output) + if (attr->aux_output || attr->aux_action) return ERR_PTR(-EINVAL); event = perf_event_alloc(attr, cpu, task, NULL, NULL, diff --git a/kernel/events/internal.h b/kernel/events/internal.h index 5150d5f84c03..3320f78117dc 100644 --- a/kernel/events/internal.h +++ b/kernel/events/internal.h @@ -51,6 +51,7 @@ struct perf_buffer { void (*free_aux)(void *); refcount_t aux_refcount; int aux_in_sampling; + int aux_in_pause_resume; void **aux_pages; void *aux_priv; From patchwork Thu Feb 8 11:31:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 198319 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp99622dyd; Thu, 8 Feb 2024 03:32:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVnFPYDIkd95A/42+Q7bLaxQYMwnrz07M4vn239etwvC2PeUtsp7CWNeXnUAB0gOVDh6vY4aOuee4cm2w/3cT43H2zxFA== X-Google-Smtp-Source: AGHT+IGkukuMXOMSWy9E2f3nIIFtLCuGWmhPGmv+g5ncCAnG/xyokaXtXEQwVK5TDQfZ2XRY4xqz X-Received: by 2002:ac8:5712:0:b0:42c:3cf5:bb3 with SMTP id 18-20020ac85712000000b0042c3cf50bb3mr7027596qtw.50.1707391961573; Thu, 08 Feb 2024 03:32:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707391961; cv=pass; d=google.com; s=arc-20160816; b=Q2+PfyeCr/Cmd1sa51VvQ+vNqZkpeb9U6OUYftTwRT1OOWBspZ3sG7ofxuKooOhBV2 a3/d45DUXJ0ve4Y2KY7aq8iRCuE5eKq37/6+D5N99ImI8pB6QR04oZhDWMPb8SIqlVil tydWIQYYKndO087O/7jf7EhFZ9KFei7uQHou9PlMa/fLVtrIo4p9jt0RPzKCK1aCmj3p 0IKZW9jvVMOT3Cbe3rpbO3qk6dPMB7jqrE7WLo/PCccUq0Hv23+8AKDpEqnVDsW67pbD SFMsRC+oMkghmY2x610GnrJ9DJfg6oylbsbwTmRFjBxF8srRSl6uXOj7nH9cq2fSRV7w 5XVQ== 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=ZAoJh1j0Di4wYSFbYTDDnq6BgTH3rz9aDeDz64xNdmw=; fh=5ZIEUNHPYls9wQMtD8/u5c8Szvu8eN7vHJ/I/9hrVcU=; b=Co+YSeptu7lv+Cv2bt9WrRCQpspqbuNAPBJz00MlFIRsgT2mv5Eh7s2eCb0jjPRFsq rcwCSmI2pT41gkz3tfKY8481+BdDkER0/wkDe3wZjI2EvgcMiDPRzS7eZmVvrqAwKyYJ YFHVdKABUMqZqr6JWZ1/An/VNwz/TGIfdQi8go8Pa3sRIvuChXbhtqrBNu1MMRyZA/C3 Jl2rmVLQubA3TG5a87Mgeutq9Tzlk813FqjlpccZIgW+CHY3Nf3heeInlnGTNFEXxWHd DGcxpe/vPuvUe8vqYaKuTJM+znttjbk7POp2rMggFzZCPOXgu/VJvy1Fc+dWFV6pekBc ywDw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ihNFAZ8u; 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-57961-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57961-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCWgGFWEhSsG0/kjfLAepmNR/AeyuB9+YR4d1UI7IN8ajK2CNRFvYhVUluJoYAnUPyyxG7g62nyi9/ynmCuQXe/IKP8/FQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o13-20020a05622a044d00b0042c0c755099si2941790qtx.243.2024.02.08.03.32.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 03:32:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57961-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=ihNFAZ8u; 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-57961-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57961-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 4D05E1C212A7 for ; Thu, 8 Feb 2024 11:32:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B3ABE71B33; Thu, 8 Feb 2024 11:32:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ihNFAZ8u" 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 8A30F6F532; Thu, 8 Feb 2024 11:31:56 +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=1707391918; cv=none; b=S385zmfrbhBRA6b+DpsTkjHfS92280XShXBdLODWP61gsTtsHqAg6vZ0xa+7sW9B+37kDKOqYi32EtauBziAxsFbOqaWWbub+97ftQ4ZfMPa/PzKT8h1YXKfIE1wMxnEvzbAxzn/9E2WRNfD62Q8a2zKLWNCNIQ9AcDIDF7fug8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707391918; c=relaxed/simple; bh=dfTBIiFpANJlz5aBagh7IAvClVgFJ19Fw8e6sothvfM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TPyc9J7TvV4r0uQ9KMM20WcPLFpZxl/nlJGyEd+uf5J7Od8s1999Co2hnnyDCnrSihgAkaUVUh9iV+hcVnq+ewwK4a++Mu9cuPlRh8H3j3s/uVb2zOUCNAlviqu7I7B3ASCW53t10D2H7rYeYIWjHJXqoLgBdLBv0tdondnnG8E= 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=ihNFAZ8u; 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=1707391917; x=1738927917; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dfTBIiFpANJlz5aBagh7IAvClVgFJ19Fw8e6sothvfM=; b=ihNFAZ8uMJv+JUJrwgkq4PV0WW4bMn4npY4loQ+lc6M21vpgdSk13SyD ns2Cc4BpvuTazfKep/tR5wYimU6C+qc/nRXKATSQaRU07FmnJ/2r2QtPG ValUcCEAo4uLdNUNVsah3gQgTDHUixYHB8CZxv9L5NyZ5lcCBPF2Pgdhw 66ERWwLTDryWanqmbjRj5jN1PLOX8hQfjC5fedBbvohZ1LV2UNKX80waV TzvhPSzAwkwm58fdju0jniYcwgSd8YEOHDwa41jiAAAe5GDs/9AuFTmYO 7pat5a0YPG7x7XQFm7ordpv8xlvVZ6yeamyQEwbu/aWB6yZOiWXJlYTxK A==; X-IronPort-AV: E=McAfee;i="6600,9927,10977"; a="1345467" X-IronPort-AV: E=Sophos;i="6.05,253,1701158400"; d="scan'208";a="1345467" 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:31:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,253,1701158400"; d="scan'208";a="1957440" 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:31:50 -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 02/12] perf/x86/intel/pt: Add support for pause / resume Date: Thu, 8 Feb 2024 13:31:17 +0200 Message-Id: <20240208113127.22216-3-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: 1790330233167565512 X-GMAIL-MSGID: 1790330233167565512 Prevent tracing to start if aux_paused. Implement support for PERF_EF_PAUSE / PERF_EF_RESUME. When aux_paused, stop tracing. When not aux_paused, only start tracing if it isn't currently meant to be stopped. Signed-off-by: Adrian Hunter --- arch/x86/events/intel/pt.c | 63 ++++++++++++++++++++++++++++++++++++-- arch/x86/events/intel/pt.h | 4 +++ 2 files changed, 64 insertions(+), 3 deletions(-) diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c index 8e2a12235e62..b6e838f2c6d5 100644 --- a/arch/x86/events/intel/pt.c +++ b/arch/x86/events/intel/pt.c @@ -418,6 +418,9 @@ static void pt_config_start(struct perf_event *event) struct pt *pt = this_cpu_ptr(&pt_ctx); u64 ctl = event->hw.config; + if (READ_ONCE(event->aux_paused)) + return; + ctl |= RTIT_CTL_TRACEEN; if (READ_ONCE(pt->vmx_on)) perf_aux_output_flag(&pt->handle, PERF_AUX_FLAG_PARTIAL); @@ -534,7 +537,20 @@ static void pt_config(struct perf_event *event) reg |= (event->attr.config & PT_CONFIG_MASK); event->hw.config = reg; + + /* + * Allow resume before starting so as not to overwrite a value set by a + * PMI. + */ + WRITE_ONCE(pt->resume_allowed, 1); + pt_config_start(event); + + /* + * Allow pause after starting so its pt_config_stop() doesn't race with + * pt_config_start(). + */ + WRITE_ONCE(pt->pause_allowed, 1); } static void pt_config_stop(struct perf_event *event) @@ -1511,6 +1527,7 @@ void intel_pt_interrupt(void) buf = perf_aux_output_begin(&pt->handle, event); if (!buf) { event->hw.state = PERF_HES_STOPPED; + pt->resume_allowed = 0; return; } @@ -1519,6 +1536,7 @@ void intel_pt_interrupt(void) ret = pt_buffer_reset_markers(buf, &pt->handle); if (ret) { perf_aux_output_end(&pt->handle, 0); + pt->resume_allowed = 0; return; } @@ -1573,6 +1591,26 @@ static void pt_event_start(struct perf_event *event, int mode) struct pt *pt = this_cpu_ptr(&pt_ctx); struct pt_buffer *buf; + if (mode & PERF_EF_RESUME) { + if (READ_ONCE(pt->resume_allowed)) { + u64 status; + + /* + * Only if the trace is not active and the error and + * stopped bits are clear, is it safe to start, but a + * PMI might have just cleared these, so resume_allowed + * must be checked again also. + */ + rdmsrl(MSR_IA32_RTIT_STATUS, status); + if (!(status & (RTIT_STATUS_TRIGGEREN | + RTIT_STATUS_ERROR | + RTIT_STATUS_STOPPED)) && + READ_ONCE(pt->resume_allowed)) + pt_config_start(event); + } + return; + } + buf = perf_aux_output_begin(&pt->handle, event); if (!buf) goto fail_stop; @@ -1601,6 +1639,16 @@ static void pt_event_stop(struct perf_event *event, int mode) { struct pt *pt = this_cpu_ptr(&pt_ctx); + if (mode & PERF_EF_PAUSE) { + if (READ_ONCE(pt->pause_allowed)) + pt_config_stop(event); + return; + } + + /* Protect against racing */ + WRITE_ONCE(pt->pause_allowed, 0); + WRITE_ONCE(pt->resume_allowed, 0); + /* * Protect against the PMI racing with disabling wrmsr, * see comment in intel_pt_interrupt(). @@ -1659,8 +1707,12 @@ static long pt_event_snapshot_aux(struct perf_event *event, /* * Here, handle_nmi tells us if the tracing is on */ - if (READ_ONCE(pt->handle_nmi)) + if (READ_ONCE(pt->handle_nmi)) { + /* Protect against racing */ + WRITE_ONCE(pt->pause_allowed, 0); + WRITE_ONCE(pt->resume_allowed, 0); pt_config_stop(event); + } pt_read_offset(buf); pt_update_head(pt); @@ -1677,8 +1729,11 @@ static long pt_event_snapshot_aux(struct perf_event *event, * Compiler barrier not needed as we couldn't have been * preempted by anything that touches pt->handle_nmi. */ - if (pt->handle_nmi) + if (pt->handle_nmi) { + WRITE_ONCE(pt->resume_allowed, 1); pt_config_start(event); + WRITE_ONCE(pt->pause_allowed, 1); + } return ret; } @@ -1794,7 +1849,9 @@ static __init int pt_init(void) if (!intel_pt_validate_hw_cap(PT_CAP_topa_multiple_entries)) pt_pmu.pmu.capabilities = PERF_PMU_CAP_AUX_NO_SG; - pt_pmu.pmu.capabilities |= PERF_PMU_CAP_EXCLUSIVE | PERF_PMU_CAP_ITRACE; + pt_pmu.pmu.capabilities |= PERF_PMU_CAP_EXCLUSIVE | + PERF_PMU_CAP_ITRACE | + PERF_PMU_CAP_AUX_PAUSE; pt_pmu.pmu.attr_groups = pt_attr_groups; pt_pmu.pmu.task_ctx_nr = perf_sw_context; pt_pmu.pmu.event_init = pt_event_init; diff --git a/arch/x86/events/intel/pt.h b/arch/x86/events/intel/pt.h index 96906a62aacd..b9527205e028 100644 --- a/arch/x86/events/intel/pt.h +++ b/arch/x86/events/intel/pt.h @@ -117,6 +117,8 @@ struct pt_filters { * @filters: last configured filters * @handle_nmi: do handle PT PMI on this cpu, there's an active event * @vmx_on: 1 if VMX is ON on this cpu + * @pause_allowed: PERF_EF_PAUSE is allowed to stop tracing + * @resume_allowed: PERF_EF_RESUME is allowed to start tracing * @output_base: cached RTIT_OUTPUT_BASE MSR value * @output_mask: cached RTIT_OUTPUT_MASK MSR value */ @@ -125,6 +127,8 @@ struct pt { struct pt_filters filters; int handle_nmi; int vmx_on; + int pause_allowed; + int resume_allowed; u64 output_base; u64 output_mask; }; From patchwork Thu Feb 8 11:31:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 198320 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp99736dyd; Thu, 8 Feb 2024 03:32:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXwuNsdgiYCDN9cHAed02VHtIvaycgg9DOmvmSx9JoWv3GRN7NyC93ddfNfMrBEURU3dDIbMI9NDofFtEPWQcR6lGBC3A== X-Google-Smtp-Source: AGHT+IHCnIRMU1Q4zXxBW7CQHWRwLlfxSOm+Q+Bm2pf44vIWv6Brbi7X/xgpnLn2dCDt2g59oxuX X-Received: by 2002:a50:ec84:0:b0:55e:ea35:1da4 with SMTP id e4-20020a50ec84000000b0055eea351da4mr5718576edr.4.1707391979573; Thu, 08 Feb 2024 03:32:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707391979; cv=pass; d=google.com; s=arc-20160816; b=OxUHjelSeE3cMdCuYoS+yXPJlzKAr1vpAJJS0k8Ig/fpUQ9WC30dhqlf7NDs3tNPFM DqxKQPT7DBQ4C01bno4M/i04Iuugw3NM6iwgQE/T/fTcCrbNRtxAXlpoAjSgfdmr9kWo wwAJz0eLbjoz7Wfdb8dxS0BFvKFtlGCuaxuHhGGkK79IRa3MBs6k8IHZSkberWU50hKH oELvGolkn8Aiccbbcb3Kbw4t365SxoIUOrCBafcKBAhVWoa0leqNlfqx7PU+rT2GFj+a X7gZnmgGVQsr5Q4nBOS6cbdoYVqezNMGhKmJDTuE+m2W6aMBnUxfxll5FVjB/RdpnCx+ 0J/g== 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=pPrWuGU9BYcinxnrgFFLKon4UrDUwc9o6dTRHvFpQ8c=; fh=YPxTHplBLZMNfUa2Yvd+nNr/6WpYcHvayMBXcPVs8P8=; b=OtcA0ZTQqxMXqgsrt4wdMqt0253tXZ8UQ/I7IojIqpga39dAoDMwfTfN71ZoKtz/3s Oh+7EGdBw2ed+a1lWes+R2MtSO7raXiZGAuLDs1DU3O0PPft3PY+pek+UvKIVWXsGK4T kOUaT96rEz+a9h3BPis+Gkeq8H+jYBMdS5CxQZj4hAz003MDJS2Qi+NWyRTAPGfJ+dLm qRbPxR66lm3GBSdxFuEPTd93fe4Q4+LBqet0qZziDTZvfl2vNfWUM4wCq9PLlCmwp4CF pPDvGhiMJ0R7NeOXTBPK/s+kxxfqryCdO2lDoHW+KcnBxF9fAuwepdAQbOEFAc90YcYn swrw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=G6LFcP28; 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-57962-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57962-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCXgQ0q4L+Hchc8ocVrqPbdMqw4ljWlMKYAJLSTCgn42tpt0mXgiUErMa+h/6SmTSU2TljIhmgfi5TDYI0zbRHN9VjsWBQ== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id l8-20020a056402124800b005610ef3032bsi457288edw.205.2024.02.08.03.32.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 03:32:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57962-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=G6LFcP28; 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-57962-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57962-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 2D40F1F28A0A for ; Thu, 8 Feb 2024 11:32:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A5FA46F50C; Thu, 8 Feb 2024 11:32:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="G6LFcP28" 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 6FE0A71B4A; Thu, 8 Feb 2024 11:32:02 +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=1707391923; cv=none; b=b6Y47gioKS6M7aT3LBL3NdJ0bYRV6ljtjVVgaCDTpgLOPcFs98D81scBTqhGtFETIMkLSjr0atuEa1jKKLyLOn2FNN0qz8/+Tb62C1TeDu2U2yzq26zSNuGpoccFKe3KG8UgkOznBAT3yp01T0QzzOy42PBBy+Wwx14HG+XLo/M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707391923; c=relaxed/simple; bh=ymurIB97b11IqH9GZGJPPvkYT9r0Cf4QevmMQfDhVpY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BHuzshRCFuBqCYPvXzHWx52HfWDhkG6IyWX2KkoBH0XLdXjJvF00tr9ZSg+3mnfwWLz7ckCLBRU4xxCBd4dQHi+k8JPk01GZpfnWRyt5SxPhT2K5SrJjOoYi4tqoIFFwOC1QtYkgZAKuJlLQr1Gz7+pnzm74quMWzyeSJkCeuQQ= 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=G6LFcP28; 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=1707391923; x=1738927923; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ymurIB97b11IqH9GZGJPPvkYT9r0Cf4QevmMQfDhVpY=; b=G6LFcP28S+N2D4PREKdYvWWX2igv4nKU6DF9T2k6ULGmBRQRMSOJC5D4 HgvNbO+6v+CgNAxBkxGUcvq6bkWDHFnmn0lVEADPcs1eKOalRdc0EX4oK 7X/P54TrkEAZ16UJru49s1I67ytYsbhiHaK5XaSjuZMBAQTVe9oTdz+BO j9OonfEbn05bqGvUXvC333dZ1GZ6XQ6JJun4ham0EJ6wV9LAHcfBJhsRQ 4/7sxsdBnj3yudBjXB2e2l/dWU4AaBLR/wW77i7JRCI9uTaLZwva8RbDA TXgdiEXYVIi4egLQNkB2hgCGdkKbg/3FKnl37ZO2rOdV03iai5CTdrgFL A==; X-IronPort-AV: E=McAfee;i="6600,9927,10977"; a="1345508" X-IronPort-AV: E=Sophos;i="6.05,253,1701158400"; d="scan'208";a="1345508" 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:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,253,1701158400"; d="scan'208";a="1957470" 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:31:56 -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 03/12] perf/x86/intel: Do not enable large PEBS for events with aux actions or aux sampling Date: Thu, 8 Feb 2024 13:31:18 +0200 Message-Id: <20240208113127.22216-4-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: 1790330252615313910 X-GMAIL-MSGID: 1790330252615313910 Events with aux actions or aux sampling expect the PMI to coincide with the event, which does not happen for large PEBS, so do not enable large PEBS in that case. Signed-off-by: Adrian Hunter --- arch/x86/events/intel/core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index 3804f21ab049..d50f4325d42a 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -3885,6 +3885,12 @@ static inline bool intel_pmu_has_cap(struct perf_event *event, int idx) return test_bit(idx, (unsigned long *)&intel_cap->capabilities); } +static inline bool has_aux_action(struct perf_event *event) +{ + return event->attr.aux_pause || event->attr.aux_resume || + event->attr.aux_sample_size; +} + static int intel_pmu_hw_config(struct perf_event *event) { int ret = x86_pmu_hw_config(event); @@ -3902,8 +3908,8 @@ static int intel_pmu_hw_config(struct perf_event *event) if (!(event->attr.freq || (event->attr.wakeup_events && !event->attr.watermark))) { event->hw.flags |= PERF_X86_EVENT_AUTO_RELOAD; - if (!(event->attr.sample_type & - ~intel_pmu_large_pebs_flags(event))) { + if (!(event->attr.sample_type & ~intel_pmu_large_pebs_flags(event)) && + !has_aux_action(event)) { event->hw.flags |= PERF_X86_EVENT_LARGE_PEBS; event->attach_state |= PERF_ATTACH_SCHED_CB; } From patchwork Thu Feb 8 11:31:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 198321 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp99872dyd; Thu, 8 Feb 2024 03:33:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IF3ktZoKtCw0bcuKK9abvgidG3gpYCIDrggSibX9BfSaorEBiJTYALSZH7cTyLG9U/VSEKM X-Received: by 2002:a17:90a:1601:b0:296:452a:9662 with SMTP id n1-20020a17090a160100b00296452a9662mr3789485pja.2.1707391997617; Thu, 08 Feb 2024 03:33:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707391997; cv=pass; d=google.com; s=arc-20160816; b=IMo5JyPadYi8qLyeyMZEjudhqiA35ZWdbjHGipkIQV35eyJx9Bf0xmg4oqSvbKEuqL 53eq3gUS8YDaJ1V154+4VLJUk5MBKavjXR8q+Wvxj1GAUBC7zmZ+8otIaTUdPKbOeNKG c1ufkMAqaL3AXUJ+U4C0NRovIQNxZn1aMtjS/3hx0jW0F9Mh54sZS31d8XTcE2fJ3+yO k93MjxioO8oUoMDrtLMNKCY+tt7827P1CaEMzYhUIaapA7pLQIRYC85Vm/1t4i2clhOx IKCwTcq6WGO0XfyKYJZ8aP+U6WwsYZ2NJHYtY9DEoUspJsIfzj9dyxj+xuiJkuElNWp5 xPIA== 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=JkvxLZdGiBJfshup6gtoxYgDd6RCTn7cuZ6zQA+tdm0=; fh=BSOz2StJh2oHygijDIhE5o3gy6L5sHRAvSMaE2stYpA=; b=vMCQwrfCyUJNH5WLeOxejoqABLxS1788u1FbvO+PUT2g3f94XsH2sGVZvTiQcsmMmd jIP6FyxCHpbV0CV78aFJBKSmRIFSksqtnfSWNKvLYps7KO2PcAHcnJns4MQF3FURIXiZ lzODWH0mLf7UoXSOxoXCxHSK/s8DR6eB1eYyjcPyWhKwuBUP11pBT99G7jPN4yc9LCXu umXOorqe10M0gaM+MDl1jFgkkUtEOBSyfsSmgIN/NIFpqCHE3tlPzabnI11LjDkg4tQp 6GLMEKkWPGp7EUfOFmz1/BlWxU1Px/dnQ5lnJcGP5KbCrQNMHptuYGSGHL5BxaPBL6Ve gcZw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OyCRs2B7; 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-57963-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57963-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCWVGxjdfleHdrY0BEXqIeQmAHxUuwjX84vJCDgjaMkQh2lu5R/FFIu9UmVGKZYMPWQgUbIZoloP3tfR+kCILfUNuwg2zg== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j185-20020a638bc2000000b005dbcff42ee2si3615494pge.536.2024.02.08.03.33.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 03:33:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57963-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OyCRs2B7; 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-57963-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57963-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 3880C283B49 for ; Thu, 8 Feb 2024 11:33:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F07B474E19; Thu, 8 Feb 2024 11:32:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="OyCRs2B7" 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 622266F50F; Thu, 8 Feb 2024 11:32:08 +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=1707391930; cv=none; b=J4WzP58k2KpS2V+Wr43DV6NwkJMMWpx+FD4gdfFZuLM8E5ixJh3QHF8LUMpdR/mpB6ajIju+HNThbLnGzGZ7qWqa7i3fdS1KRj6Z0V92QSY5tCNn6PFX7KU0AqyLyQ/skMm5T5QXmBCR1QFUjLDAZigs++dz+tecN4ig9mETuNg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707391930; c=relaxed/simple; bh=ltm4BNE1kVbTScZPdTe85e8QfDDAc7SPDrUZuF1fT8Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=e4KuyrrWmPawjeoMCYjk0JO/VUaidlU/3/yM7Dbx0ta8bcMrIveoIF96F3uGXJuPZsOqYWEf04ueZqoJEHv8Hwest2++P2n1jamFlVgQdSWaoO1I6io8mki1Ri4Pei3V77YDWbmX3irqj8M9FMn/8ig9Yu2D2/b4sqYJLB29CXk= 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=OyCRs2B7; 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=1707391929; x=1738927929; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ltm4BNE1kVbTScZPdTe85e8QfDDAc7SPDrUZuF1fT8Y=; b=OyCRs2B7WPntVcGUgb1QfC1mCFWh5uQewg11Su78W3Tbu5M3NBQfywSb oedbolZCjwP9Gj3CmGuzQq5UNOOlK5n97hRoFjM4TqN2E8fBg76t4OON+ 4HJl7j4W+pOayRCiUnE0Y5RzrrVSBN9EFn+TbMbnSWATdlGWnZBPjvzW/ IwBWbnFDGOFDJdj4s8A5LQzJqwH+OLJQK6sI/8NN3RL7ltiyMy8fHJfSu LNl/oVlybhKUiH/zqijMHNw0+PlGIKqbjS/A+wqRoB2TXJuGLuA8nBdqu G2ez/UfOgB4xk1kuNEBwHMzU/A9nM8hbY3bk13fY6tiod5XlNjJ+41Tpb Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10977"; a="1345552" X-IronPort-AV: E=Sophos;i="6.05,253,1701158400"; d="scan'208";a="1345552" 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:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,253,1701158400"; d="scan'208";a="1957506" 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:02 -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 04/12] perf tools: Enable evsel__is_aux_event() to work for ARM/ARM64 Date: Thu, 8 Feb 2024 13:31:19 +0200 Message-Id: <20240208113127.22216-5-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: 1790330271308900965 X-GMAIL-MSGID: 1790330271308900965 Set pmu->auxtrace on ARM/ARM64 AUX area PMUs. evsel__is_aux_event() needs the setting to identify AUX area tracing selected events. Currently, the features that use evsel__is_aux_event() are used only by Intel PT, but that may change in the future. Signed-off-by: Adrian Hunter Acked-by: Ian Rogers --- tools/perf/arch/arm/util/pmu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/perf/arch/arm/util/pmu.c b/tools/perf/arch/arm/util/pmu.c index 8b7cb68ba1a8..668a4310cb69 100644 --- a/tools/perf/arch/arm/util/pmu.c +++ b/tools/perf/arch/arm/util/pmu.c @@ -20,16 +20,19 @@ void perf_pmu__arch_init(struct perf_pmu *pmu __maybe_unused) #ifdef HAVE_AUXTRACE_SUPPORT if (!strcmp(pmu->name, CORESIGHT_ETM_PMU_NAME)) { /* add ETM default config here */ + pmu->auxtrace = true; pmu->selectable = true; pmu->perf_event_attr_init_default = cs_etm_get_default_config; #if defined(__aarch64__) } else if (strstarts(pmu->name, ARM_SPE_PMU_NAME)) { + pmu->auxtrace = true; pmu->selectable = true; pmu->is_uncore = false; pmu->perf_event_attr_init_default = arm_spe_pmu_default_config; if (!strcmp(pmu->name, "arm_spe_0")) pmu->mem_events = perf_mem_events_arm; } else if (strstarts(pmu->name, HISI_PTT_PMU_NAME)) { + pmu->auxtrace = true; pmu->selectable = true; #endif } From patchwork Thu Feb 8 11:31:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 198322 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp100160dyd; Thu, 8 Feb 2024 03:33:55 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXAp1JL2TcWBnIey2yLEMsSVKa5EW5JUDoogUEO8N/snDegD6Ac13vaScwH6ZufcOGPB4YGPn94zVouiEU1oWGO3fE/0Q== X-Google-Smtp-Source: AGHT+IFcmVHvu306WdjgXZqZo1wFJVEW6qtZp3tHKPUugtY8e5SqJrFgBZN5sK68mJ+8u7TGzUMR X-Received: by 2002:ac8:7608:0:b0:42c:49cd:38cd with SMTP id t8-20020ac87608000000b0042c49cd38cdmr2081839qtq.30.1707392035277; Thu, 08 Feb 2024 03:33:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707392035; cv=pass; d=google.com; s=arc-20160816; b=eht0KP8NoUI7czWu1KHgSEfSzkmrdgCYLGLwspx9aqhMJEE9sH/xZ4o1Xp6h0U4KAA WzLyi2zWIvpg3fgvCu5/KCxU31pJBNSEBik/pBWRAFL7PnsLqfEdLcnvqd2CgDW0oI3i wYkQBV+BjILwDZ3+tMj2/CvyHhAKl736PrZgkQdnJdcTuixM96Rqomg0tKfjKUP8kw9K 3LW2X1RC8sSEjDmtSX7BBp8FMDQRnB6i7Mmb8VIAopc+5sdL7dDMptkn+jm1VvXpByR3 Em2azXqPGoLbZl6gNGJjy7+XrCXxckXFvehcASseUQ9lixuKaG7fXetsHKijAmobebjw M2dQ== 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=AnW8r9TRGwiz7GDwEU67jpl3RUV2w6EGZX/z7qRiS4E=; fh=IYh/X1PkZpyFqX0qy3+h3wzA4TGjha6kB/0zYSzMAVw=; b=hs15MaEF9uXD/seIH7c2lJUDIbd+uczcVnvs/OhSDyzMmu9RfLlif8kJlXbMro1130 HbJDTVo79s4ypIm50criJD/aWocgg5EtszehGAE8raLNFlvIJhn2R9qRRDP0gI8s8d6j kYqJbboXwyiq1/oZrzueESrAZsLxw9qi8DPBU9DXiVJdRgkzl1NBERCSw+A6xnv8P8tN GSAtAklaq7turaopys6ElIxqP6YohSYzJFyLjoUTZ+hppCQkp6T3P/yae/2cnORksW/u UCrxQ4gjfwW8TE0vcFLzNPYUKslvtOtth2nYJFWW56NcUoNp8U4P2btqNi81bcvfbUH7 kA+w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mChSWcZR; 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-57965-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57965-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCVBH+9QxNw3h0SGDsYNITe2UWkutOsWSlVGSmLdqXpB9rEgEhUei70UKNhBIm73C0/co4V1DljAdsMJ/9PMK8fg6S6RGw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y14-20020a05622a004e00b0042c44b43c71si2414847qtw.73.2024.02.08.03.33.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 03:33:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57965-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=mChSWcZR; 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-57965-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57965-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 EB5381C209B9 for ; Thu, 8 Feb 2024 11:33:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 678AD762F0; Thu, 8 Feb 2024 11:32:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="mChSWcZR" 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 1EC7C76037; Thu, 8 Feb 2024 11:32:14 +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=1707391935; cv=none; b=UA6jVeYfpfGk9DhwHc6N08F/jfBxkUi9LZkWXpTdpPhl/+YSbgjldK8fGFFCkZ+DLVImGIfA4BzavXhbpdkSLZWAXTQozwDFdG/cKYHQkR3A1CgFE/EUzvxcwf86HN8ucLltyfzjeJ93KmtS5V1cU0v3i0mx2h0olfH89Mrb0j0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707391935; c=relaxed/simple; bh=/uNuO1osfQ/KqtLrzS800xAbLzNCQEyTMRkrAuppesM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gdzduZy3CV2GkM/I3rNXet/AFbP7KSw5TTmyiPKKUGG/pd9m/tkhBqwQOHCJy5t0fbAyr5oiDXbWWUqXUPYTsk1tQHoqEQ/2zaOA1XiLD+rEsTszFJnLS2pVMY/ldyncKP53EFuzyYFNihX8Qbfzq4VTiWvIPG6u5vssb2M1oZY= 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=mChSWcZR; 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=1707391934; x=1738927934; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/uNuO1osfQ/KqtLrzS800xAbLzNCQEyTMRkrAuppesM=; b=mChSWcZR4jRIH6JuZiyZhMyf6D3l9gXnwyUGtufWBArJ2YRJopCQVas/ Lp4IuYexIOwu/Lo0gGEJ7/lRU4Ig7LTZcZmxz2eoBRzUTPHhUmHN/9VbH nQY6OAzbDTj1B9L4XiywVWOR9LyCwRF9ghQW5zqxMi3Rb3rLFTRDBozRS ZBHiEe1JDy80XQnotqJbHAdsMUJYifl0uZxMVL64lvkHxv/b76/lW/HRB PUcWqGpmfrAREDqntNAO2eH9Pk18EIKVvTqdZHcxvUjJDvwY4vtENYWbq o6V5UEMXMNVddHDosSYriH2CUExSk0SRw4wh2dO34HUx7+vFakoyassrG Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10977"; a="1345594" X-IronPort-AV: E=Sophos;i="6.05,253,1701158400"; d="scan'208";a="1345594" 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:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,253,1701158400"; d="scan'208";a="1957534" 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:08 -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 05/12] perf tools: Enable evsel__is_aux_event() to work for S390_CPUMSF Date: Thu, 8 Feb 2024 13:31:20 +0200 Message-Id: <20240208113127.22216-6-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: 1790330310593610815 X-GMAIL-MSGID: 1790330310593610815 evsel__is_aux_event() identifies AUX area tracing selected events. S390_CPUMSF uses a raw event type (PERF_TYPE_RAW - refer s390_cpumsf_evsel_is_auxtrace()) not a PMU type value that could be checked in evsel__is_aux_event(). However it sets needs_auxtrace_mmap (refer auxtrace_record__init()), so check that first. Currently, the features that use evsel__is_aux_event() are used only by Intel PT, but that may change in the future. Signed-off-by: Adrian Hunter Acked-by: Ian Rogers --- tools/perf/util/pmu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 437386dedd5c..40be43f1f648 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -1099,8 +1099,12 @@ void perf_pmu__warn_invalid_formats(struct perf_pmu *pmu) bool evsel__is_aux_event(const struct evsel *evsel) { - struct perf_pmu *pmu = evsel__find_pmu(evsel); + struct perf_pmu *pmu; + + if (evsel->needs_auxtrace_mmap) + return true; + pmu = evsel__find_pmu(evsel); return pmu && pmu->auxtrace; } From patchwork Thu Feb 8 11:31:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 198323 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp100282dyd; Thu, 8 Feb 2024 03:34:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IEnSphFwQ0poDFFowmUjX7iyWEfhZQaHjyfJPCerbcPEYN50VW1hR7ipkZN0Op4AZTIbfLk X-Received: by 2002:a05:620a:10af:b0:783:4766:b88f with SMTP id h15-20020a05620a10af00b007834766b88fmr8024129qkk.36.1707392053248; Thu, 08 Feb 2024 03:34:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707392053; cv=pass; d=google.com; s=arc-20160816; b=cw7YDFf5XVv6jI9fAbXQt+xw4u6Xu8ho5YnUqVjKXts1wyqunvnqXw74t1G3OK5hfv GjpGlgGPmTrK18t5TO0oZYOcB7j49ey1/rcv7CkegSIK06iSTlFxGjpzN3CLDzYrwexD 3iqFRKbQaHXltqrOJQ0pH7t8fb1x7gR7+qZPZQ8Njp9qErBUJ1oBqqQGdZuStcKwfpka TMAYVTj6hcLFq6Si6MXQyZdH7y4eXD/BF1Ex9vCBDaGQ+1ksitunP8KfitX6JtMXK/sr HcOCbg3wRtC+Nsz2w9VbspH5Y/s1vFEUtPEx7pdstB3KQt8/TcuW4egFFUH0BiE/G6uz J/Ng== 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=H62+WEP6s/6ELBNQR1BnaDHxgYORYdtYVphkNEjTSHE=; fh=YbyM1T2bkVGG+cC3vouBM65v9PlrJQPHNVFBLUfD9Yg=; b=ChObDWfXyHx98+jwJ5w1EprRu0Wx0+xvOnrIlFXlcMr65lT+31/D4AwlhUoi4COOt6 VTgghGizfPpBGmaaQwuCz0aSoaB0UiLcCl8Wtt5Nf2ETB50c7ADwuUkSjUNcd16MFzc7 QsG4OF99AgQKyGSYEsbzBNjQKeJPOIt2M0k8JUVv8JPbVw8D/frogp+IWhbSolF1mur3 4IZXpTKKB45tmTzONR3ye4gZ1YKZqCt2HDEckIjnu+EiuZPs7qEVOL94XfUqAtOEsgSN Ud1q/2Jjdr5lMkE6h4sv62Dvd/n1EH1YB/oyjOB/To0NJW/pNHlaEKDIrpmt+HnHKYVI lc4g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=cz3s08IB; 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-57966-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57966-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCUXKTfWzU0db30MnhikPe3WOQ7xvfbvwr/zEKkqnpPd+bvk91e3m0eRHf/iHYMWpKn71Oc/OVKqwxM8ZDfi2i3f5YnhGw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id f12-20020a05620a15ac00b007856110ba80si3121399qkk.426.2024.02.08.03.34.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 03:34:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57966-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=cz3s08IB; 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-57966-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57966-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 04AB21C2135A for ; Thu, 8 Feb 2024 11:34:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B05D46F527; Thu, 8 Feb 2024 11:32:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="cz3s08IB" 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 6C5B26F07B; Thu, 8 Feb 2024 11:32:20 +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=1707391941; cv=none; b=Oz9qBR0Jt2S9NyAtsGtb77bkF5+Mz7UgdXHrjOyghuikX6Inx4H21Pbmt1mcKwI8m4lRpH5vxFWC3MIgNgZAdoOGWxjVWMca6fCLoY45YbdzA941qr3mQgFwrHiimXHMRCU91ynsW4UgjAq5eRpOpfvS3cbOVJaZB5tkmetPHew= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707391941; c=relaxed/simple; bh=sTi/tiaFBfkZQc/Ou+a5JYj8AxQ1/vPEycCmaXjMqkA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DV2KlNB60Si+BFccSmdhkCysiL3t6g235xRUHAY3aBM7hm6TXvE5Vf8kW9Eb2rkhB1sMmXQrG9Nc0r/KdSkbv/52lcl6FFacrNo4phAjbkybp1hOb3LQkmu1FsTdnTp68mTa8T3j97arbfU3MhlKvQ9iDi03nJR+FZxzrzhXtHc= 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=cz3s08IB; 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=1707391941; x=1738927941; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sTi/tiaFBfkZQc/Ou+a5JYj8AxQ1/vPEycCmaXjMqkA=; b=cz3s08IBrsiK3vr3wJkYgxavD7R5mot7omcRz2xGXKFmyhIpTlGwksme CSI1ZTY5Jv3jLLd6BWMZ2FX+gTuORM54DVptLsSHvOqJZ2cEjBLnE+IUy 99oqw2xU3YzvgQoEkCmbfRWc6F+W8t5ZPvgNHDU0CQTKBt81Su2KpNgkf +LWjZ4e2F6lGdelL+cd9CbHMg68HRY79Ub19NmznLR+ZjiteJZKxpHzDX 2djqtSbGvpnZUCoDAa0AaydtooNPCtNboESW0jaX8V6j8GqsoqNFMCVtW orcdkjL2Gpw42G4txKCssIRhmyAK70y0NXbvMTuX17GQVqxUQNhHfjsHZ w==; X-IronPort-AV: E=McAfee;i="6600,9927,10977"; a="1345636" X-IronPort-AV: E=Sophos;i="6.05,253,1701158400"; d="scan'208";a="1345636" 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:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,253,1701158400"; d="scan'208";a="1957585" 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:14 -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 06/12] perf tools: Add aux_start_paused, aux_pause and aux_resume Date: Thu, 8 Feb 2024 13:31:21 +0200 Message-Id: <20240208113127.22216-7-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: 1790330329394633811 X-GMAIL-MSGID: 1790330329394633811 Add struct perf_event_attr members to support pause and resume of AUX area tracing. Signed-off-by: Adrian Hunter Acked-by: Ian Rogers --- tools/include/uapi/linux/perf_event.h | 11 ++++++++++- tools/perf/util/perf_event_attr_fprintf.c | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h index 3a64499b0f5d..0c557f0a17b3 100644 --- a/tools/include/uapi/linux/perf_event.h +++ b/tools/include/uapi/linux/perf_event.h @@ -511,7 +511,16 @@ struct perf_event_attr { __u16 sample_max_stack; __u16 __reserved_2; __u32 aux_sample_size; - __u32 __reserved_3; + + union { + __u32 aux_action; + struct { + __u32 aux_start_paused : 1, /* start AUX area tracing paused */ + aux_pause : 1, /* on overflow, pause AUX area tracing */ + aux_resume : 1, /* on overflow, resume AUX area tracing */ + __reserved_3 : 29; + }; + }; /* * User provided data if sigtrap=1, passed back to user via diff --git a/tools/perf/util/perf_event_attr_fprintf.c b/tools/perf/util/perf_event_attr_fprintf.c index 8f04d3b7f3ec..0e3cb35aab33 100644 --- a/tools/perf/util/perf_event_attr_fprintf.c +++ b/tools/perf/util/perf_event_attr_fprintf.c @@ -323,6 +323,9 @@ int perf_event_attr__fprintf(FILE *fp, struct perf_event_attr *attr, PRINT_ATTRf(sample_max_stack, p_unsigned); PRINT_ATTRf(aux_sample_size, p_unsigned); PRINT_ATTRf(sig_data, p_unsigned); + PRINT_ATTRf(aux_start_paused, p_unsigned); + PRINT_ATTRf(aux_pause, p_unsigned); + PRINT_ATTRf(aux_resume, p_unsigned); return ret; } From patchwork Thu Feb 8 11:31:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 198324 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp100399dyd; Thu, 8 Feb 2024 03:34:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IHlLHiPXlTPSfVZz8zJNyd6HJ+Wa3X3fJEwAEbUNsOEMiFp6iHXt+CkwWP4mgqHlGYI+FTm X-Received: by 2002:a5b:88d:0:b0:dc6:bcb3:5d8e with SMTP id e13-20020a5b088d000000b00dc6bcb35d8emr7470014ybq.20.1707392072067; Thu, 08 Feb 2024 03:34:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707392072; cv=pass; d=google.com; s=arc-20160816; b=fKfNmYFO9AWTHSy6Y7Rmf3jd2tl5X3+yNnC9SHgPCvM+/9PNtKcPy2HcXMnaqzWRpJ KxtAXXlFynmp10I871Equo8rSlwRFZFivfuyJhVvxdWfJTnHW5icDZxLP5iL2a1TUixk QaeWTqhjb6ucYLRnVPLuSOKZC7cgVDC8B4+rBSZVr0eUWPu3JZi/adkO2vOV8AVEu1zh TDiI0b4iFz0PQHte4EBEl7tSTS3jKaON8FrSmwBSR2e8QoszJW41rRxaZxUdFun6uxHj CoHgKd/UPDNgz5CLMFs57O/+4ezRkEhDG+vjIWvo6CxzVpBFi0zBKb7bLpmgyzLXdPZU 4DpQ== 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=C3RK26A2uo6dD/WWl+VjFqDA8GjhhVN/bKwt+YViyoE=; fh=zDU0K0/TGGlqaAqBfI0TXwvLxX/YCc0rzrvB0/oIgR8=; b=UTvJFYPr0i8FaDXiNkBqxOd7o8EZ88DUlAGeewXnARHJAuZQwXhUX1wa5oCfX2mLtj lMca5USSIxi6gcFHO8m5fYWDH42WJstZlDvBhM48gHoLuiFskAGE6zWPQ5/2RCXvXUY/ 5PcfbALqlfpV2KkITn6Ym8YOdtK4iedsnknsf2aAKmIwfYXIU2sOYifjd1C03Zaw1L71 +I2IQMM7IoCxlFvKFoE6fZcc5UY2Kj93e9PbNpE0t5CD38c8syoLSaod7zli/uLKfBDD Jwgi0fE40aOQSYSLlghpoQVbPkyxPem2OyiLjZ/C3175iUzKGly8a1uBKxEGmgqTuBsU u6FA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MmnieKV4; 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-57967-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57967-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCWVcs5+dhB7NbK7fG9Y46yMmKY9/JkPMlgeshLiTYYcA6de6vjUYoMId+dMlZ2eFFqEd+DftjkaYqi6jesB/4ibhr0t9w== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id h14-20020a0cf8ce000000b0068c4530beffsi2944816qvo.353.2024.02.08.03.34.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 03:34:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57967-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=MmnieKV4; 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-57967-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57967-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 C42F01C2135A for ; Thu, 8 Feb 2024 11:34:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 87C9C763F7; Thu, 8 Feb 2024 11:32:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="MmnieKV4" 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 945BB763E7; Thu, 8 Feb 2024 11:32:26 +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=1707391948; cv=none; b=SqQuiIEuAmUzNUPNFjiXne/mLa+0Q+AzOYOvDjR4iQ7dvYkSRYcP/JHX5a4gTKWCWAPKqL/limFAlmw6LS/Cr69zCiZ9fGIlnSQYyuMysY/7NczgR2+/2/N3ncBY/OljUNBFnYR1qehkM84tvLgLPpm701zpIfjPZwSezthBh3c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707391948; c=relaxed/simple; bh=AKPcWBzNqSLXpi+HJcYIiU5xlui38B0/DvWSJcjZ7S8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aK+wh9dziHqNduIkIjb1+Xutb5LTQlcPQy88Dsc2xE0qmMTs7P9ypoNlJKC5uRiLFR/VEDNz2AQPMEh/DnpZwLVIjTb1DKey3B6sdPgjtJ963vE5UHu/PaalWSYgeDSw8WjFWnOfwI6xsPybIG/SJhv+uJJXw8/NWEudylgUpbE= 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=MmnieKV4; 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=1707391947; x=1738927947; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AKPcWBzNqSLXpi+HJcYIiU5xlui38B0/DvWSJcjZ7S8=; b=MmnieKV48ru+Ak6E6NKRmAJ43HlKVvKyGb93a5711VCGot/HIhnjPw3S Jgg2a0JphW8ysrJ0jgEcoXYOOVYsetyJGzhHVn/vam35BpIPXxufikAOv yQGOoTzWMUFI99Jj2UxreQDEvHAiVpqnG0V5c1hhiujNWajfKlbJyjOGt Pmtj6wdHsoIl3/k62KcH6n3CSqrgaH17nvIHr/PUNi5KcsTrqjA6MH2fn PyF0N/do4ephCQQFAG2Y5rQEVT6sdhi3o85jkearkpbxlRlGIj+5k9eeq kS6eutS1sGja9+P18DfSYBWuAz6NSFGY7K7KC3OGQS7rVIuy1VvI/9kEA g==; X-IronPort-AV: E=McAfee;i="6600,9927,10977"; a="1345650" X-IronPort-AV: E=Sophos;i="6.05,253,1701158400"; d="scan'208";a="1345650" 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:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,253,1701158400"; d="scan'208";a="1957636" 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:20 -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 07/12] perf tools: Add aux-action config term Date: Thu, 8 Feb 2024 13:31:22 +0200 Message-Id: <20240208113127.22216-8-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: 1790330349411228902 X-GMAIL-MSGID: 1790330349411228902 Add a new common config term "aux-action" to use for configuring AUX area trace pause / resume. The value is a string that will be parsed in a subsequent patch. Signed-off-by: Adrian Hunter Acked-by: Ian Rogers --- tools/perf/util/evsel.c | 2 ++ tools/perf/util/evsel_config.h | 1 + tools/perf/util/parse-events.c | 10 ++++++++++ tools/perf/util/parse-events.h | 1 + tools/perf/util/parse-events.l | 1 + 5 files changed, 15 insertions(+) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 3536404e9447..866c69f83595 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -1001,6 +1001,8 @@ static void evsel__apply_config_terms(struct evsel *evsel, case EVSEL__CONFIG_TERM_AUX_OUTPUT: attr->aux_output = term->val.aux_output ? 1 : 0; break; + case EVSEL__CONFIG_TERM_AUX_ACTION: + break; case EVSEL__CONFIG_TERM_AUX_SAMPLE_SIZE: /* Already applied by auxtrace */ break; diff --git a/tools/perf/util/evsel_config.h b/tools/perf/util/evsel_config.h index aee6f808b512..af52a1516d0b 100644 --- a/tools/perf/util/evsel_config.h +++ b/tools/perf/util/evsel_config.h @@ -25,6 +25,7 @@ enum evsel_term_type { EVSEL__CONFIG_TERM_BRANCH, EVSEL__CONFIG_TERM_PERCORE, EVSEL__CONFIG_TERM_AUX_OUTPUT, + EVSEL__CONFIG_TERM_AUX_ACTION, EVSEL__CONFIG_TERM_AUX_SAMPLE_SIZE, EVSEL__CONFIG_TERM_CFG_CHG, }; diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 6f8b0fa17689..75ebc515faba 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -768,6 +768,7 @@ static const char *config_term_name(enum parse_events__term_type term_type) [PARSE_EVENTS__TERM_TYPE_DRV_CFG] = "driver-config", [PARSE_EVENTS__TERM_TYPE_PERCORE] = "percore", [PARSE_EVENTS__TERM_TYPE_AUX_OUTPUT] = "aux-output", + [PARSE_EVENTS__TERM_TYPE_AUX_ACTION] = "aux-action", [PARSE_EVENTS__TERM_TYPE_AUX_SAMPLE_SIZE] = "aux-sample-size", [PARSE_EVENTS__TERM_TYPE_METRIC_ID] = "metric-id", [PARSE_EVENTS__TERM_TYPE_RAW] = "raw", @@ -817,6 +818,7 @@ config_term_avail(enum parse_events__term_type term_type, struct parse_events_er case PARSE_EVENTS__TERM_TYPE_OVERWRITE: case PARSE_EVENTS__TERM_TYPE_DRV_CFG: case PARSE_EVENTS__TERM_TYPE_AUX_OUTPUT: + case PARSE_EVENTS__TERM_TYPE_AUX_ACTION: case PARSE_EVENTS__TERM_TYPE_AUX_SAMPLE_SIZE: case PARSE_EVENTS__TERM_TYPE_RAW: case PARSE_EVENTS__TERM_TYPE_LEGACY_CACHE: @@ -936,6 +938,9 @@ do { \ case PARSE_EVENTS__TERM_TYPE_AUX_OUTPUT: CHECK_TYPE_VAL(NUM); break; + case PARSE_EVENTS__TERM_TYPE_AUX_ACTION: + CHECK_TYPE_VAL(STR); + break; case PARSE_EVENTS__TERM_TYPE_AUX_SAMPLE_SIZE: CHECK_TYPE_VAL(NUM); if (term->val.num > UINT_MAX) { @@ -1053,6 +1058,7 @@ static int config_term_tracepoint(struct perf_event_attr *attr, case PARSE_EVENTS__TERM_TYPE_OVERWRITE: case PARSE_EVENTS__TERM_TYPE_NOOVERWRITE: case PARSE_EVENTS__TERM_TYPE_AUX_OUTPUT: + case PARSE_EVENTS__TERM_TYPE_AUX_ACTION: case PARSE_EVENTS__TERM_TYPE_AUX_SAMPLE_SIZE: return config_term_common(attr, term, err); case PARSE_EVENTS__TERM_TYPE_USER: @@ -1187,6 +1193,9 @@ do { \ ADD_CONFIG_TERM_VAL(AUX_OUTPUT, aux_output, term->val.num ? 1 : 0, term->weak); break; + case PARSE_EVENTS__TERM_TYPE_AUX_ACTION: + ADD_CONFIG_TERM_STR(AUX_ACTION, term->val.str, term->weak); + break; case PARSE_EVENTS__TERM_TYPE_AUX_SAMPLE_SIZE: ADD_CONFIG_TERM_VAL(AUX_SAMPLE_SIZE, aux_sample_size, term->val.num, term->weak); @@ -1249,6 +1258,7 @@ static int get_config_chgs(struct perf_pmu *pmu, struct parse_events_terms *head case PARSE_EVENTS__TERM_TYPE_DRV_CFG: case PARSE_EVENTS__TERM_TYPE_PERCORE: case PARSE_EVENTS__TERM_TYPE_AUX_OUTPUT: + case PARSE_EVENTS__TERM_TYPE_AUX_ACTION: case PARSE_EVENTS__TERM_TYPE_AUX_SAMPLE_SIZE: case PARSE_EVENTS__TERM_TYPE_METRIC_ID: case PARSE_EVENTS__TERM_TYPE_RAW: diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h index 809359e8544e..7e467ff71f19 100644 --- a/tools/perf/util/parse-events.h +++ b/tools/perf/util/parse-events.h @@ -74,6 +74,7 @@ enum parse_events__term_type { PARSE_EVENTS__TERM_TYPE_DRV_CFG, PARSE_EVENTS__TERM_TYPE_PERCORE, PARSE_EVENTS__TERM_TYPE_AUX_OUTPUT, + PARSE_EVENTS__TERM_TYPE_AUX_ACTION, PARSE_EVENTS__TERM_TYPE_AUX_SAMPLE_SIZE, PARSE_EVENTS__TERM_TYPE_METRIC_ID, PARSE_EVENTS__TERM_TYPE_RAW, diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l index e86c45675e1d..26a60ad5853c 100644 --- a/tools/perf/util/parse-events.l +++ b/tools/perf/util/parse-events.l @@ -244,6 +244,7 @@ overwrite { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_OVERWRITE); } no-overwrite { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NOOVERWRITE); } percore { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_PERCORE); } aux-output { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_AUX_OUTPUT); } +aux-action { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_AUX_ACTION); } aux-sample-size { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_AUX_SAMPLE_SIZE); } metric-id { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_METRIC_ID); } cpu-cycles|cycles { return hw_term(yyscanner, PERF_COUNT_HW_CPU_CYCLES); } 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 */ From patchwork Thu Feb 8 11:31:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 198326 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp100702dyd; Thu, 8 Feb 2024 03:35:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUZmeZ6Kj9kDGfYw7QXbBaNl55ywvRlA7znLdkSTNAur01FsniIhC0RE0wIRZA6nzLwkYgX/4+VlnH6um1O/fG515EANg== X-Google-Smtp-Source: AGHT+IF1yLi4nnnG+F6g04GtB6xbDrKVgkBSAh6mqkWchENojgvzKyJwtfQuuz1CBtUEfoggpONF X-Received: by 2002:aa7:df99:0:b0:561:12a3:fe64 with SMTP id b25-20020aa7df99000000b0056112a3fe64mr865030edy.9.1707392113899; Thu, 08 Feb 2024 03:35:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707392113; cv=pass; d=google.com; s=arc-20160816; b=bI0IamNWFCvwuHfioZytsKubdC0OcpaXy69tQBF6vftbDA++T2PdIVbRw7PfPmFXGI 33pA8WBiWN001MvrPZHJUjcJv3MqfK2Dy+aOWO4n7E7VC9Vnwf2rTgE/E7UN99qSWtn0 +jWog9OYcAqVeXmGEg1piQpkKJS6IRUaHay6WbJjC+xFooPSj/W60WMpHju7R68sOt2a ACyUl6WJdKvVLjTiMjUAEsvwvq4ftsCSN3NsH6oniAZTNm/DMx8dvP0r+cZf5cyTb4gd 9lJDj3EMqE+ZhMZQSw3hNfumTweDjt5PNQUb/gUIcuLRaLKbCyU6a9I+q4vTNoSr63Jc v89A== 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=n3qsVDGtKRh68lOkPnCuMAbofKTly6NAF87a/UKM40Q=; fh=IrHYFXc1IrB6ULYaQMYJ39hYn0TaFMfSmwzkkkrJKs8=; b=JaI0LlbZbsOzjzZkpFZoUaohghwuNUl/YD2ramD8Kx8TZs/sPbIs5FLqpdG5Cccyf+ 4WXKYhFAVH1hajBPhBoKYRz81wojq8q5ioWvZeeySDoN6Bvuoe1yP7MaSkKasOuLCvbL /lUXd9Zh4GzlWjfwGIGqSlA4uB7+nQdb5pUFM72LGJ0jWrxOj4M9koJCZ6T/9h+hW5ti nl5QYG/WiRCyXv6oVJWr4hCb50pcYqyM/vGD7CeXfrTCIpibw0+RnTR8mVD/MzYpIeeV M8/MJq0pYu6D6F+rW4eLZw4j1M3GZ45oSdM7vgaS0gsiBphkqrSFB28H65m0j52HR7od jXnQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="dYH+3/b4"; 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-57969-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57969-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCXH9l5G1FuhzZ5QRO/mcdPsv4WT68WqFgSOE936otPamKXWPBMZ1dd0lre2Sa2BzR0jDAST8nORJ6NtchPxfwGxfWv9YQ== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id u16-20020aa7d0d0000000b0055eeadefccbsi754407edo.654.2024.02.08.03.35.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 03:35:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57969-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="dYH+3/b4"; 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-57969-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57969-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 7BE9D1F2888E for ; Thu, 8 Feb 2024 11:35:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B9A26768F7; Thu, 8 Feb 2024 11:32:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="dYH+3/b4" 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 78B8076417; Thu, 8 Feb 2024 11:32:38 +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=1707391960; cv=none; b=X/iIpJBk747gTR+dHECkOkh1TOJ7fKeKgw5di26KP7APFdMKnRV8t5N1NLxmLf+MUB/sy1M0txWIvpMa1GQZXU1VbNDQaiDCu+yzFxZnDUOouV8ib/KjZkXneeCC8pG8okkRMSzWhDyHwU94d4+y9ZYWvSKaPD/9IL+wN7xpOsc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707391960; c=relaxed/simple; bh=6DpUpJ1gq9LuRkJBX6BDqLjCRgV6K9lzl/yGpxHeMUY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aq+O9sQEyg+HHd2VB5Vai0svyu6q0U2DKqr9BI3lCp/4siqGdTw9qVY7dDma3Bh3aH+O7RchBsO2SRfrloFaPocMc4hjqx9xJajFNGZFpmxLzMV0Qvzc83NwF5i/ZicpDs57NDzYtGPQkbry6P1UeFfwUlB7zcDMQtK3Ok/dRvc= 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=dYH+3/b4; 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=1707391959; x=1738927959; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6DpUpJ1gq9LuRkJBX6BDqLjCRgV6K9lzl/yGpxHeMUY=; b=dYH+3/b4lPFYwf5TIXEWpSBEhuDlIADspzz3xdS+X6YAVX0RL5LqFvyO r3H9bSmyDOnbZ+gAEI5ojwNifr+EucrsjVynxn/Hl4iradG7Zj/X76enE dM8PdixUvR9qB3ARKnjZ+HjeLPrdJKvAfNfbidCzE9+GHJ5nngP/2op7L 12Mm7nB9XX5YuThTPO7XwP9S79duUzTezgxKuAoKu95RC+jHAEfB+e7G5 OCAQ4PESi9NbD1+9DUttKpYc16rEVUHFSBVreEqfHb4CPk/VB4jA1eoWC 2oixvukn7ppFGHqWxhShK4y+AJovBTR3fL/k6YrreMqmKFH6WQu5fcRbL A==; X-IronPort-AV: E=McAfee;i="6600,9927,10977"; a="1345710" X-IronPort-AV: E=Sophos;i="6.05,253,1701158400"; d="scan'208";a="1345710" 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:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,253,1701158400"; d="scan'208";a="1957714" 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:32 -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 09/12] perf tools: Add missing_features for aux_start_paused, aux_pause, aux_resume Date: Thu, 8 Feb 2024 13:31:24 +0200 Message-Id: <20240208113127.22216-10-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: 1790330393448788473 X-GMAIL-MSGID: 1790330393448788473 Display "feature is not supported" error message if aux_start_paused, aux_pause or aux_resume result in a perf_event_open() error. Signed-off-by: Adrian Hunter Acked-by: Ian Rogers --- tools/perf/util/evsel.c | 10 +++++++++- tools/perf/util/evsel.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 8401685461bf..9d2fde919604 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -1890,7 +1890,13 @@ bool evsel__detect_missing_features(struct evsel *evsel) * Must probe features in the order they were added to the * perf_event_attr interface. */ - if (!perf_missing_features.branch_counters && + if (!perf_missing_features.aux_pause_resume && + (evsel->core.attr.aux_pause || evsel->core.attr.aux_resume || + evsel->core.attr.aux_start_paused)) { + perf_missing_features.aux_pause_resume = true; + pr_debug2_peo("Kernel has no aux_pause/aux_resume support, bailing out\n"); + return false; + } else if (!perf_missing_features.branch_counters && (evsel->core.attr.branch_sample_type & PERF_SAMPLE_BRANCH_COUNTERS)) { perf_missing_features.branch_counters = true; pr_debug2("switching off branch counters support\n"); @@ -3089,6 +3095,8 @@ int evsel__open_strerror(struct evsel *evsel, struct target *target, return scnprintf(msg, size, "clockid feature not supported."); if (perf_missing_features.clockid_wrong) return scnprintf(msg, size, "wrong clockid (%d).", clockid); + if (perf_missing_features.aux_pause_resume) + return scnprintf(msg, size, "The 'aux_pause / aux_resume' feature is not supported, update the kernel."); if (perf_missing_features.aux_output) return scnprintf(msg, size, "The 'aux_output' feature is not supported, update the kernel."); if (!target__has_cpu(target)) diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 517cff431de2..8ef5a6fdbd45 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -192,6 +192,7 @@ struct perf_missing_features { bool weight_struct; bool read_lost; bool branch_counters; + bool aux_pause_resume; }; extern struct perf_missing_features perf_missing_features; From patchwork Thu Feb 8 11:31:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 198327 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp100893dyd; Thu, 8 Feb 2024 03:35:40 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV2xjJ19Xulqr0T7ZkFW5F1Cnrl7kGtrmJjJfaeznsc9QsoDV3ksmXedu6mAtycr6NySnCdQl73rJ77m1xErngt4KJkzw== X-Google-Smtp-Source: AGHT+IHoueTzqiUkawJXJqZKNjwGajYDFxi8ATbOxlsiSVlUSSiNJuRmLyfKqFVYhg7e/bME7WyQ X-Received: by 2002:a17:906:31c6:b0:a38:9ff:571c with SMTP id f6-20020a17090631c600b00a3809ff571cmr5508831ejf.9.1707392140077; Thu, 08 Feb 2024 03:35:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707392140; cv=pass; d=google.com; s=arc-20160816; b=U9oClErMC4m5U+TQtnkjDyjeI4UONyZrGTmdwdw4+llDPWJUgNnOPNpjYVOGu7jDJK ka0TNYblxMyqZuwjdxoUs9YsDCOii+ykZWl3Un+i7EkXH57RXWpV+Xyg2H1KbN4tUTp8 haOp3XIILwja94B5ijZilw6i2ZrxpVjuXkpssp9REcrBFteaU48NOcxHf5fGp6ukcI8w GjumiNczkNGo3wUCt5A+0ilHFF/5Ksvf1pu8Bk3IU6F1lgbGh2xc6rZ6APffcIsSSUO6 uP2nHkLCzkH3IdDI9k0yKyxvR3GuVw4R1ZlsA47KaU8HCK90PWDUO5DeiSCKu/JWYG93 n7mQ== 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=q8GyJiw/tz83Uc9Dfz3zC+5v1pcwOFJJmo66LZH0KJs=; fh=+E+BS+lG3Ed66I5dpJmGGUXsbdt2UL/SLARLeb6p6Oc=; b=OhV57N1yxlcLxQn5FQfYy1Ayg0hHhtPfUgNcFY0UmIwfaJiGArYh9H9y3F7NW75k3h z2TzZqHx/iNcpHU93tNSPT5Qjh8D7fbWHDSH3bJIJa68cuiKCNp+QeeV7SOQHk2srNmx 3zvlJK/xsSL170uE2yoX73+xzSb56KWmLLCOe4LCx+/aaWcKui+FJdfnUnlLyTaPjgfL Yeh0qnhcQqYxIPmrnL3YoApJ1ofTysQvJXx6rwOMtl3wmGpyxWfcVHvQzcmIV+gSuJsr oD+yoMQqqYqfet5t/sEerIAyZf/m6Bl9xFLi2lkJKSiufzgJQHTShpHuGOWwF8RLQwvZ FSIw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=T142XgkU; 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-57970-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57970-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCUyRne67uz6Ht63XR14pZ+r9f6T0HBqb0E1hgatx/q73Kit8VZ4zD+U0JnTZa2ixglIKj0u8MgCEg1v5mfUR6J85dmQoQ== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id v15-20020a170906564f00b00a388d084d29si1550463ejr.999.2024.02.08.03.35.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 03:35:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57970-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=T142XgkU; 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-57970-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57970-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 7C8BD1F29EB0 for ; Thu, 8 Feb 2024 11:35:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 309F978660; Thu, 8 Feb 2024 11:32:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="T142XgkU" 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 89E4771B42; Thu, 8 Feb 2024 11:32:44 +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=1707391967; cv=none; b=JdOhHBsWSQBeD24A5/dLLgloLCjk1qD9fNm7FFM7mwRy2QQEOLHmSlE752Iy3AFfwJ4d8Yam1WoJ30lL5WWpkWg0JCG6K4BvSzgi2Qj7kor1v8sGIE7yYBkL8ezhz4AM9RsKdhokLZX9+lzEtYKXv1Ejdb1LTLjzP55v7744GqE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707391967; c=relaxed/simple; bh=dXgLmFoGXsUoN83vaKAB+qITVvUGvBgwTEfzq1O3pUc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YWTMVMtx2ZGrDh7KdtkzTL7OQov7Jav+WK5mHIuXzrt8lHGArxLXlfGqyCvDDL2EnNnmiDk+7H705NvgdQj7dOltFQPZDNhxdbIbj8QixSTQPfMRsFtSFS9KwAwTmPa48a9X+2+LT/r4dt/vJV/0FAXDv7lfqEGbuUY9yIgDZkg= 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=T142XgkU; 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=1707391965; x=1738927965; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dXgLmFoGXsUoN83vaKAB+qITVvUGvBgwTEfzq1O3pUc=; b=T142XgkUdxD2UjlcQvs9s4xS8mKNttr4DOLRy0/Q3Imhi6dO/cDutNpq 3O0aA2ZyyawsNSYEuTW5hz5WFqJtOHnAoJYcQCi4Cu/6Zd2GKTKQOc6aP JPx37KTngp2Xax2zN0y0PlaCEjf3gHB7EcSKzXECZfRrtblNbfmOC487B 4tmQ1lcxKEihvIAA5p7cQaQWYB2PLT2Q9P9xFgfMUKnQKub1LiXvuVxyW caJS/qlBqzLTendAOn345eYCxGWFMhczUKVbViMvN4Inm9YnKTHCd4Zmx kDqCAnvutK6HRfijlgNGIos6juBBMOU5H+NpYLbJojiTlAR1Plk+BVxeo w==; X-IronPort-AV: E=McAfee;i="6600,9927,10977"; a="1345726" X-IronPort-AV: E=Sophos;i="6.05,253,1701158400"; d="scan'208";a="1345726" 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:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,253,1701158400"; d="scan'208";a="1957773" 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:38 -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 10/12] perf intel-pt: Improve man page format Date: Thu, 8 Feb 2024 13:31:25 +0200 Message-Id: <20240208113127.22216-11-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: 1790330420729288251 X-GMAIL-MSGID: 1790330420729288251 Improve format of config terms and section references. Signed-off-by: Adrian Hunter Acked-by: Ian Rogers --- tools/perf/Documentation/perf-intel-pt.txt | 486 +++++++++++---------- 1 file changed, 267 insertions(+), 219 deletions(-) diff --git a/tools/perf/Documentation/perf-intel-pt.txt b/tools/perf/Documentation/perf-intel-pt.txt index 2109690b0d5f..b5fa7c7ad7f5 100644 --- a/tools/perf/Documentation/perf-intel-pt.txt +++ b/tools/perf/Documentation/perf-intel-pt.txt @@ -147,7 +147,7 @@ displayed as follows: There are two ways that instructions-per-cycle (IPC) can be calculated depending on the recording. -If the 'cyc' config term (see config terms section below) was used, then IPC +If the 'cyc' config term (see <<_config_terms,config terms>> section below) was used, then IPC and cycle events are calculated using the cycle count from CYC packets, otherwise MTC packets are used - refer to the 'mtc' config term. When MTC is used, however, the values are less accurate because the timing is less accurate. @@ -235,7 +235,7 @@ which is the same as -e intel_pt/tsc=1,noretcomp=0/ -Note there are now new config terms - see section 'config terms' further below. +Note there are other config terms - see section <<_config_terms,config terms>> further below. The config terms are listed in /sys/devices/intel_pt/format. They are bit fields within the config member of the struct perf_event_attr which is @@ -307,217 +307,264 @@ perf_event_attr is displayed if the -vv option is used e.g. config terms ~~~~~~~~~~~~ -The June 2015 version of Intel 64 and IA-32 Architectures Software Developer -Manuals, Chapter 36 Intel Processor Trace, defined new Intel PT features. -Some of the features are reflect in new config terms. All the config terms are -described below. - -tsc Always supported. Produces TSC timestamp packets to provide - timing information. In some cases it is possible to decode - without timing information, for example a per-thread context - that does not overlap executable memory maps. - - The default config selects tsc (i.e. tsc=1). - -noretcomp Always supported. Disables "return compression" so a TIP packet - is produced when a function returns. Causes more packets to be - produced but might make decoding more reliable. - - The default config does not select noretcomp (i.e. noretcomp=0). - -psb_period Allows the frequency of PSB packets to be specified. - - The PSB packet is a synchronization packet that provides a - starting point for decoding or recovery from errors. - - Support for psb_period is indicated by: - - /sys/bus/event_source/devices/intel_pt/caps/psb_cyc - - which contains "1" if the feature is supported and "0" - otherwise. - - Valid values are given by: - - /sys/bus/event_source/devices/intel_pt/caps/psb_periods - - which contains a hexadecimal value, the bits of which represent - valid values e.g. bit 2 set means value 2 is valid. - - The psb_period value is converted to the approximate number of - trace bytes between PSB packets as: - - 2 ^ (value + 11) - - e.g. value 3 means 16KiB bytes between PSBs - - If an invalid value is entered, the error message - will give a list of valid values e.g. - - $ perf record -e intel_pt/psb_period=15/u uname - Invalid psb_period for intel_pt. Valid values are: 0-5 - - If MTC packets are selected, the default config selects a value - of 3 (i.e. psb_period=3) or the nearest lower value that is - supported (0 is always supported). Otherwise the default is 0. - - If decoding is expected to be reliable and the buffer is large - then a large PSB period can be used. - - Because a TSC packet is produced with PSB, the PSB period can - also affect the granularity to timing information in the absence - of MTC or CYC. - -mtc Produces MTC timing packets. - - MTC packets provide finer grain timestamp information than TSC - packets. MTC packets record time using the hardware crystal - clock (CTC) which is related to TSC packets using a TMA packet. - - Support for this feature is indicated by: - - /sys/bus/event_source/devices/intel_pt/caps/mtc - - which contains "1" if the feature is supported and - "0" otherwise. - - The frequency of MTC packets can also be specified - see - mtc_period below. - -mtc_period Specifies how frequently MTC packets are produced - see mtc - above for how to determine if MTC packets are supported. - - Valid values are given by: - - /sys/bus/event_source/devices/intel_pt/caps/mtc_periods - - which contains a hexadecimal value, the bits of which represent - valid values e.g. bit 2 set means value 2 is valid. - - The mtc_period value is converted to the MTC frequency as: - - CTC-frequency / (2 ^ value) - - e.g. value 3 means one eighth of CTC-frequency - - Where CTC is the hardware crystal clock, the frequency of which - can be related to TSC via values provided in cpuid leaf 0x15. - - If an invalid value is entered, the error message - will give a list of valid values e.g. - - $ perf record -e intel_pt/mtc_period=15/u uname - Invalid mtc_period for intel_pt. Valid values are: 0,3,6,9 - - The default value is 3 or the nearest lower value - that is supported (0 is always supported). - -cyc Produces CYC timing packets. - - CYC packets provide even finer grain timestamp information than - MTC and TSC packets. A CYC packet contains the number of CPU - cycles since the last CYC packet. Unlike MTC and TSC packets, - CYC packets are only sent when another packet is also sent. - - Support for this feature is indicated by: - - /sys/bus/event_source/devices/intel_pt/caps/psb_cyc - - which contains "1" if the feature is supported and - "0" otherwise. - - The number of CYC packets produced can be reduced by specifying - a threshold - see cyc_thresh below. - -cyc_thresh Specifies how frequently CYC packets are produced - see cyc - above for how to determine if CYC packets are supported. - - Valid cyc_thresh values are given by: - - /sys/bus/event_source/devices/intel_pt/caps/cycle_thresholds - - which contains a hexadecimal value, the bits of which represent - valid values e.g. bit 2 set means value 2 is valid. - - The cyc_thresh value represents the minimum number of CPU cycles - that must have passed before a CYC packet can be sent. The - number of CPU cycles is: - - 2 ^ (value - 1) - - e.g. value 4 means 8 CPU cycles must pass before a CYC packet - can be sent. Note a CYC packet is still only sent when another - packet is sent, not at, e.g. every 8 CPU cycles. - - If an invalid value is entered, the error message - will give a list of valid values e.g. - - $ perf record -e intel_pt/cyc,cyc_thresh=15/u uname - Invalid cyc_thresh for intel_pt. Valid values are: 0-12 - - CYC packets are not requested by default. - -pt Specifies pass-through which enables the 'branch' config term. - - The default config selects 'pt' if it is available, so a user will - never need to specify this term. - -branch Enable branch tracing. Branch tracing is enabled by default so to - disable branch tracing use 'branch=0'. - - The default config selects 'branch' if it is available. - -ptw Enable PTWRITE packets which are produced when a ptwrite instruction - is executed. - - Support for this feature is indicated by: - - /sys/bus/event_source/devices/intel_pt/caps/ptwrite - - which contains "1" if the feature is supported and - "0" otherwise. - - As an alternative, refer to "Emulated PTWRITE" further below. - -fup_on_ptw Enable a FUP packet to follow the PTWRITE packet. The FUP packet - provides the address of the ptwrite instruction. In the absence of - fup_on_ptw, the decoder will use the address of the previous branch - if branch tracing is enabled, otherwise the address will be zero. - Note that fup_on_ptw will work even when branch tracing is disabled. - -pwr_evt Enable power events. The power events provide information about - changes to the CPU C-state. - - Support for this feature is indicated by: - - /sys/bus/event_source/devices/intel_pt/caps/power_event_trace - - which contains "1" if the feature is supported and - "0" otherwise. - -event Enable Event Trace. The events provide information about asynchronous - events. - - Support for this feature is indicated by: - - /sys/bus/event_source/devices/intel_pt/caps/event_trace - - which contains "1" if the feature is supported and - "0" otherwise. - -notnt Disable TNT packets. Without TNT packets, it is not possible to walk - executable code to reconstruct control flow, however FUP, TIP, TIP.PGE - and TIP.PGD packets still indicate asynchronous control flow, and (if - return compression is disabled - see noretcomp) return statements. - The advantage of eliminating TNT packets is reducing the size of the - trace and corresponding tracing overhead. - - Support for this feature is indicated by: - - /sys/bus/event_source/devices/intel_pt/caps/tnt_disable - - which contains "1" if the feature is supported and - "0" otherwise. +Config terms are parameters specified with the -e intel_pt// event option, +for example: + + -e intel_pt/cyc/ + +which selects cycle accurate mode. Each config term can have a value which +defaults to 1, so the above is the same as: + + -e intel_pt/cyc=1/ + +Some terms are set by default, so must be set to 0 to turn them off. For +example, to turn off branch tracing: + + -e intel_pt/branch=0/ + +Multiple config terms are separated by commas, for example: + + -e intel_pt/cyc,mtc_period=9/ + +There are also common config terms, see linkperf:perf-record[1] documentation. + +Intel PT config terms are described below. + +*tsc*:: +Always supported. Produces TSC timestamp packets to provide +timing information. In some cases it is possible to decode +without timing information, for example a per-thread context +that does not overlap executable memory maps. ++ +The default config selects tsc (i.e. tsc=1). + +*noretcomp*:: +Always supported. Disables "return compression" so a TIP packet +is produced when a function returns. Causes more packets to be +produced but might make decoding more reliable. ++ +The default config does not select noretcomp (i.e. noretcomp=0). + +*psb_period*:: +Allows the frequency of PSB packets to be specified. ++ +The PSB packet is a synchronization packet that provides a +starting point for decoding or recovery from errors. ++ +Support for psb_period is indicated by: ++ + /sys/bus/event_source/devices/intel_pt/caps/psb_cyc ++ +which contains "1" if the feature is supported and "0" +otherwise. ++ +Valid values are given by: ++ + /sys/bus/event_source/devices/intel_pt/caps/psb_periods ++ +which contains a hexadecimal value, the bits of which represent +valid values e.g. bit 2 set means value 2 is valid. ++ +The psb_period value is converted to the approximate number of +trace bytes between PSB packets as: ++ + 2 ^ (value + 11) ++ +e.g. value 3 means 16KiB bytes between PSBs ++ +If an invalid value is entered, the error message +will give a list of valid values e.g. ++ + $ perf record -e intel_pt/psb_period=15/u uname + Invalid psb_period for intel_pt. Valid values are: 0-5 ++ +If MTC packets are selected, the default config selects a value +of 3 (i.e. psb_period=3) or the nearest lower value that is +supported (0 is always supported). Otherwise the default is 0. ++ +If decoding is expected to be reliable and the buffer is large +then a large PSB period can be used. ++ +Because a TSC packet is produced with PSB, the PSB period can +also affect the granularity to timing information in the absence +of MTC or CYC. + +*mtc*:: +Produces MTC timing packets. ++ +MTC packets provide finer grain timestamp information than TSC +packets. MTC packets record time using the hardware crystal +clock (CTC) which is related to TSC packets using a TMA packet. ++ +Support for this feature is indicated by: ++ + /sys/bus/event_source/devices/intel_pt/caps/mtc ++ +which contains "1" if the feature is supported and +"0" otherwise. ++ +The frequency of MTC packets can also be specified - see +mtc_period below. + +*mtc_period*:: +Specifies how frequently MTC packets are produced - see mtc +above for how to determine if MTC packets are supported. ++ +Valid values are given by: ++ + /sys/bus/event_source/devices/intel_pt/caps/mtc_periods ++ +which contains a hexadecimal value, the bits of which represent +valid values e.g. bit 2 set means value 2 is valid. ++ +The mtc_period value is converted to the MTC frequency as: + + CTC-frequency / (2 ^ value) ++ +e.g. value 3 means one eighth of CTC-frequency ++ +Where CTC is the hardware crystal clock, the frequency of which +can be related to TSC via values provided in cpuid leaf 0x15. ++ +If an invalid value is entered, the error message +will give a list of valid values e.g. ++ + $ perf record -e intel_pt/mtc_period=15/u uname + Invalid mtc_period for intel_pt. Valid values are: 0,3,6,9 ++ +The default value is 3 or the nearest lower value +that is supported (0 is always supported). + +*cyc*:: +Produces CYC timing packets. ++ +CYC packets provide even finer grain timestamp information than +MTC and TSC packets. A CYC packet contains the number of CPU +cycles since the last CYC packet. Unlike MTC and TSC packets, +CYC packets are only sent when another packet is also sent. ++ +Support for this feature is indicated by: ++ + /sys/bus/event_source/devices/intel_pt/caps/psb_cyc ++ +which contains "1" if the feature is supported and +"0" otherwise. ++ +The number of CYC packets produced can be reduced by specifying +a threshold - see cyc_thresh below. + +*cyc_thresh*:: +Specifies how frequently CYC packets are produced - see cyc +above for how to determine if CYC packets are supported. ++ +Valid cyc_thresh values are given by: ++ + /sys/bus/event_source/devices/intel_pt/caps/cycle_thresholds ++ +which contains a hexadecimal value, the bits of which represent +valid values e.g. bit 2 set means value 2 is valid. ++ +The cyc_thresh value represents the minimum number of CPU cycles +that must have passed before a CYC packet can be sent. The +number of CPU cycles is: ++ + 2 ^ (value - 1) ++ +e.g. value 4 means 8 CPU cycles must pass before a CYC packet +can be sent. Note a CYC packet is still only sent when another +packet is sent, not at, e.g. every 8 CPU cycles. ++ +If an invalid value is entered, the error message +will give a list of valid values e.g. ++ + $ perf record -e intel_pt/cyc,cyc_thresh=15/u uname + Invalid cyc_thresh for intel_pt. Valid values are: 0-12 ++ +CYC packets are not requested by default. + +*pt*:: +Specifies pass-through which enables the 'branch' config term. ++ +The default config selects 'pt' if it is available, so a user will +never need to specify this term. + +*branch*:: +Enable branch tracing. Branch tracing is enabled by default so to +disable branch tracing use 'branch=0'. ++ +The default config selects 'branch' if it is available. + +*ptw*:: +Enable PTWRITE packets which are produced when a ptwrite instruction +is executed. ++ +Support for this feature is indicated by: ++ + /sys/bus/event_source/devices/intel_pt/caps/ptwrite ++ +which contains "1" if the feature is supported and +"0" otherwise. ++ +As an alternative, refer to "Emulated PTWRITE" further below. + +*fup_on_ptw*:: +Enable a FUP packet to follow the PTWRITE packet. The FUP packet +provides the address of the ptwrite instruction. In the absence of +fup_on_ptw, the decoder will use the address of the previous branch +if branch tracing is enabled, otherwise the address will be zero. +Note that fup_on_ptw will work even when branch tracing is disabled. + +*pwr_evt*:: +Enable power events. The power events provide information about +changes to the CPU C-state. ++ +Support for this feature is indicated by: ++ + /sys/bus/event_source/devices/intel_pt/caps/power_event_trace ++ +which contains "1" if the feature is supported and +"0" otherwise. + +*event*:: +Enable Event Trace. The events provide information about asynchronous +events. ++ +Support for this feature is indicated by: ++ + /sys/bus/event_source/devices/intel_pt/caps/event_trace ++ +which contains "1" if the feature is supported and +"0" otherwise. + +*notnt*:: +Disable TNT packets. Without TNT packets, it is not possible to walk +executable code to reconstruct control flow, however FUP, TIP, TIP.PGE +and TIP.PGD packets still indicate asynchronous control flow, and (if +return compression is disabled - see noretcomp) return statements. +The advantage of eliminating TNT packets is reducing the size of the +trace and corresponding tracing overhead. ++ +Support for this feature is indicated by: ++ + /sys/bus/event_source/devices/intel_pt/caps/tnt_disable ++ +which contains "1" if the feature is supported and +"0" otherwise. + + +config terms on other events +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Some Intel PT features work with other events, features such as AUX area sampling +and PEBS-via-PT. In those cases, the other events can have config terms below: + +*aux-sample-size*:: + Used to set the AUX area sample size, refer to the section + <<_aux_area_sampling_option,AUX area sampling option>> + +*aux-output*:: + Used to select PEBS-via-PT, refer to the + section <<_pebs_via_intel_pt,PEBS via Intel PT>> AUX area sampling option @@ -592,7 +639,8 @@ The default snapshot size is the auxtrace mmap size. If neither auxtrace mmap s nor snapshot size is specified, then the default is 4MiB for privileged users (or if /proc/sys/kernel/perf_event_paranoid < 0), 128KiB for unprivileged users. If an unprivileged user does not specify mmap pages, the mmap pages will be -reduced as described in the 'new auxtrace mmap size option' section below. +reduced as described in the <<_new_auxtrace_mmap_size_option,new auxtrace mmap size option>> +section below. The snapshot size is displayed if the option -vv is used e.g. @@ -948,11 +996,11 @@ transaction start, commit or abort. Note that "instructions", "cycles", "branches" and "transactions" events depend on code flow packets which can be disabled by using the config term -"branch=0". Refer to the config terms section above. +"branch=0". Refer to the <<_config_terms,config terms>> section above. "ptwrite" events record the payload of the ptwrite instruction and whether "fup_on_ptw" was used. "ptwrite" events depend on PTWRITE packets which are -recorded only if the "ptw" config term was used. Refer to the config terms +recorded only if the "ptw" config term was used. Refer to the <<_config_terms,config terms>> section above. perf script "synth" field displays "ptwrite" information like this: "ip: 0 payload: 0x123456789abcdef0" where "ip" is 1 if "fup_on_ptw" was used. @@ -960,7 +1008,7 @@ used. "Power" events correspond to power event packets and CBR (core-to-bus ratio) packets. While CBR packets are always recorded when tracing is enabled, power event packets are recorded only if the "pwr_evt" config term was used. Refer to -the config terms section above. The power events record information about +the <<_config_terms,config terms>> section above. The power events record information about C-state changes, whereas CBR is indicative of CPU frequency. perf script "event,synth" fields display information like this: @@ -1116,7 +1164,7 @@ What *will* be decoded with the (single) q option: - asynchronous branches such as interrupts - indirect branches - function return target address *if* the noretcomp config term (refer - config terms section) was used + <<_config_terms,config terms>> section) was used - start of (control-flow) tracing - end of (control-flow) tracing, if it is not out of context - power events, ptwrite, transaction start and abort @@ -1129,7 +1177,7 @@ Repeating the q option (double-q i.e. qq) results in even faster decoding and ev less detail. The decoder decodes only extended PSB (PSB+) packets, getting the instruction pointer if there is a FUP packet within PSB+ (i.e. between PSB and PSBEND). Note PSB packets occur regularly in the trace based on the psb_period -config term (refer config terms section). There will be a FUP packet if the +config term (refer <<_config_terms,config terms>> section). There will be a FUP packet if the PSB+ occurs while control flow is being traced. What will *not* be decoded with the qq option: From patchwork Thu Feb 8 11:31:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 198356 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp119437dyd; Thu, 8 Feb 2024 04:12:55 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXmcWoMwpgnEI3IkRx2DH9OZya/O6m2ZeFFVujAy/sHAYpORXV+8ezCS56RQs9eaupL8hmkHFbU7rpYTMftStOK5gOsYw== X-Google-Smtp-Source: AGHT+IEMyZo85CjCgeDpvj/RIDpYoHl8htrGn+5qUo6kVCtkNEBsDI+0GWuAP3FYDz93CyD0yEmJ X-Received: by 2002:a17:902:6b8a:b0:1d9:6009:c23d with SMTP id p10-20020a1709026b8a00b001d96009c23dmr7171228plk.54.1707394375328; Thu, 08 Feb 2024 04:12:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707394375; cv=pass; d=google.com; s=arc-20160816; b=aBBZpAvSKWo82BFtBTzsvqXxgrDGKSYAKyFG78kGiPtYefYaQzSYkZTqUCmioeryYg lYM3/hFvZhKnU25lpk4CxE+nMs98pEFHOq4WjbW7l5+2Ioxik9Dmxv/OkGE3VeOKF2sq kMbWPxEeRCy8m8jlXFtabvhHajl+zyK9NSJqLN6jPPmatt8Hd8pPOQMNBX1e1/3jj+W0 kYFFS5O+urlM/27XHy7kP6eee0NAgfHKVhNVY72GZpHPSzWQI+nveH0MnIPm+AQEm+vz e/8jfBy4qLRxBLXluxibc9XpXN1NQ7YccpxbJNhSCqzGUQe+3U6uzRehmIpYm8PUO6Mj sb1g== 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=sRFU109qiKcwjJTF4G9m4mCsjont7dK4MYginb09Tnk=; fh=wwRtbTl7VFYJ5eMUFzLmFO1XZH1Dy+GSMT4buBcr+Qw=; b=TIbvYFFQeEj+EJ4k4v3IQT3DnS11IUo8Ono7H2fCbd80WLevjZWYizt8HTDKfgVKIi SIMjtNOKwxRHjUgS1tDlRnD96TsY7dQlaafBHxj7kBHQD4Y9GtWwmaR+STqoca4vdUTV eMoIsQpEUuwrM9rhQgkX/bbbq5awS2khAbw6Kg+rist7dnwXkosqvhVu++jN8EzzIJOd fUQFtf1iYl+XOnjpert3HnXeFvSCM/U7iU78XHLAbUsC8pZ85lIdCjSs0cY9eqoUdHet o4nDCpz2oi7y8lomlMqWV5oSjJ+e6AsM0KWDJZ00kZtkspgC34Gnw42SkYdho4boIYE7 H78w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NNClvapV; 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-57971-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57971-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCUoP//+4s0nVPuBoAhPtkFfm9d4i5R0d9WiA2HlWVN3SjXMfpv3cDZ0TJM80q7nvBuurLXmxpknhMBBQv5RAF9nxwfSuA== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id h8-20020a170902680800b001d9fcd34721si2060218plk.119.2024.02.08.04.12.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 04:12:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57971-ouuuleilei=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=NNClvapV; 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-57971-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57971-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 9ED75B27766 for ; Thu, 8 Feb 2024 11:35:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CBE8578B43; Thu, 8 Feb 2024 11:32:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="NNClvapV" 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 0D0D276C72; Thu, 8 Feb 2024 11:32:50 +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=1707391971; cv=none; b=VA2YpdzbvLX1qlWsd1ptDDdhgrDsQxFh94PSIBjGGwUkIrRqq/LAgnlBYL1P7zF/4OBBLqLR+9m2xlYHntxtgk1Nw+g2t08kyO/HU94oC70P5m19Pb5JjyC2uQfX/sAHOTQ4kmvM89J70QU8XU2tdVxfo/wtnWlAAJEhpekebPA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707391971; c=relaxed/simple; bh=rMOg95dCUtTuUufz+Irpzx0/1+cSCGSF32IEAjEJKjU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PcZ/BDdxLCVMlkElG/Zd5OXZFUWa+9/P3aEyesXVG0D6p8qdcuzpAQcT8UPTW2TsgHK7UIADc07PY8HgOpaE5AGT3d/2izLAIx1ZqrOlB99U/IQiAWraTYYtFrbv3nn2gRqvXXtrrvV6nnbu3G/U+AtBa6MZ01Ew2qeqfL5hf4E= 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=NNClvapV; 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=1707391970; x=1738927970; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rMOg95dCUtTuUufz+Irpzx0/1+cSCGSF32IEAjEJKjU=; b=NNClvapVzzDoeaxahwy8e9d2UnQvoxPLwKTa4ks9Cg35fG2k4v4FK7n/ Ayb81C6cWTBJ2jdCbbYH3fk5R94Z5QfVddHd/pl1/Dq3yV8pi8ltk0mAQ qMiG9jPE45cjHMcGkhFG2CRlM/VplcG+9KQiyCPdSsdyPOBLwK6MlEDOR zqhmfdw7dmja+HUsn4olv8WN/fqP5hIsJWKdZn5Y7pJenRkApgUrdNkZn d8dVurQknrSnb6hdoHJI49xubVadHdi3Md7IJHB1InK1acjCGs5RsHmih f89ScbRO7QxAN1Z75MPeoDdVqP2L9GAyQsfkRE1WTnGzzLZJMeQ9W06QC A==; X-IronPort-AV: E=McAfee;i="6600,9927,10977"; a="1345758" X-IronPort-AV: E=Sophos;i="6.05,253,1701158400"; d="scan'208";a="1345758" 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:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,253,1701158400"; d="scan'208";a="1957848" 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:44 -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 11/12] perf intel-pt: Add documentation for pause / resume Date: Thu, 8 Feb 2024 13:31:26 +0200 Message-Id: <20240208113127.22216-12-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: 1790332764633148200 X-GMAIL-MSGID: 1790332764633148200 Document the use of aux-action config term and provide a simple example. Signed-off-by: Adrian Hunter Acked-by: Ian Rogers --- Changes in V5: Added more examples tools/perf/Documentation/perf-intel-pt.txt | 108 +++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/tools/perf/Documentation/perf-intel-pt.txt b/tools/perf/Documentation/perf-intel-pt.txt index b5fa7c7ad7f5..c86deae170e4 100644 --- a/tools/perf/Documentation/perf-intel-pt.txt +++ b/tools/perf/Documentation/perf-intel-pt.txt @@ -551,6 +551,9 @@ Support for this feature is indicated by: which contains "1" if the feature is supported and "0" otherwise. +*aux-action=start-paused*:: +Start tracing paused, refer to the section <<_pause_or_resume_tracing,Pause or Resume Tracing>> + config terms on other events ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -566,6 +569,9 @@ and PEBS-via-PT. In those cases, the other events can have config terms below: Used to select PEBS-via-PT, refer to the section <<_pebs_via_intel_pt,PEBS via Intel PT>> +*aux-action*:: + Used to pause or resume tracing, refer to the section + <<_pause_or_resume_tracing,Pause or Resume Tracing>> AUX area sampling option ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1911,6 +1917,108 @@ For pipe mode, the order of events and timestamps can presumably be messed up. +Pause or Resume Tracing +----------------------- + +With newer Kernels, it is possible to use other selected events to pause +or resume Intel PT tracing. This is configured by using the "aux-action" +config term: + +"aux-action=pause" is used with events that are to pause Intel PT tracing. + +"aux-action=resume" is used with events that are to resume Intel PT tracing. + +"aux-action=start-paused" is used with the Intel PT event to start in a +paused state. + +For example, to trace only the uname system call (sys_newuname) when running the +command line utility uname: + + $ perf record --kcore -e intel_pt/aux-action=start-paused/k,syscalls:sys_enter_newuname/aux-action=resume/,syscalls:sys_exit_newuname/aux-action=pause/ uname + Linux + [ perf record: Woken up 1 times to write data ] + [ perf record: Captured and wrote 0.043 MB perf.data ] + $ perf script --call-trace + uname 30805 [000] 24001.058782799: name: 0x7ffc9c1865b0 + uname 30805 [000] 24001.058784424: psb offs: 0 + uname 30805 [000] 24001.058784424: cbr: 39 freq: 3904 MHz (139%) + uname 30805 [000] 24001.058784629: ([kernel.kallsyms]) debug_smp_processor_id + uname 30805 [000] 24001.058784629: ([kernel.kallsyms]) __x64_sys_newuname + uname 30805 [000] 24001.058784629: ([kernel.kallsyms]) down_read + uname 30805 [000] 24001.058784629: ([kernel.kallsyms]) __cond_resched + uname 30805 [000] 24001.058784629: ([kernel.kallsyms]) preempt_count_add + uname 30805 [000] 24001.058784629: ([kernel.kallsyms]) in_lock_functions + uname 30805 [000] 24001.058784629: ([kernel.kallsyms]) preempt_count_sub + uname 30805 [000] 24001.058784629: ([kernel.kallsyms]) up_read + uname 30805 [000] 24001.058784629: ([kernel.kallsyms]) preempt_count_add + uname 30805 [000] 24001.058784838: ([kernel.kallsyms]) in_lock_functions + uname 30805 [000] 24001.058784838: ([kernel.kallsyms]) preempt_count_sub + uname 30805 [000] 24001.058784838: ([kernel.kallsyms]) _copy_to_user + uname 30805 [000] 24001.058784838: ([kernel.kallsyms]) syscall_exit_to_user_mode + uname 30805 [000] 24001.058784838: ([kernel.kallsyms]) syscall_exit_work + uname 30805 [000] 24001.058784838: ([kernel.kallsyms]) perf_syscall_exit + uname 30805 [000] 24001.058784838: ([kernel.kallsyms]) debug_smp_processor_id + uname 30805 [000] 24001.058785046: ([kernel.kallsyms]) perf_trace_buf_alloc + uname 30805 [000] 24001.058785046: ([kernel.kallsyms]) perf_swevent_get_recursion_context + uname 30805 [000] 24001.058785046: ([kernel.kallsyms]) debug_smp_processor_id + uname 30805 [000] 24001.058785046: ([kernel.kallsyms]) debug_smp_processor_id + uname 30805 [000] 24001.058785046: ([kernel.kallsyms]) perf_tp_event + uname 30805 [000] 24001.058785046: ([kernel.kallsyms]) perf_trace_buf_update + uname 30805 [000] 24001.058785046: ([kernel.kallsyms]) tracing_gen_ctx_irq_test + uname 30805 [000] 24001.058785046: ([kernel.kallsyms]) perf_swevent_event + uname 30805 [000] 24001.058785046: ([kernel.kallsyms]) __perf_event_account_interrupt + uname 30805 [000] 24001.058785046: ([kernel.kallsyms]) __this_cpu_preempt_check + uname 30805 [000] 24001.058785046: ([kernel.kallsyms]) perf_event_output_forward + uname 30805 [000] 24001.058785046: ([kernel.kallsyms]) perf_event_aux_pause + uname 30805 [000] 24001.058785046: ([kernel.kallsyms]) ring_buffer_get + uname 30805 [000] 24001.058785046: ([kernel.kallsyms]) __rcu_read_lock + uname 30805 [000] 24001.058785046: ([kernel.kallsyms]) __rcu_read_unlock + uname 30805 [000] 24001.058785254: ([kernel.kallsyms]) pt_event_stop + uname 30805 [000] 24001.058785254: ([kernel.kallsyms]) debug_smp_processor_id + uname 30805 [000] 24001.058785254: ([kernel.kallsyms]) debug_smp_processor_id + uname 30805 [000] 24001.058785254: ([kernel.kallsyms]) native_write_msr + uname 30805 [000] 24001.058785463: ([kernel.kallsyms]) native_write_msr + uname 30805 [000] 24001.058785639: 0x0 + +The example above uses tracepoints, but any kind of sampled event can be used. + +For example: + + Tracing between arch_cpu_idle_enter() and arch_cpu_idle_exit() using breakpoint events: + + $ sudo cat /proc/kallsyms | sort | grep ' arch_cpu_idle_enter\| arch_cpu_idle_exit' + ffffffffb605bf60 T arch_cpu_idle_enter + ffffffffb614d8a0 W arch_cpu_idle_exit + $ sudo perf record --kcore -a -e intel_pt/aux-action=start-paused/k -e mem:0xffffffffb605bf60:x/aux-action=resume/ -e mem:0xffffffffb614d8a0:x/aux-action=pause/ -- sleep 1 + [ perf record: Woken up 1 times to write data ] + [ perf record: Captured and wrote 1.387 MB perf.data ] + + Tracing __alloc_pages() using kprobes: + + $ sudo perf probe --add '__alloc_pages order' + Added new event: probe:__alloc_pages (on __alloc_pages with order) + $ sudo perf probe --add __alloc_pages%return + Added new event: probe:__alloc_pages__return (on __alloc_pages%return) + $ sudo perf record --kcore -aR -e intel_pt/aux-action=start-paused/k -e probe:__alloc_pages/aux-action=resume/ -e probe:__alloc_pages__return/aux-action=pause/ -- sleep 1 + [ perf record: Woken up 1 times to write data ] + [ perf record: Captured and wrote 1.490 MB perf.data ] + + Tracing starting at main() using a uprobe event: + + $ sudo perf probe -x /usr/bin/uname main + Added new event: probe_uname:main (on main in /usr/bin/uname) + $ sudo perf record -e intel_pt/-aux-action=start-paused/u -e probe_uname:main/aux-action=resume/ -- uname + Linux + [ perf record: Woken up 1 times to write data ] + [ perf record: Captured and wrote 0.031 MB perf.data ] + + Tracing occassionally using cycles events with different periods: + + $ perf record --kcore -a -m,64M -e intel_pt/aux-action=start-paused/k -e cycles/aux-action=pause,period=1000000/Pk -e cycles/aux-action=resume,period=10500000/Pk -- firefox + [ perf record: Woken up 19 times to write data ] + [ perf record: Captured and wrote 16.561 MB perf.data ] + + EXAMPLE ------- From patchwork Thu Feb 8 11:31:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 198328 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp101496dyd; Thu, 8 Feb 2024 03:37:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUZ2Slu7OWcT1LUrXc4G8KcDRYsdCHA+Gk9L5802TfX51q14rKUBUW3slI23V1nU/oOcYd2SO+Wvp2Iu0NLTNhxHv314g== X-Google-Smtp-Source: AGHT+IGMvdI/9Hfk748X8LlQSbH2gkEJNBnkMlbkQ+US7JegGo1SNPYZ//8tp5GWaNgydPcblvyV X-Received: by 2002:a05:6358:e481:b0:178:8ec9:a2f with SMTP id by1-20020a056358e48100b001788ec90a2fmr6838694rwb.5.1707392222807; Thu, 08 Feb 2024 03:37:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707392222; cv=pass; d=google.com; s=arc-20160816; b=UqfaKe5gzAYgTm2wjC/hJERGDdASPgtrFoJbS5lsAMUaKo41zjPsxRJTh3Boh5OkvV DbWpJk1pTnM0a1frEqxH2e+HFj3zv44avX4F7fhvC2c5+E5WVp4qG59LnULULr9P+CYQ XZPy3Wemv6tpJvd+hDHE1/UnhJ0Ua9fjtDzX7BXXJ9U+RbB6f821BJegD8bGPQiIu5Kx eKysebRmAFaMAPSW83eQ1BkLhTBDZkjfYg2WmJoSWMNU1bY4nOVyzovKIfallktpevsB aSNvgBPSAlqE3qAwi8QFKBsy5PSXb6xQWtJs7sL8XnGQlOKujGw2l3t0EaEuEzkLCWhV m0GA== 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=2sCpe1zfJJLCKweo+jv3p3iPTwl1AjjLkgZPtGcwXHQ=; fh=o1j1BWyIZGhKmtpyMXhrdRBgKrtZbVsCsRfjKTFJ4CY=; b=rEpRzd1rNiMMlRcT4oi1ilPiInA7hBUM0OfgrHNz8cpz0Lf6xsVtPXBfNnl6GR0R69 cMy1+JHu8ys85dsw9dxEN7c8qj7oY38BGwYo2NygNUW4crrfhAvGEwZmgY3BrTaIdBrg urk2lRCjaPhxBmGaaYErwORmMPywqnEhGR0C+RxMnwjkz6hIk9gMcbyVuteWV/cCw2vQ uWjyy0vyo1B/vN8AbkhKprn+PSg7s2LYi5ajKz1SCQ5FAJYJly/1vYB3tU1vs8CfqVUg DX70D3/OILnF+E4w9kN8OrhkM2eO9dtFp1pZmUs+PRV+XJje8EFHdY0PfqC8+2rkn/kp 1rGQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EkO1fpun; 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-57972-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57972-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCUSKrowVDsxQZrbEVcd3jfsH3j7gXW0e45UZY0yDvSNq3AQwcimnm/J/MNQr1PlYPuxxEcnrannQnWELP1qMgQxtaZm0w== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id l6-20020a632506000000b005d81875c4cfsi3784678pgl.882.2024.02.08.03.37.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 03:37:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57972-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EkO1fpun; 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-57972-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57972-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id CE7CC2850D9 for ; Thu, 8 Feb 2024 11:36:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 69C1D78B51; Thu, 8 Feb 2024 11:33:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="EkO1fpun" 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 1FD6178B49; Thu, 8 Feb 2024 11:32:56 +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=1707391977; cv=none; b=bWM/vVSMPtbYWZosnVOHohrwnTOPly8BUwIoGisCE8QuLJhq5KLieMHXDQXFS6MRfpMoMTDLUg7rGEH1Kd1IlP9IGt20FJMA+XH0kbrlW5S0fvzKLdgHIz/PdrvcpLvHvkL0/cMlCdinsp4rfZkJzIL4D7HrsIC7FyHsIUt9UzI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707391977; c=relaxed/simple; bh=z/v40T43ha2hX1e8ZimPBiWM40ccC7SzSxwOXcvZwoA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sG1P5PrHXXTW5UMt0/gcLF9jtYmdrEttCx0BeKNef24hVoE3LO8XzYUgM0jar/6zUusRKA47coqPTnyV3tOkvw+GWtTyfFCVZASczlZUg2tUx0dYWtqwJQ2q969PsHC+WOqNjNQN/pdtvqiLZhi9pV7de5gN0+UmJECSmPXcRAY= 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=EkO1fpun; 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=1707391976; x=1738927976; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=z/v40T43ha2hX1e8ZimPBiWM40ccC7SzSxwOXcvZwoA=; b=EkO1fpunqnrk9NBrQ1Tw5QA47SX4ICesqZYz2m5pSZtzPWaW6ppjw9pn XzzDXHhRZwxLu05c/SQCngpyQ7bswb8q6FkgJint9lguBuL4vOlwUtatX m3I/YG68DIyN2z7Nf5lxqp3cnj5CPhIY1j0wHoV5x/3R4iWIT/n7VDClv Z6kihpieUEQmjMXynEMBBif2xMQX+67fl7DJD565+69eCvrCfJhkxO6Jr j+5Fyzr+f5XaOCiXM6miB3VRFXEFpM6Hoh3B8VoILYN/VXzpN7LhgnTq2 kpRx3McM5l4lmUBp6w9CCBoHrirqvZ2OiMcfalsNS9uhqTmWiHzWQvFOT Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10977"; a="1345804" X-IronPort-AV: E=Sophos;i="6.05,253,1701158400"; d="scan'208";a="1345804" 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:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,253,1701158400"; d="scan'208";a="1957927" 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:50 -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 12/12] perf intel-pt: Add a test for pause / resume Date: Thu, 8 Feb 2024 13:31:27 +0200 Message-Id: <20240208113127.22216-13-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: 1790330507865168174 X-GMAIL-MSGID: 1790330507865168174 Add a simple sub-test to the "Miscellaneous Intel PT testing" test to check pause / resume. Signed-off-by: Adrian Hunter Acked-by: Ian Rogers Reviewed-by: Andi Kleen --- tools/perf/tests/shell/test_intel_pt.sh | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tools/perf/tests/shell/test_intel_pt.sh b/tools/perf/tests/shell/test_intel_pt.sh index 723ec501f99a..e359db0d0ff2 100755 --- a/tools/perf/tests/shell/test_intel_pt.sh +++ b/tools/perf/tests/shell/test_intel_pt.sh @@ -644,6 +644,33 @@ test_pipe() return 0 } +test_pause_resume() +{ + echo "--- Test with pause / resume ---" + if ! perf_record_no_decode -o "${perfdatafile}" -e intel_pt/aux-action=start-paused/u uname ; then + echo "SKIP: pause / resume is not supported" + return 2 + fi + if ! perf_record_no_bpf -o "${perfdatafile}" \ + -e intel_pt/aux-action=start-paused/u \ + -e instructions/period=50000,aux-action=resume,name=Resume/u \ + -e instructions/period=100000,aux-action=pause,name=Pause/u uname ; then + echo "perf record with pause / resume failed" + return 1 + fi + if ! perf script -i "${perfdatafile}" --itrace=b -Fperiod,event | \ + awk 'BEGIN {paused=1;branches=0} + /Resume/ {paused=0} + /branches/ {if (paused) exit 1;branches=1} + /Pause/ {paused=1} + END {if (!branches) exit 1}' ; then + echo "perf record with pause / resume failed" + return 1 + fi + echo OK + return 0 +} + count_result() { if [ "$1" -eq 2 ] ; then @@ -672,6 +699,7 @@ test_power_event || ret=$? ; count_result $ret ; ret=0 test_no_tnt || ret=$? ; count_result $ret ; ret=0 test_event_trace || ret=$? ; count_result $ret ; ret=0 test_pipe || ret=$? ; count_result $ret ; ret=0 +test_pause_resume || ret=$? ; count_result $ret ; ret=0 cleanup