Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp877422pxj; Thu, 27 May 2021 13:51:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3feADHeSbcX7wxgKI6TUatP/KBpyOfv3s/Kpy3uUX2F/gzJDVxaM4tpmCuf7/Af7Qo/XC X-Received: by 2002:a92:cda5:: with SMTP id g5mr4525612ild.245.1622148714496; Thu, 27 May 2021 13:51:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622148714; cv=none; d=google.com; s=arc-20160816; b=K8hS7ehdW71zzxHQ7PK0tkzK5oIV/FVlVj6zjk8AQfjHUan/Q69eAMOmmaR3tO9R77 l7ZFrI7PZsbeC/6D3ihg+huUHNOqKw2UfBFEV8BCY8tg3bErGJpvq/CFW4fBL9l4Ll4J jo8rVNr37Nb2jOBdtjqA1WjsCZudOLOXsXXEH7JCF1CmcL4+U40u1oxle73eXKXcIDv1 DBJENPv7Hdu9VVzXghaHLkwRKqF6lyUUKyFMs7gJNzhlc7tOCcf9iDf4qijFNzqRLIFT OmCPyERLqlr3v5MRAKeJQGC1TL9qaAtEWu/Nq2Oj9s2kAPKXnI/U2llE++77KkxXW6zA sqRg== 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 :cc:to:subject; bh=W7reFXHiFxfLdHylBL/pn1SrcaBMOu9RUsj6Wm1r6og=; b=b120/b66ywAH9uFJhyYavd5ClCFPQcPrZiM4PYyC1+DE6ZDC2edaqiRpuadabPp+kX ULouryZYIQL3HfdAfCDyKOCOXbeHwez3ws0CpwAz0ExNsaz6kfKeIQVur01dDesO9JXQ n6SETHFZ+x0tRCiZcfym7+ZiT9aJ1+EKdu4IQ6/7sxpQn2CZSbdFYWLnz8N6Lv69QRse VQtum4W+8yWAgKaqC4cb6pp+hQOVFHdl8P80j/kBxal4KO2lg3YrsrUDV3r/QybNaHwp Jlf35E4qQwaJ8RIcjkyoUu3bu2iax9d81Olj5UqLF/t32mqzIcPEOGqvBmye+QydP8Ob uSlQ== 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 p26si3973990jal.111.2021.05.27.13.51.39; Thu, 27 May 2021 13:51:54 -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 S236598AbhE0NsU (ORCPT + 99 others); Thu, 27 May 2021 09:48:20 -0400 Received: from foss.arm.com ([217.140.110.172]:58036 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236593AbhE0NsT (ORCPT ); Thu, 27 May 2021 09:48:19 -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 2601614FF; Thu, 27 May 2021 06:46:46 -0700 (PDT) Received: from [10.57.0.246] (unknown [10.57.0.246]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9EA183F73D; Thu, 27 May 2021 06:46:43 -0700 (PDT) Subject: Re: [RFC PATCH v3] perf cs-etm: Split Coresight decode by aux records To: acme@kernel.org, mathieu.poirier@linaro.org, coresight@lists.linaro.org, leo.yan@linaro.org Cc: al.grant@arm.com, branislav.rankov@arm.com, denik@chromium.org, suzuki.poulose@arm.com, anshuman.khandual@arm.com, Mike Leach , John Garry , Will Deacon , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210527104234.24313-1-james.clark@arm.com> From: James Clark Message-ID: <11822824-7486-2333-f039-bfd801b86922@arm.com> Date: Thu, 27 May 2021 16:46:42 +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: <20210527104234.24313-1-james.clark@arm.com> 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 27/05/2021 13:42, James Clark wrote: > Populate the auxtrace queues using AUX records rather than whole > auxtrace buffers. > ... > Snapshot mode still needs to be tested. > Snapshot mode is also working, but needs the following patch applied to reverse aux_offset from the end of the buffer to the beginning: diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 5d6c03488187..9db556e14dfa 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -2700,6 +2700,7 @@ static int cs_etm__queue_aux_fragment(struct perf_session *session, struct perf_record_auxtrace *auxtrace_event; union perf_event auxtrace_fragment; bool matchesCpuPid; + __u64 aux_offset; struct cs_etm_auxtrace *etm = container_of(session->auxtrace, struct cs_etm_auxtrace, auxtrace); @@ -2730,19 +2731,26 @@ static int cs_etm__queue_aux_fragment(struct perf_session *session, else matchesCpuPid = auxtrace_event->cpu == sample->cpu; + /* + * In snapshot/overwrite mode, the head points to the end of the buffer so aux_offset needs + * to have the size subtracted so it points to the beginning as in normal mode. + */ + if (aux_event->flags && PERF_AUX_FLAG_OVERWRITE) + aux_offset = aux_event->aux_offset - aux_event->aux_size; + else + aux_offset = aux_event->aux_offset; + if (matchesCpuPid && - aux_event->aux_offset >= auxtrace_event->offset && - aux_event->aux_offset + aux_event->aux_size <= - auxtrace_event->offset + auxtrace_event->size) { + aux_offset >= auxtrace_event->offset && + aux_offset + aux_event->aux_size <= auxtrace_event->offset + auxtrace_event->size) { /* * If this AUX event was inside this buffer somewhere, create a new auxtrace event * based on the sizes of the aux event, and queue that fragment. */ auxtrace_fragment.auxtrace = *auxtrace_event; auxtrace_fragment.auxtrace.size = aux_event->aux_size; - auxtrace_fragment.auxtrace.offset = aux_event->aux_offset; - file_offset += aux_event->aux_offset - auxtrace_event->offset + - auxtrace_event->header.size; + auxtrace_fragment.auxtrace.offset = aux_offset; + file_offset += aux_offset - auxtrace_event->offset + auxtrace_event->header.size; return auxtrace_queues__add_event(&etm->queues, session, &auxtrace_fragment,