Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp487864lqd; Wed, 24 Apr 2024 08:14:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX0cA8nO2Fe8SfKOnfKAPGwt2BujGWSuEP1LYGWHWUGoVJi1FnSoP07hLx0Bdu1YcI2RkKusVFU3Ifr1I/0reaudx1h3YzIFU9WyvkDlA== X-Google-Smtp-Source: AGHT+IHqDYHo8IKCyO8t8BqPdlRsoHHCPZG5xsC7wAgFezvNKdCZJTdx5Jfu2JaDT59uKP37C3vk X-Received: by 2002:a05:6214:e69:b0:6a0:4756:ce99 with SMTP id jz9-20020a0562140e6900b006a04756ce99mr11255837qvb.21.1713971669283; Wed, 24 Apr 2024 08:14:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713971669; cv=pass; d=google.com; s=arc-20160816; b=ehM5xI3PzU6DooXpIUMyerCeutdlCliEZsNDqZIGoxZjZhMQQLK08KBXlFfRzDSDnr cSAG1kQ6IyRsWrKUxz9IAFaxb84DPO0lEWVafm99SlSU+RahYACRKSpwWZcrnKIU83sB wuAJT3Jbn76yAIhmjikoHwuowMvVWQpGfIK8QCCM5+50gjayOiPSI+eNryV//MyugnWE MfH+R8R/O/xcBMRjqulXoCiFe4vU+r1jLvKgRVwgtGJAoOA+oSQYOr1s7/sBCViWrSBy l8z6wSI2c+z515veF6GeY9bArvuLkYxz3tOTMOyHPxn5oLWdLL6esdUatIvM9keq2T5J HuMg== 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:dkim-signature; bh=l96CL3C0CMjmESU5d/Yu/i0e8lRRnuduS9TzRkrFrs8=; fh=sUcyHVzc9tzp/qW3ho/wrYTWvb5f78z2Hxy3lhKCZqI=; b=d195Ml+qGkqQbJFTPRPHDvq7ryXUAn1VkyHuE4XqorHX4fGfU8BihAze0yA3s+Svxi BwELBieudE8/Mr+c2TveAhEO0P3JZkyzZBdP2Zb/hg5QtuOWZda97i3c6Erj/Zs5fZnc oxwtFqshMbLZtpYhCb4/tLbm4YvQz1CD7tI8scxmQpHS9J5jcWuS70xBnkgSQDmcg9YA KUJuB3KiceNur7mG5FPdmYid6UNbavCnX6LNMUSdmpa7CzRUtK+VIsp96mSU0mFlPfzf mzIArgb+SPuM7y8ZpIE/wMJE1r0JWCvWPHpfAmvEBsVzw4TNzw6nclyKUhDLrll/taMT pHqw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="Cz/AbNt1"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-157172-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157172-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id q11-20020ad4574b000000b0069936018655si15610108qvx.262.2024.04.24.08.14.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 08:14:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-157172-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="Cz/AbNt1"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-157172-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157172-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id EF50E1C22F3E for ; Wed, 24 Apr 2024 15:14:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 01AF315EFBE; Wed, 24 Apr 2024 15:14:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Cz/AbNt1" Received: from mail-il1-f169.google.com (mail-il1-f169.google.com [209.85.166.169]) (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 94D8E15EFC7 for ; Wed, 24 Apr 2024 15:14:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713971659; cv=none; b=K4ZRbZTmKEhJYmAUqvpZVZRVVica+Ly6/9C/o6c3BWWVe2pWMARP8c6lD92n/zO+7KIHRsxbi/dJW7yXLVgEk2UlGYZGF2aJ43jvRvZ58k8mS1yKGq25lEQi1lzeYYonVQUWF3tHJoeCeZQmB4FOL5s9q+oXkGrq9NM89Wd7I/E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713971659; c=relaxed/simple; bh=9ApGTsY8uxB5PcD5HHBxIE2iGBtDP6lO/IMIeZfW83Y=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=bD46+RcI1+nZsyVyKqWJumGkr08YQpwCztYx/PPDjPvXiMOX6ZQnoMIYhWQzx5CMX7lXwK/Y+lMNPXv9FyffbFyD+LypzeQw9pBzwgRIvbeSPzO/sEweaubB1JjWkMd7QlDascrjQ8CRoBjTsYEPmQILiDhu6Xv3L84FnRkJcnY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Cz/AbNt1; arc=none smtp.client-ip=209.85.166.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-il1-f169.google.com with SMTP id e9e14a558f8ab-36a0c8c5f18so109645ab.0 for ; Wed, 24 Apr 2024 08:14:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1713971657; x=1714576457; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=l96CL3C0CMjmESU5d/Yu/i0e8lRRnuduS9TzRkrFrs8=; b=Cz/AbNt1Xdf4OUbM6wP0UmJ/lTr//CYR2z5BhFNhyUKcx89V29c8HbcaMdwjVB3WR3 dGwqUT0n3lcvVyM0QYhqapM1NcN0r/pe+E+El2XgREoZOLnP5IzHc9pbIflScsYJbTE5 uYJLBKjJMHjPKCZXIBRVvZH2iota/vPeI4VyNiYFFVEN38iEMsYreIH7ztJ/8Qj+l1J/ 40UmBiHA7h+rHPpVCxUeqbD0rXL9/duwhYjophMvdbqqpgPgrnKeEbsoVmoywz8PQEQk JtFbubS6RDJzaVJK/4kfv31RKmFauUpjDdwUHy40MJCnUfg9wtJ6obdT6j601oqR/N0z kvew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713971657; x=1714576457; 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=l96CL3C0CMjmESU5d/Yu/i0e8lRRnuduS9TzRkrFrs8=; b=BUqV8zTcnxBM6m8jAaAWH/CIuU+nBQ+SQmbwotFUHJ6k4A9+7E2SBuNV3/a5yt1waT 3/2+CM+SDqSLtZ9CukP+8A4Fap7oIylNUDXyXrWxH1d59Qex09ir2D+bI9/I0Dc8SXO1 0UxU+hexC3KZMb0RsieIBXru3/DW0W+u73YunLU4nS82GQmC8qjA3J5HxZDShL1VUoeW WW9Fmge3nMINpHPdFHUDn4AXc53Kd7XVNCU9LPD6sNdvxGahg/5DoS0uOu1SbCS8eS+j NVBOidBtiXWXX1r4Raxlg9EkUEGi+Vih5uoMhjWMsy373kJHA0khStjifH0DU909CSS1 /M1A== X-Forwarded-Encrypted: i=1; AJvYcCVvbBpDtoe2EgnHwOXM9UF3RvkuB/79/cmJBwjAMFzDv31CQh8Yulut5PCp4YdkhRjuBDq/Viq1bkkEGP2MQ5fu5/anLbvuI4gJsMrJ X-Gm-Message-State: AOJu0YzMf5PtH2QFhpplA7ql5Mx/GoOarP1jrVSSFAQEllW59RzDBxVo 2f+yycj7nvQ9iDCjwwzmdgWx76MLKC88tlb9Wvn0zVDKo/Ajy4q94zarpbJB1Pu2hC21aaUWofV w1L+i5SMRAeUShE2F0yM1WFWfzfTNUZ7yBM36 X-Received: by 2002:a92:c9c9:0:b0:36b:fbb3:2e96 with SMTP id k9-20020a92c9c9000000b0036bfbb32e96mr227535ilq.22.1713971656469; Wed, 24 Apr 2024 08:14:16 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240416061533.921723-1-irogers@google.com> In-Reply-To: From: Ian Rogers Date: Wed, 24 Apr 2024 08:14:02 -0700 Message-ID: Subject: Re: [PATCH v2 00/16] Consistently prefer sysfs/json events To: Atish Kumar Patra Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , James Clark , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-riscv@lists.infradead.org, Beeman Strong Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Apr 23, 2024 at 5:28=E2=80=AFPM Atish Kumar Patra wrote: > > On Mon, Apr 15, 2024 at 11:15=E2=80=AFPM Ian Rogers = wrote: > > > > As discussed in: > > https://lore.kernel.org/lkml/20240217005738.3744121-1-atishp@rivosinc.c= om/ > > preferring sysfs/json events consistently (with or without a given > > PMU) will enable RISC-V's hope to customize legacy events in the perf > > tool. > > > > Thanks for remapping legacy events in a generic way. This looks great > and got rid of my > ugly arch specific way of remapping. Is there a good way for the > driver (e.g via sysfs) to tell the perf tool > whether to remap the legacy event or not ? > > In RISC-V the legacy systems without the new ISA extension may not > want to remap if running > the latest kernel. > > I described the problem in detail in the original thread as well. > https://lore.kernel.org/lkml/63d73f09-84e5-49e1-99f5-60f414b22d70@rivosin= c.com/ So the sysfs/json events have priority over the legacy hardware events with this patch series. I'm not clear on your question but here are some scenarios: 1) for a vendor/model with a CPUID json files want to be used: 1.1) the driver shouldn't advertise the events /sys/devices//even= ts 1.2) the json in the perf tool needs to have a mapfile.csv entry for the cpuid to a model directory containing the event json. In the directory the legacy events should be defined. 2) for a vendor/model with a CPUID the driver files should be used: 2.1) the driver should advertise the events in /sys/devices//even= ts 2.2) in the json for the CPUID avoid redefining the events 3) for a vendor/model with a CPUID the legacy events should be used: 3.1) the driver shouldn't advertise the events in /sys/devices//e= vents 3.2) in the json for the CPUID avoid defining the events Are you asking to have both sysfs and json events for a model? In this case, which have priority over the other? It's possible in the pmu.c code to have a prioritized lookup either from json then sysfs or vice-versa, at the moment it is first come first served. To some extent this can be seen on Intel uncore events where there are both sysfs and json events with the same config, when we reverse map if the sysfs name is loaded then it is reverse mapped in verbose log or by perf trace, whilst typically I think the json name is reverse mapped. Are you asking for the search order to be configurable by the driver? In the past I've considered that the search order may be configured in the tool and the user may want to provide their own directory containing additional events and metrics. > FWIW, for the entire series. > Tested-by: Atish Patra Thanks, I think we can go ahead to land this. Kan's comment was to ask for a follow up changing max_precise behavior and I'm hesitant to do two behavior changes in 1 patch series. Ian > > Some minor clean-up is performed on the way. > > > > v2. Additional cleanup particularly adding better error messages. Fix > > some line length issues on the earlier patches. > > > > Ian Rogers (16): > > perf parse-events: Factor out '/.../' parsing > > perf parse-events: Directly pass PMU to parse_events_add_pmu > > perf parse-events: Avoid copying an empty list > > perf pmu: Refactor perf_pmu__match > > perf tests parse-events: Use branches rather than cache-references > > perf parse-events: Legacy cache names on all PMUs and lower priority > > perf parse-events: Handle PE_TERM_HW in name_or_raw > > perf parse-events: Constify parse_events_add_numeric > > perf parse-events: Prefer sysfs/json hardware events over legacy > > perf parse-events: Inline parse_events_update_lists > > perf parse-events: Improve error message for bad numbers > > perf parse-events: Inline parse_events_evlist_error > > perf parse-events: Improvements to modifier parsing > > perf parse-event: Constify event_symbol arrays > > perf parse-events: Minor grouping tidy up > > perf parse-events: Tidy the setting of the default event name > > > > tools/perf/tests/parse-events.c | 6 +- > > tools/perf/util/parse-events.c | 482 ++++++++++++++++---------------- > > tools/perf/util/parse-events.h | 49 ++-- > > tools/perf/util/parse-events.l | 196 +++++++++---- > > tools/perf/util/parse-events.y | 261 +++++++---------- > > tools/perf/util/pmu.c | 27 +- > > tools/perf/util/pmu.h | 2 +- > > 7 files changed, 540 insertions(+), 483 deletions(-) > > > > -- > > 2.44.0.683.g7961c838ac-goog > >