Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp207738lqb; Tue, 28 May 2024 13:06:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVOeWdbYZ0doOPXLlKzbMy3q4HkRL6sO3NfedX9q6P2UaPUsBv+aXNdQKtY49/gvGK1haExeCYoe7eb01rgZI5uvGY9DnEOylVJv/IacQ== X-Google-Smtp-Source: AGHT+IGf5mbuIu3aDjsNO7Vldjf9K1uJ2RIIRZRcpJztjuozFYpIHIxk25eY/i8q0nxJ6AZKiir7 X-Received: by 2002:a17:902:da8b:b0:1f2:feb4:84f3 with SMTP id d9443c01a7336-1f4ea78481cmr1621915ad.1.1716926763390; Tue, 28 May 2024 13:06:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716926763; cv=pass; d=google.com; s=arc-20160816; b=DYRdIACYlPwxXss3aVbCtcJJOd5vhLgpZNQFTKqmaCTAuUAUt5hp18j0QWNz6IH8Se YSXqYTCwn9Hbl8MQoZnkU4eQLgoJgf/E+s9A2OW2+jcgJOVof6Aa/kC0qYSDd890/GeX 1RaVeqXiCYL7+1XP/52/wwFOqWCzz43NWM9CdlFll6bkL5KfjnmTVbnJoDrw7CGJKYOu aGgzbLHD1Mr9mI/HwPauSCtqU+4nd5z+FvL5S+Uugh4kwPKNg5NH/b58Z0yWs3UR6nIJ YTMKJLJChBVtNxCqozz319Lz5VoZ5pDhGONpsUwqGbh+kUnWpxIQ0IKpLrLulXpjxNnL fz/A== 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=9TMTcoUocvE/NbqECARFUZ+u82wBWW35aaQbNOD16pM=; fh=36xg69vQWg1W5Acp1TvCx+7GheYppNzOeCguGzZL3C8=; b=F6f9f3uYKh/zJX1o6ExvO8MEU13010nRiPDuwDkaaj7fIzD9VJB+WMPVYT5oP0qcHz ibb91qKSj9LJ6rXApW2x3NRoZ2WR3+qaZGgxzdDtLUeDj3HYQt8FOcRJhIy6E1BZiQtK SsphBd1rq1xic60MsoroM6kT15yoh4JM7qe0Rpe+tQ8f83oH1oHFG2Q2JgpILPO2fN1d q+9GWwwduwSdAn5mSph5X1X5qGDdviEM4YOIAfuD+/nG1MiaK5pU6FNZPDyRviZmSqtZ t5U81hvUWtfinMbSlHys6xClNHzFqB1zHx9emJS8tUv2GBLXNJHVLrhoPAk+tUaaImtH 3j6A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=OJX9UL9X; 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-192986-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192986-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6822779b95esi479881a12.348.2024.05.28.13.06.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 13:06:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-192986-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=OJX9UL9X; 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-192986-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192986-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 6A52728C09C for ; Tue, 28 May 2024 19:52:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C5590178385; Tue, 28 May 2024 19:51:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="OJX9UL9X" Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) (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 40A434CDEC for ; Tue, 28 May 2024 19:51:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716925911; cv=none; b=RS7QFTCKfKH4+dPR+vUYKcSM8c4+UVDLgMOufr9KdJ9Gf0v46pS2rxRBBFs9auVYiBhTCXxlV15B0JM1I09i/zeDmsluiCOmSJ28rAY1NBy9XL2Opb7nozOYixRe+b7qsgmaFFTnE+hLTVufyayEwB0IdF+zoPer4vvsAukx7kQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716925911; c=relaxed/simple; bh=HM/62gjuE2bbsMwNJlLbJFt0oSriuYMd4jtJOYaq9mc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=cFfHwFgroUIP3wKSojDlgykf1ip3By0epM59y/qNDqzNs7zi/hN08RPlO54BiTndJbJt2JXtKfOBt1MYTAdjA9w5Bw5o6pG8l7/o6aMiTsORyzXmRBsXhlUVsaneG7wmKF83oZJq2sWwNlyYTn7906rMdhpK+41maLhz0rtozuA= 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=OJX9UL9X; arc=none smtp.client-ip=209.85.160.171 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-qt1-f171.google.com with SMTP id d75a77b69052e-43e14f0bd75so7671cf.1 for ; Tue, 28 May 2024 12:51:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1716925909; x=1717530709; 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=9TMTcoUocvE/NbqECARFUZ+u82wBWW35aaQbNOD16pM=; b=OJX9UL9XZ2dbtp/keUse+W0HOMxuSvr9NT9SFPncvdzcj6Efz6wfAwJqif/tphjQyp iFQ7zDko5U9YCMuVJCjCxnaC3mqGX8j0G6HJZ2YisHr9DEwE7LYivqns0wntdNs7d/G4 1XvbKZ1PgD+KJmQ2WTgO8CmWGt+/Hb3mNmw4rQLZiyOYNQAkebk9HBVX8b2zHHzUJNGG Y5c7lIGSA1Q4newURkOw6TZg4jhisfn1Iukxc5PoeqTDgPgaD9rzqQnPSHMLHKZDm+JQ T63uQx+Hy6nlSHVc99no9ieUhvqOwMfnpJ8i2a1g3ojgsLY4ElJ5NNlwTLQ/nfrx9JN4 2Ilg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716925909; x=1717530709; 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=9TMTcoUocvE/NbqECARFUZ+u82wBWW35aaQbNOD16pM=; b=kx+8j5J/ELap5GoNK9htMoq5VWahfpQLZD/Vs2zkMS3mVF1zvGXlnNzg5SCP/h/luT qfMSWvGGVOsTu/sDprXtKwtrthwz/F98meKVbZC6hUimbFgAsHAjOHNWqkxjqRgVBi5h 8wT1eQIbiIRH/B0UTHFlTj8FhHAdOg32dPgR2RGjo0E/LqYRpT8hn5eI5HZpXD6Ia2l7 dkP9sLVfLopCYjfiXy+mVM39T7JNORsyMcv7LCiZWgL+xcUYPVCj4IpYZZG2oibLv3wI AsRzhumYR83PNJSqAHLwEx/fU1MA4MGZlfF79ORxfd1Jl16sx5RlPqC+oE8iiaEeavY2 f/Kg== X-Forwarded-Encrypted: i=1; AJvYcCXghpe5nbLdTDfvuP6GwVY7ARveNDYIh1grz1jdP3Gv2Vcc6/79kqwTan5AHnZA0Wxhauep51NwY2EWKBFMaPdHkNbOe9gClS4Yo/ir X-Gm-Message-State: AOJu0YxUonlY/h4M02iE3awwIvbbQ0WE7QY9EIhQGnT37v9B3sEyA3Tj JJMjvih/AoHfc7eH32TI4uUGKSH4XLuwgVayuV3kI9s5sxLN3BFYaQGJ/TqmbSPuJVsKEZrYw9T aCm5ckGZDqwxhdXoNy8mo0E5GK3NLfbUuQsnE X-Received: by 2002:a05:622a:4203:b0:43d:a002:b with SMTP id d75a77b69052e-43fe10d6413mr134101cf.9.1716925908895; Tue, 28 May 2024 12:51:48 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240525152927.665498-1-irogers@google.com> <20240527105842.GB33806@debian-dev> In-Reply-To: From: Ian Rogers Date: Tue, 28 May 2024 12:51:36 -0700 Message-ID: Subject: Re: [PATCH v1] perf evlist: Force adding default events only to core PMUs To: Arnaldo Carvalho de Melo Cc: Leo Yan , Linus Torvalds , Peter Zijlstra , Ingo Molnar , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , James Clark , Dominique Martinet , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, May 28, 2024 at 12:44=E2=80=AFPM Arnaldo Carvalho de Melo wrote: > > On Mon, May 27, 2024 at 10:36:45PM -0700, Ian Rogers wrote: > > On Mon, May 27, 2024 at 3:58=E2=80=AFAM Leo Yan wro= te: > > > On Sat, May 25, 2024 at 02:14:26PM -0700, Linus Torvalds wrote: > > > > On Sat, 25 May 2024 at 09:43, Linus Torvalds wrote: > > > > > > This makes 'perf record' work for me again. > > > > > Oh, wait, no it doesn't. > > > > > It makes just the plain "perf record" without any arguments work, > > > > which was what I was testing because I was lazy. > > > > > So now > > > > > $ perf record sleep 1 > > > > > works fine. But > > > > > $ perf record -e cycles:pp sleep 1 > > > > > is still completely broken (with or without ":p" and ":pp"). > > > > Seems to me that this patch fails to check if a PMU is a core-attache= d > > > PMU that can support common hardware events. Therefore, we should > > > consider adding the following check. > > > > +++ b/tools/perf/util/parse-events.c > > > @@ -1594,6 +1594,9 @@ int parse_events_multi_pmu_add(struct parse_eve= nts_state *parse_state, > > > while ((pmu =3D perf_pmus__scan(pmu)) !=3D NULL) { > > > bool auto_merge_stats; > > > > > > + if (hw_config !=3D PERF_COUNT_HW_MAX && !pmu->is_core= ) > > > + continue; > > > + > > > if (parse_events__filter_pmu(parse_state, pmu)) > > > continue; > > > > To be clear, I only compiled this change but I have no chance to test > > > it. @Ian, could you confirm this? > > > Hi Leo, > > > so the code is working as intended. I believe it also agrees with what > > Arnaldo thinks. > > > If you do: > > > $ perf stat -e cycles ... > > > and you have > > > /sys/devices/pmu1/events/cycles > > /sys/devices/pmu2/events/cycles > > > The output of perf stat should contain counts for pmu1 and pmu2. Were > > the event 'data_read' or 'inst_retired.any' we wouldn't be having the > > Sure, what is being asked is to count events and if those two events in > those two PMUs can count, then do what the user asked. > > For 'perf record' we're asking for sampling, if the event has the name > specified and can't be sampled, skip it, warn the user and even so > only if verbose mode is asked, something like: > > root@x1:~# perf record -e cycles -a sleep 1 > [ perf record: Woken up 1 times to write data ] > [ perf record: Captured and wrote 1.998 MB perf.data (4472 samples) ] > root@x1:~# perf evlist > cpu_atom/cycles/ > cpu_core/cycles/ > dummy:u > root@x1:~# > > Cool, there are two 'cycles' events, one in a PMU named 'cpu_atom', > another in a 'cpu_core' one, both can be sampled, my workload may > run/use resources on then, I'm interested, sample both. > > But if we had some other PMU, to use a name Jiri uses in tests/fake > PMUs, the 'krava' PMU and it has a 'cycles' event, so 'krava/cycles/' > and for some reason it doesn't support sampling, skip it, then the > result should be the same as above. > > If the user finds it strange after looking at sysfs that 'krava/cycles/' > isn't being sampled, the usual workflow is to ask perf for more > verbosity, using -v (or multiple 'v' letters to get increasing levels of > verbosity), in which case the user would see: > > root@x1:~# perf record -v -e cycles -a sleep 1 > WARNING: skipping 'krava/cycles/' event, it doesn't support sampling. > [ perf record: Woken up 1 times to write data ] > [ perf record: Captured and wrote 1.998 MB perf.data (4472 samples) ] > root@x1:~# perf evlist The problem here is that we're hiding a problem rather than reporting it. Typically we report the issue and more than that we ask the user to work around the issue. That would be analogous to wanting the user to specify what PMU they want the event to apply to, which has always been perf's behavior. Thanks, Ian > - Arnaldo