Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp24709pxh; Thu, 7 Apr 2022 12:52:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkPT/38FqpEGZkE+vZoSdHR1b4JvwuDn5/+72ZnSODFCgIxlm8ghAG9DlVgygU4h+Lknd1 X-Received: by 2002:a05:6a02:197:b0:382:a4b0:b9a8 with SMTP id bj23-20020a056a02019700b00382a4b0b9a8mr12469211pgb.325.1649361146390; Thu, 07 Apr 2022 12:52:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649361146; cv=none; d=google.com; s=arc-20160816; b=dqfEDVccXOzZQ9pDJOnodEjh5R+uGR0IrdcZCaQBn4USdfuVUmNL4UJqPi7rZ/Hqqv hXI81LHjbra2HiTe0mUqujxzWgIN6mPqsltZeZNnO383XueiMnEaWQEAH6uc01v4tFIK LsnebmrFvrqWSteWt4FlBmfyyyShYg/8qIlpYk9gsn4aOhbatTKEXa5YGB11EeGUSUBx dCtuvdiKrX7nSs0k51x2G0cmtf181maJyJKgeYLNaWjW9ljrJnb+nED1zF8adLZo0Yy6 CbUW+93MhiVpAU4l7pso1lX6TvcngtHFzW+uyvwb8MVtiN4CwmNGdFVlawkPvEkfce9w nTOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=glYV/l98Ao73KMk9v/wcQMQsuIKB62MFE0MbECEB0bU=; b=JWe/WnEjjjWEBcxiPlrxpE0vQm1tuxFQY3Gq8ZVnB9GPwisGXCRmnSDyRAGefFNt5P irROlZVSclV4pbTgtzI8d2Q8GdQ6danNqzdXo+2mmCUm7nZ+U8K6szgDKHWWwAvBBOoZ jyKfNmgdtVeMeb/uSqr4lK1Ff1smAzlJ5xoRBX17X6kJlt451GXp5mrZVqLy3DmFApUe +w6d4z42+4p5XIpJoQVnY+gAUy7LACqY8jgimVHmXY8083nbGc/S4ZrV1oJ4bbaPclHh 9kTyL6BYpHbuPLBKM1I6gezXzRU8Y7N9sosZ55UfAh/HKrMq6M2tcA+0q4x5f8bYcwli SzFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HqOjqTdp; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id p17-20020a170902e75100b00156fceb78f1si648943plf.318.2022.04.07.12.52.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 12:52:26 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HqOjqTdp; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7BBB4272AF9; Thu, 7 Apr 2022 12:23:24 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239453AbiDGRsh (ORCPT + 99 others); Thu, 7 Apr 2022 13:48:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346561AbiDGRsc (ORCPT ); Thu, 7 Apr 2022 13:48:32 -0400 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59E48271E for ; Thu, 7 Apr 2022 10:46:31 -0700 (PDT) Received: by mail-pg1-x534.google.com with SMTP id c2so5542430pga.10 for ; Thu, 07 Apr 2022 10:46:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=glYV/l98Ao73KMk9v/wcQMQsuIKB62MFE0MbECEB0bU=; b=HqOjqTdpUg8BZniBO/NW6yOtfh1s/xQNadFPrvtrh4cZEyz0PcnUnZHLcuc2NOLgZy 65NawgWlhpko3+AdB6n4v64b2tK8ye4gOhdvV1dD0OFj3XGP19HTxJ1JgyLWm6P6k8+n hNpcW/A8zRCpIWDHw4Bh9nMkRX3vC7DVzrN83N0z1xs1f58zmSaOQvXMQ0oeRE5Ect/n VfLmm3q7xLyeb/MJZSrGjYFiBbCRvYQQGZSfPkuB6NhWjGAhawp5uuweYY8ESS8Ex8KD ZYz8zTlsyCc7DUgDYkGl17tNSOdKqxud95KTOJRehhHpUbDQmnX0PClssah+OnSxbH3N orCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=glYV/l98Ao73KMk9v/wcQMQsuIKB62MFE0MbECEB0bU=; b=Tw70Mu/8MGaafKuufkFapdi264KG7aBN0qDw8LEdtlmrPqKpaFpGldt2sULtOMpvwR BR1mljX9egKvCBhZlRx0gwOmPrWIQ5//iKb6ANdLfqNyAdiuOCPV+3Q8ec6orRsmsfsB Zv1sEfoTxFWyO9kmVOpJCBgHp6JXvu0ZFw1ze3na62fjRTeNjvpjzo/238Z/NScL/FKd t2qY6cqe4RZ+ZW9Htw9WWG4njRxbaItiFPqSIHWrG1cw5GtuMEGTC348V+I8j267IaSO cetIKaEuPSgqNLV1OZ3Y43YRLgREw9Iwa58O3rF3tla2IElkD6Zov0U2r2cdx31Y5Hwo Fjbg== X-Gm-Message-State: AOAM531ZN4OnUahWih8KHU+LwC2dbUWQny4/8ojO8kR+X2yhIk30jKg1 5QYinJhXj4xY7ueQ7v+etTiYbBSIuCmS9Q== X-Received: by 2002:a65:6a97:0:b0:398:ae2:d207 with SMTP id q23-20020a656a97000000b003980ae2d207mr11843101pgu.197.1649353590776; Thu, 07 Apr 2022 10:46:30 -0700 (PDT) Received: from p14s (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id x6-20020a17090aa38600b001ca2f87d271sm9611813pjp.15.2022.04.07.10.46.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 10:46:29 -0700 (PDT) Date: Thu, 7 Apr 2022 11:46:27 -0600 From: Mathieu Poirier To: Mike Leach Cc: suzuki.poulose@arm.com, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, linux-perf-users@vger.kernel.org, leo.yan@linaro.org Subject: Re: [PATCH 06/10] coresight: perf: traceid: Add perf notifiers for trace ID Message-ID: <20220407174627.GA102085@p14s> References: <20220308205000.27646-1-mike.leach@linaro.org> <20220308205000.27646-7-mike.leach@linaro.org> <20220406171132.GA16110@p14s> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Good morning, On Wed, Apr 06, 2022 at 08:38:08PM +0100, Mike Leach wrote: > Hi Mathieu, > > On Wed, 6 Apr 2022 at 18:11, Mathieu Poirier wrote: > > > > On Tue, Mar 08, 2022 at 08:49:56PM +0000, Mike Leach wrote: > > > Adds in notifier calls to the trace ID allocator that perf > > > events are starting and stopping. > > > > > > This ensures that Trace IDs associated with CPUs remain the same > > > throughout the perf session, and are only release when all perf > > > sessions are complete. > > > > > > Signed-off-by: Mike Leach > > > --- > > > drivers/hwtracing/coresight/coresight-etm-perf.c | 16 +++++++++++++++- > > > 1 file changed, 15 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c > > > index c039b6ae206f..008f9dac429d 100644 > > > --- a/drivers/hwtracing/coresight/coresight-etm-perf.c > > > +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c > > > @@ -22,6 +22,7 @@ > > > #include "coresight-etm-perf.h" > > > #include "coresight-priv.h" > > > #include "coresight-syscfg.h" > > > +#include "coresight-trace-id.h" > > > > > > static struct pmu etm_pmu; > > > static bool etm_perf_up; > > > @@ -223,11 +224,21 @@ static void free_event_data(struct work_struct *work) > > > struct list_head **ppath; > > > > > > ppath = etm_event_cpu_path_ptr(event_data, cpu); > > > - if (!(IS_ERR_OR_NULL(*ppath))) > > > + if (!(IS_ERR_OR_NULL(*ppath))) { > > > coresight_release_path(*ppath); > > > + /* > > > + * perf may have read a trace id for a cpu, but never actually > > > + * executed code on that cpu - which means the trace id would > > > + * not release on disable. Re-release here to be sure. > > > + */ > > > + coresight_trace_id_put_cpu_id(cpu, coresight_get_trace_id_map()); > > > > A CPU gets a traceID in event_etm_start() when the event is installed for > > running. Do you see a scenario where etm_free_aux() is called without > > previously calling event_etm_stop()? > > > > To ensure that IDs are obtained in a timely manner, they assign on > read. Therefore when cs_etm.c::cs_etm_info_fill() is called, > potentially the ID will be read for all CPUs - and dumped into the > AUXINFO data at the top of the perf.data file. Right, I realised that when I got to the perf tools part. If we end up keeping the current approach it would be nice to see this explanation in the comment. Otherwise it will be very difficult for anyone new to the project to understand what is going on. > However, a --per-thread execution may actually only start the event on > a subset of cpus, hence we ensure that all cpus are released. > This was proven during testing when I ran both --per-thread and cpu > wide tests with logging monitoring the ID assignments. > > I have programmed this deliberately defensively - on the basis that > the timings and orderings of the code/callbacks in todays perf may not > necessarily be the same in tomorrows. perf. > > In future we may be able to use Suzuki's idea of embedding the ID into > an alternative packet in the perf.data file. but I think that should > be a separate change as it affects decode in a big way. > I really like Suzuki's idea of using a PERF_RECORD_AUX_OUTPUT_HW_ID to convey the traceID to user space for perf sessions. At the very least it is worth prototyping. I generally prefer an incremental approach but in this case it might be better to move forward the right way, right away. We would also avoid having to maintain the old way, the intermediate way and the new way. Thanks, Mathieu > Regards > > Mike > > > > > + } > > > *ppath = NULL; > > > } > > > > > > + /* mark perf event as done for trace id allocator */ > > > + coresight_trace_id_perf_stop(); > > > + > > > free_percpu(event_data->path); > > > kfree(event_data); > > > } > > > @@ -314,6 +325,9 @@ static void *etm_setup_aux(struct perf_event *event, void **pages, > > > sink = user_sink = coresight_get_sink_by_id(id); > > > } > > > > > > + /* tell the trace ID allocator that a perf event is starting up */ > > > + coresight_trace_id_perf_start(); > > > + > > > /* check if user wants a coresight configuration selected */ > > > cfg_hash = (u32)((event->attr.config2 & GENMASK_ULL(63, 32)) >> 32); > > > if (cfg_hash) { > > > -- > > > 2.17.1 > > > > > > > -- > Mike Leach > Principal Engineer, ARM Ltd. > Manchester Design Centre. UK