From: Yicong Yang <yangyicong@huawei.com>
To: Ian Rogers <irogers@google.com>
Cc: <yangyicong@hisilicon.com>, <will@kernel.org>,
<mark.rutland@arm.com>, <acme@kernel.org>, <namhyung@kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-perf-users@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <peterz@infradead.org>,
<mingo@redhat.com>, <alexander.shishkin@linux.intel.com>,
<jolsa@kernel.org>, <james.clark@arm.com>,
<dongli.zhang@oracle.com>, <jonathan.cameron@huawei.com>,
<prime.zeng@hisilicon.com>, <linuxarm@huawei.com>
Subject: Re: [PATCH 0/3] Perf avoid opening events on offline CPUs
Date: Tue, 4 Jun 2024 16:03:51 +0800 [thread overview]
Message-ID: <3f43ecf1-ae3c-3418-9798-9f1aa0dcc3d2@huawei.com> (raw)
In-Reply-To: <CAP-5=fXw0=dHORC-kObYFiAco64PGP4_uFr__f9YmVctWtGSfA@mail.gmail.com>
On 2024/6/4 0:42, Ian Rogers wrote:
> On Mon, Jun 3, 2024 at 2:33 AM Yicong Yang <yangyicong@huawei.com> wrote:
>>
>> From: Yicong Yang <yangyicong@hisilicon.com>
>>
>> If user doesn't specify the CPUs, perf will try to open events on CPUs
>> of the PMU which is initialized from the PMU's "cpumask" or "cpus" sysfs
>> attributes if provided. But we doesn't check whether the CPUs provided
>> by the PMU are all online. So we may open events on offline CPUs if PMU
>> driver provide offline CPUs and then we'll be rejected by the kernel:
>>
>> [root@localhost yang]# echo 0 > /sys/devices/system/cpu/cpu0/online
>
> Generally Linux won't let you take CPU0 off line, I'm not able to
> follow this step on x86 Linux. Fwiw, I routinely run perf with the
> core hyperthread siblings offline.
>
It doesn't matter if it's the CPU0 offline or other CPUs. There's no restriction
for CPU0 can go offline or not on arm64 and I just use this for example.
I cannot reproduce it on x86. I think it may because we're initializing the
pmu->cpus in different routines in pmu_cpumask(). There's no "cpus"
for x86's core pmu on my x86 machine:
root@ubuntu204:~# ls /sys/bus/event_source/devices/cpu/
allow_tsx_force_abort caps events format freeze_on_smi perf_event_mux_interval_ms power rdpmc subsystem type uevent
So pmu_cpumask() will infer it as an core pmu and initialize the cpus
with online CPUs [1]. For arm64 there lies a "cpus" sysfs attributes
so pmu->cpus are initialized from the "cpus" without checking each
CPUs is online or not. That's what proposed in Patch 1/3.
There's a "cpus" sysfs for x86's hybrid machine, reading from the code [2].
And it seems always reflect the online CPUs supported by that PMU.
[1] https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/util/pmu.c?h=perf-tools-next#n779
[2] https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree//arch/x86/events/intel/core.c#n5736
Thanks.
next prev parent reply other threads:[~2024-06-04 8:03 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-03 9:28 Yicong Yang
2024-06-03 9:28 ` [PATCH 1/3] perf pmu: Limit PMU cpumask to online CPUs Yicong Yang
2024-06-03 16:52 ` Ian Rogers
2024-06-04 11:12 ` Yicong Yang
2024-06-04 14:12 ` Ian Rogers
2024-06-07 0:09 ` Namhyung Kim
2024-06-07 0:36 ` Ian Rogers
2024-06-07 7:04 ` Ian Rogers
2024-06-03 9:28 ` [PATCH 2/3] perf: arm_pmu: Only show online CPUs in device's "cpus" attribute Yicong Yang
2024-06-03 16:20 ` Ian Rogers
2024-06-04 7:43 ` Yicong Yang
2024-06-07 0:17 ` Namhyung Kim
2024-06-04 12:22 ` Yicong Yang
2024-06-03 9:28 ` [PATCH 3/3] perf: arm_spe: Only show online CPUs in device's "cpumask" attribute Yicong Yang
2024-06-03 16:42 ` [PATCH 0/3] Perf avoid opening events on offline CPUs Ian Rogers
2024-06-04 8:03 ` Yicong Yang [this message]
2024-06-06 7:04 ` Ian Rogers
2024-07-01 14:22 ` Will Deacon
2024-07-03 4:55 ` Ian Rogers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3f43ecf1-ae3c-3418-9798-9f1aa0dcc3d2@huawei.com \
--to=yangyicong@huawei.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=dongli.zhang@oracle.com \
--cc=irogers@google.com \
--cc=james.clark@arm.com \
--cc=jolsa@kernel.org \
--cc=jonathan.cameron@huawei.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=prime.zeng@hisilicon.com \
--cc=will@kernel.org \
--cc=yangyicong@hisilicon.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®