Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3333833pxj; Tue, 1 Jun 2021 02:55:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvgJpiIBEknxRbPHz9XiQC+RgBC9JdxB5iF5QzLAuA6MNbGOlKmtlLCx1ybeR9VFWcZvOs X-Received: by 2002:aa7:c913:: with SMTP id b19mr4865627edt.323.1622541323850; Tue, 01 Jun 2021 02:55:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622541323; cv=none; d=google.com; s=arc-20160816; b=ppUTJkXgmFW84zAGWYesMztYO5gUd0dGUOeObdkjfWZj7j+2uUEnKJSboAZmcIfc4f WtulQfDZ9lA7qa+5YLEp77DRPdrcs8LX/tyBorpyc05FiBw8d6DK4YYs8d/iQ27qZPKl AxRKK5sBKRmWCG8VvzQr+pgPZXMW0hTzHH9FmOE+TEdIjQEJ0K+vZOvdHVGGHnTUGE6N XBzkUQHOwhNmYNhbdojHSjJToX2m2FMqF2CqhUj8ILLDwwaK7Ya+B81XwWqCrEXY58a2 1ZePACg/RMdh3ADkfNdeL3NGr6Shs+Yb+MewKdhvymF/V6pjOkief2uXPj/Oa2eSpKDG kKdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject; bh=EPZB+mqDWrkZYVUk32UjHqRpv5kbATQM5OYZ4oik+ZQ=; b=iGIYP7hv4Eq6/Ngv2xDi0Dr88SgP2FG2GAxvhbyHeWpyxvcincNSGbLQTcIyT3twdg Jc8r8mlq8U/lFhEUHS9mmhfLloSLdSyqCWWpaLkg2KhQr7tZk5qOdLe4IvHmXs+eTUC3 RMJcc7FperakvVLoxkLCyzzSVwbVw1MIFkjSFSJKc0WggBthcmoaVpKpl7xdyPW+wBf/ 2s8d8TCr4tRmgmfpHTrVCo3Fd8U9j9/WoFFjB8OU2QP5rkk8fl643W3kClEKlmrNfi2I 0lhdEiiVL2+Q+s3r/cwokY1IvHin8CABXFB5YAVnJbIGYgSEQLKVMougROZ6+FR2/HOf 9ZFA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m26si11714715edp.349.2021.06.01.02.55.01; Tue, 01 Jun 2021 02:55:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232138AbhFAJy4 (ORCPT + 99 others); Tue, 1 Jun 2021 05:54:56 -0400 Received: from foss.arm.com ([217.140.110.172]:45498 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230323AbhFAJyz (ORCPT ); Tue, 1 Jun 2021 05:54:55 -0400 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 1DBD011D4; Tue, 1 Jun 2021 02:53:14 -0700 (PDT) Received: from [10.57.9.215] (unknown [10.57.9.215]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B215B3F73D; Tue, 1 Jun 2021 02:53:11 -0700 (PDT) Subject: Re: [PATCH v1 1/3] coresight: etm-perf: Correct buffer syncing for snapshot To: Leo Yan , Arnaldo Carvalho de Melo , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Alexander Shishkin , John Garry , Will Deacon , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Namhyung Kim , Daniel Kiss , Denis Nikitin , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org References: <20210528161552.654907-1-leo.yan@linaro.org> <20210528161552.654907-2-leo.yan@linaro.org> From: James Clark Message-ID: Date: Tue, 1 Jun 2021 12:53:16 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20210528161552.654907-2-leo.yan@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28/05/2021 19:15, Leo Yan wrote: > The perf tool records the Arm CoreSight trace data with snapshot mode > with the option '-S', when receiving USR2 signal, it is observed the > captured trace data size is very varied: from several MBs to ~20MBs. > This can be reproduced with the command: > > perf record -e cs_etm// -S \ > -- dd if=/dev/zero of=/dev/null > /dev/null 2>&1 & > PERFPID=$! > sleep 1 > kill -USR2 $PERFPID > > It's different for only specifying option '-S' than options '-a -S'. If > without option '-a', perf tool creates separate AUX buffers for every > CPU, but the tracer will be enabled only when the profiled program is > scheduled onto the corresponding CPU, this might lead to record very > old trace data when snapshot. > > Let's see below diagram: > snapshot > CPU0: ______###P1###__________________________________________| > CPU1: __________________________###P3###____________###P5###__| > CPU2: ____________________________________###P4###____________| > CPU3: ________________###P2###________________________________V > > In this diagram, the program runs for 5 periods (from P1 to P5), these 5 > periods show the task run on different CPUs, e.g. during P1 period the > program runs on CPU0, and during P2 period the program is migrated to > CPU1, and so on. At the end of P1 period when the program is switched > out from CPU0, the ETR trace data is saved into AUX trace buffer, this > AUX buffer is a dedicated buffer for CPU0's tracer. With the same > logic, P2's trace data is saved into CPU3's tracer buffer, P4's trace > data is saved into CPU2's buffer, P3 and P5's trace data is saved into > CPU1's. Therefore, when snapshot, it saves the trace data from all AUX > ring buffers (in this case, it have total 4 AUX ring buffers) into perf > data file. Hi Leo, I was testing out snapshot mode (without your patch) and I noticed that it only ever collects from the last CPU. For example on a 4 core system, the CPU ID of the AUX records and the AUXTRACE buffers is always 3. This is with systemwide tracing, and running "stress -m 2 -c 2". Is this something that your patch fixes, or am I doing something wrong, or is it just a coincidence? Here's a snippet of the output: ./perf report -D | grep AUX 0 0 0x200 [0x168]: PERF_RECORD_AUXTRACE_INFO type: 3 0 0 0x152248 [0x30]: PERF_RECORD_AUXTRACE size: 0x400000 offset: 0 ref: 0x75e0bdc44ea1bb65 idx: 3 tid: -1 cpu: 3 3 583600975364460 0x152160 [0x40]: PERF_RECORD_AUX offset: 0x400000 size: 0x400000 flags: 0x2 [O] 0 0 0x55c950 [0x30]: PERF_RECORD_AUXTRACE size: 0x400000 offset: 0x400000 ref: 0x6f506d2d02841da4 idx: 3 tid: -1 cpu: 3 3 583602209157460 0x55c908 [0x40]: PERF_RECORD_AUX offset: 0x800000 size: 0x400000 flags: 0x2 [O] 0 0 0x9624d8 [0x30]: PERF_RECORD_AUXTRACE size: 0x400000 offset: 0x800000 ref: 0x2d83d30161e1117a idx: 3 tid: -1 cpu: 3 3 583602526365800 0x962490 [0x40]: PERF_RECORD_AUX offset: 0xc00000 size: 0x400000 flags: 0x2 [O] 0 0 0xd65f00 [0x30]: PERF_RECORD_AUXTRACE size: 0x400000 offset: 0xc00000 ref: 0x5013e6e2a3c97c9 idx: 3 tid: -1 cpu: 3 3 583602714310320 0xd65eb8 [0x40]: PERF_RECORD_AUX offset: 0x1000000 size: 0x400000 flags: 0x2 [O] 0 0 0x1169be8 [0x30]: PERF_RECORD_AUXTRACE size: 0x400000 offset: 0x1000000 ref: 0x67b37e157f843269 idx: 3 tid: -1 cpu: 3 3 583602874193840 0x1169ba0 [0x40]: PERF_RECORD_AUX offset: 0x1400000 size: 0x400000 flags: 0x2 [O] 0 0 0x156d550 [0x30]: PERF_RECORD_AUXTRACE size: 0x400000 offset: 0x1400000 ref: 0x3cb268b926f22d41 idx: 3 tid: -1 cpu: 3 3 583603044203980 0x156d508 [0x40]: PERF_RECORD_AUX offset: 0x1800000 size: 0x400000 flags: 0x2 [O] 0 0 0x1971238 [0x30]: PERF_RECORD_AUXTRACE size: 0x400000 offset: 0x1800000 ref: 0x4905e0a21d5d35d7 idx: 3 tid: -1 cpu: 3 3 583603211393440 0x19711f0 [0x40]: PERF_RECORD_AUX offset: 0x1c00000 size: 0x400000 flags: 0x2 [O] 0 0 0x1d747e0 [0x30]: PERF_RECORD_AUXTRACE size: 0x400000 offset: 0x1c00000 ref: 0x4f8f48007f7d70e7 idx: 3 tid: -1 cpu: 3 3 583603362643100 0x1d74798 [0x40]: PERF_RECORD_AUX offset: 0x2000000 size: 0x400000 flags: 0x2 [O] 0 0 0x2178368 [0x30]: PERF_RECORD_AUXTRACE size: 0x400000 offset: 0x2000000 ref: 0x770d07213be2d29a idx: 3 tid: -1 cpu: 3 3 583603526029900 0x2178320 [0x40]: PERF_RECORD_AUX offset: 0x2400000 size: 0x400000 flags: 0x2 [O] 0 0 0x257bfb0 [0x30]: PERF_RECORD_AUXTRACE size: 0x400000 offset: 0x2400000 ref: 0x2e4ed1454815c13e idx: 3 tid: -1 cpu: 3 3 583603687951260 0x257bf68 [0x40]: PERF_RECORD_AUX offset: 0x2800000 size: 0x400000 flags: 0x2 [O] 0 0 0x297fb18 [0x30]: PERF_RECORD_AUXTRACE size: 0x400000 offset: 0x2800000 ref: 0x644eba01d391129 idx: 3 tid: -1 cpu: 3 Thanks James