Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp44356rdb; Thu, 21 Dec 2023 02:13:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IEIq5OcrKHp5TjvpUuclq2MvCiLIM718J0dnXlxLM71B45yS7PFeG/VG3dGPZfnGBY+IzvZ X-Received: by 2002:a05:6e02:12e4:b0:35e:6ba1:7dfb with SMTP id l4-20020a056e0212e400b0035e6ba17dfbmr19083678iln.29.1703153614930; Thu, 21 Dec 2023 02:13:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703153614; cv=none; d=google.com; s=arc-20160816; b=cDzYFc2CPpf3iHd8KebzGYbuIK8ImbJ5PiUxEB46GnVH4Fxy+QybXnXayOEEJlxTK9 NRFg9HcSwcfW6dYRDyHSi4OXxBSjxMrzE91Dyd0N+jBHI/g1TArCUMNBxaLfx7YXYfMp EqxyV/vnOLE4C/iVm1V/P+9g0FgN0i8ZZb+DEbEEaxNWjH5JIDg1ZakIiHWSzZYwvkz2 SBfdzait/+QWrerB4dpHKdMzYvwAkRRd+XYhB9vYaYYl+eNL8KMKh+1aFvg/AKLIWSSa KkOo7CM4cL8QqjnxYxK4JNV8UiSPzsN2C9h9dIeheMRrC6sECTBnfa7aVsclO1+NvBde MDNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=Gy5fCK6YCs8hZpxvz/wqY5a++9b4pq0BMaikq7tthwQ=; fh=CIhjk7Kden0/2jjkHMjx41rzeKQqpwFmEVfS8ybKOpU=; b=ZVM7eTyukVZCL91E2qSfqddog7IJiyJdEM0r5+BHeBvgnSMfCO0ulg6yMGe57nOKVj Y0Iy8I49XdOa8LMxOGylxcPjCxh2P7geuv5ec2RmRc825tfi/3Xlqam2Epyut7IJKCgM PTsN5fH4BtnDMOkWlgUZrHs7whudy/M/jOvXOyRnttQzsBctH9tKx2r2kcg1dTcpq1Y5 COsH3tnKYgsJBhoNTG42qp1zJsJmOzgWeL0zEJ5tKOeX3NdlkQdomiHEqcOO4L1pYFQ8 NLvp9zXRy8zFYnzpUpVNbt3vw/TwKsDbi0cy1zVSrYa2euhW7tI9SNbK2N9ZKeOMGnZX 0s0w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-8173-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8173-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id o17-20020a635d51000000b00584ca25959csi1371526pgm.540.2023.12.21.02.13.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 02:13:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8173-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-8173-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8173-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 A0708B21FF4 for ; Thu, 21 Dec 2023 10:05:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4CF0D4E1B1; Thu, 21 Dec 2023 10:05:41 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D33DA51C20; Thu, 21 Dec 2023 10:05:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D15742F4; Thu, 21 Dec 2023 02:06:21 -0800 (PST) Received: from [192.168.1.3] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 568F93F5A1; Thu, 21 Dec 2023 02:05:34 -0800 (PST) Message-ID: Date: Thu, 21 Dec 2023 10:05:33 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 From: James Clark Subject: Re: [PATCH RFC V2 1/4] perf/core: Add aux_pause, aux_resume, aux_start_paused To: Adrian Hunter , Peter Zijlstra Cc: Ingo Molnar , Mark Rutland , Alexander Shishkin , Heiko Carstens , Thomas Richter , Hendrik Brueckner , Suzuki K Poulose , Mike Leach , 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 , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org References: <20231208172449.35444-1-adrian.hunter@intel.com> <20231208172449.35444-2-adrian.hunter@intel.com> <0bbbcdb5-41eb-dd07-660a-2e5e4a0d59f0@arm.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 20/12/2023 16:16, Adrian Hunter wrote: > On 20/12/23 17:54, James Clark wrote: >> >> >> On 08/12/2023 17:24, Adrian Hunter wrote: >>> 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-start-paused/k,syscalls:sys_enter_newuname/aux-resume/,syscalls:sys_exit_newuname/aux-pause/}' uname >> >> I think it might be useful to have an aux-toggle option as well, and >> then you could do sampling if you put it on a PMU counter with an >> interval. Unless you can make two events for the same counter with >> different intervals, and one does resume and the other does pause? I'm >> not sure if that would work? > > There is already ->snapshot_aux() for sampling. Is that what you mean? > I suppose that mostly handles that use case yes. Although there are some slight differences. It looks like for SAMPLE_AUX, the buffer size for each sample is fixed and limited to 16 bits in size, whereas between pause and resume you could potentially have multiple buffers delivered to userspace of any size. And it looks like SAMPLE_AUX would leave the trace running even when no samples were being collected. I suppose you might not want to consume the memory bandwidth and turn the trace off between samples, which pause/resume does. Especially if you intend to have long periods between the samples. I think if it did turn out to be useful the toggle function can easily be added later, so I don't intend this comment to be a blocking one. >> >> Other than that it looks ok. I got Coresight working with a couple of >> changes to what you posted on here, but that can always be done more >> thoroughly later if we leave PERF_PMU_CAP_AUX_PAUSE off Coresight for now. > > Thanks a lot for looking at this! >