Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp884349lqh; Thu, 28 Mar 2024 22:47:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWTc7DqDQ9PO5H0wlgKmivFaydTLphErx6RIWm+1f1v0yav0nJnbaaeuLXgVWzdhp8Lk6maW7JxDHPEBtLO80NeQel5aCXY/kvL4jS1dQ== X-Google-Smtp-Source: AGHT+IFHbxHiJltcSO9FEg5uO9a1p+tBUOsFc85yZ/g02ZPrdQpRJTVau2e18OqXrbhvk8yJ3/xg X-Received: by 2002:a05:6a20:6a21:b0:1a3:6464:1154 with SMTP id p33-20020a056a206a2100b001a364641154mr2272515pzk.0.1711691269744; Thu, 28 Mar 2024 22:47:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711691269; cv=pass; d=google.com; s=arc-20160816; b=naOMZbEkqOfoLn+YhByKyTX3gJEaGc1ICq8Vq6PaKHeU55i1RXoRIOnzxeRMkzgG3H FKzxSS+VKX30PbyFw5sWUvJkaw8ESs3OUl41VADKmdfvZAzVxwuzbNXH59bi5rf5FCgB lPM+j5szL5U7UMtYKL4DLdS0ZOn9zCH2mF4GjRh4lMuAFHviop54s2C3IMv1AfpMLt1u LB/1s3SWIwIpc57DSi/YGPumDYUpKvCxu22aIRuJ+w9Qyj5KR4YvIHhCQ39bzE5we4Ey C3FPaa7feGMYsaGboZdxPQNTxY95jZ96s4eDfWxiKw3UAYn+aEv/eF/gVcSuGE6LfV82 f6TA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=6+2vFU7V6j+41AhIjyIIqYWwenIJmg7wdwdRq1cmkxY=; fh=lN9zNtS8ddN7rfcvDfXEn+QEuyWl+LeGQ0rM6qZ6rCY=; b=J9WR5J3O4/VDbGCXI1H8SZ3Nv7a7PtXhxgSdOuVuxHou5s7HSf9jIrBvk1dT+prNnx kwATKGExiuhsYhKXH4XbgAQaX3R69tcZBhZVKl9gn3jCSZ3SftB+OYr/ZvEKIDODt0Su 8ldf+f3ikF31VYW7GntLC1XQ4gmHv7bs8QcrRsoFFGg//XRrhAVAo04tdpYj989Yjv2a aSqjbBPhAiRLVJVTymI1DCMqD5w1orib9NuHw+eCmhSZKPTdopbFuJBspIFlNT7tU9o7 E7AY75iJt2HXbYwdzWCn/OE6dc6FVZ8QpG0uq5ZC5cA9DmE6kF06Bcc5jfQNHOUmJOCt odWg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-124169-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124169-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id o26-20020a635a1a000000b005e45abc8c8fsi2981994pgb.306.2024.03.28.22.47.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 22:47:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-124169-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-124169-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124169-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 72FE3B21D4E for ; Fri, 29 Mar 2024 05:46:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E22BF3CF7E; Fri, 29 Mar 2024 05:46:14 +0000 (UTC) Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0733C3A8F7; Fri, 29 Mar 2024 05:46:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711691174; cv=none; b=dGr/mzODk+Nmr1adlITiEy5TwCs+tSRKEAXlikNp9qahEXwDpITVTVJB554tprE0sw7UKFEPlSVhrH4tUoDi5OyBeA3MuzA+282swe/p6b171Ot3D5lAv4NxTdPtTTjm5UYKJ+0+6DJ4iVjL2KywU9l+Tum9B50qHURYDUVD/AU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711691174; c=relaxed/simple; bh=KGwkGKtTA4rDrrqayQ/alyrWXig3KMsQmbrIPNkMeVw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=ZXnx+HrYOW5OdmcKRdDeqk5swJr+gvQZQwY3+H5v8D4YBEKiZY2lPLeLS+vgNRNyTDAZaU64o7+TwTJ+3tOk5eZnRH9TgaYPgZ73C9y1OkSs5a+3mDRM9NbmIBxJwUqsfglV8bsbPbtQz05QOOqk4r0a4oWEPpLt5rp4HykGRJo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.215.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-5c66b093b86so2005943a12.0; Thu, 28 Mar 2024 22:46:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711691172; x=1712295972; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6+2vFU7V6j+41AhIjyIIqYWwenIJmg7wdwdRq1cmkxY=; b=QNYNrzIfoBI7hQN81eQOz3SIdLxjH91jl8NqjRwagkC4kiuu4Ad/R9Eyx11s07wjca ZSAWDmjokDZEFyEJHQBBWU+fUTyGqX+h9eW6fXsDCsKHKWND5T3lE05W9fst5pFuigyN Vu7b9yzMO7j3jGB0DsV5CsehM1uymVHCQjhlE7CKRTren/trGhIsjmLvjXICJto3VM/9 zRN2uvOBEeB2OnS4/kD9i9v3rjlEymIvi0SDH/Kri6CPzkf+IZUGNCGgtFapGCFQbs0l JH7pj8zu9ugzIKjgXYcT/VhUOw6tuMv67xHBUsmPjLhOtUyNMDxx4tB7vm9d6YSseKo2 oy1Q== X-Forwarded-Encrypted: i=1; AJvYcCWmWzz+tzDSQvYV2Xm2PUXACMZqrY4SDJcY9Xa8iqmorcWPXWY87FIO2MvadOt3p1dkwUgUVDFkGFcSResOmyKzhOcUFN6voykCP6Je7Yk6NeS3aaTob6qLzG47/2LXnbNVtElZVxKytcHJ7kE0RQ== X-Gm-Message-State: AOJu0Yz926NRS4gRBY45eV39DcNgohqrYyXK90EMvVrO6A96SeGkeBRf CnWtfcf45tnDSM8CMSXtzrSn90livGOuGNfUKiWoE8KCIyajOlih928/567xRIDjjiKy6szE2Xb cZMK+t/OuQXTt1zTUvA/Y9cQSFCY= X-Received: by 2002:a17:90a:8284:b0:2a0:4e60:ba46 with SMTP id g4-20020a17090a828400b002a04e60ba46mr2209931pjn.16.1711691172259; Thu, 28 Mar 2024 22:46:12 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240326202859.960577-1-weilin.wang@intel.com> <20240326202859.960577-2-weilin.wang@intel.com> In-Reply-To: <20240326202859.960577-2-weilin.wang@intel.com> From: Namhyung Kim Date: Thu, 28 Mar 2024 22:46:00 -0700 Message-ID: Subject: Re: [RFC PATCH v5 1/6] perf stat: Parse and find tpebs events when parsing metrics to prepare for perf record sampling To: weilin.wang@intel.com Cc: Ian Rogers , Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Perry Taylor , Samantha Alt , Caleb Biggers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Mar 26, 2024 at 1:29=E2=80=AFPM wrote: > > From: Weilin Wang > > Metrics that use tpebs values would use the :retire_latency keyword in > formulas. We put all these events into a list and pass the list to perf > record to collect their retire latency value. > > Signed-off-by: Weilin Wang > Reviewed-by: Ian Rogers > --- [SNIP] > @@ -681,8 +685,56 @@ static int metricgroup__build_event_string(struct st= rbuf *events, > hashmap__for_each_entry(ctx->ids, cur, bkt) { > const char *sep, *rsep, *id =3D cur->pkey; > enum perf_tool_event ev; > + /* > + * Parse and search for event name with retire_latency mo= difier. > + * If found, put event name into the tpebs_events list. T= his list > + * of events will be passed to perf record for sampling t= o get > + * their reitre_latency value. > + * Search for ":R" in event name without "@". Search for = the > + * last "@R" in event name with "@". What is the retire_latency modifier exactly? Why do you search for :R and @R? What's the difference? Why don't you search for "retire_latency"? Thanks, Namhyung > + */ > + char *p =3D strstr(id, ":R"); > + char *p1 =3D strstr(id, "@R"); > + > + if (p =3D=3D NULL && p1) { > + p =3D strstr(p1+1, "@R"); > + if (p =3D=3D NULL) > + p =3D p1; > + p =3D p+1; > + } > + > + if (p) { > + char *name; > + char *at; > + struct tpebs_event *new_event =3D malloc(sizeof(s= truct tpebs_event)); > > - pr_debug("found event %s\n", id); > + if (!new_event) > + return -ENOMEM; > + > + new_event->tpebs_name =3D strdup(id); > + *p =3D '\0'; > + name =3D malloc(strlen(id) + 2); > + if (!name) > + return -ENOMEM; > + > + at =3D strchr(id, '@'); > + if (at !=3D NULL) { > + *at =3D '/'; > + at =3D strchr(id, '@'); > + *at =3D '/'; > + strcpy(name, id); > + strcat(name, "p"); > + } else { > + strcpy(name, id); > + strcat(name, ":p"); > + } > + new_event->name =3D name; > + *tpebs_event_size +=3D 1; > + pr_debug("retire_latency required, tpebs_event_si= ze=3D%lu, new_event=3D%s\n", > + *tpebs_event_size, new_event->name); > + list_add_tail(&new_event->nd, tpebs_events); > + continue; > + } > > /* Always move tool events outside of the group. */ > ev =3D perf_tool_event__from_str(id);