Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Yicong Yang <yangyicong@huawei.com>
To: Will Deacon <will@kernel.org>
Cc: <yangyicong@hisilicon.com>, <jonathan.cameron@huawei.com>,
	<mark.rutland@arm.com>, <linux-arm-kernel@lists.infradead.org>,
	<hejunhao3@huawei.com>, <linuxarm@huawei.com>,
	<wangyushan12@huawei.com>, <prime.zeng@hisilicon.com>
Subject: Re: [PATCH v3 2/8] drivers/perf: hisi: Improve the detection of associated CPUs
Date: Thu, 7 Nov 2024 22:11:01 +0800	[thread overview]
Message-ID: <df38a326-bb5c-5a17-9375-f1695cd7d937@huawei.com> (raw)
In-Reply-To: <20241106115134.GC13801@willie-the-truck>

On 2024/11/6 19:51, Will Deacon wrote:
> On Wed, Nov 06, 2024 at 04:33:18PM +0800, Yicong Yang wrote:
>> Hi Will,
>>
>> Further comment on this patch?
> 
> You failed to convince me that copying the online mask is safe, but I
> haven't had time to look into that in more depth myself. Saying "It should
> be safe" isn't really enough -- it _must_ be safe!
> 

I assume the "safe" here means we won't have trouble if CPU in the copied cpumask
offlined since we don't synchronize with the cpuhp here. Accessing cpu_online_mask
itself is safe since it's a piece of static memory.

We'll initialize the hisi_pmu::associated_cpus from cpu_online_mask in the below
cases. For other cases the associated CPUs is initalized in the cpuhp callback
and we won't come here.
1) for a PMU does have associated CPUs like L3C PMU, but the associcated CPUs
   not onlined at probe
2) for a PMU has no association like CPA PMU which locates on a SICL. Before this
   patch this kind of PMU'associated CPUs are initliazed in the cpuhp callbacks

For the above 2 cases it is safe since the driver's not using hisi_pmu::assoicated_cpus
directly but combined with cpu_online_masks. PMU indicates the user the preferred CPU
to open events on by "cpumask" sysfs which shows hisi_pmu::on_cpu. It's initialized/updated in:
1) hisi_pmu_init_associated_cpus() by cpumask_local_spread() which tries to
   found a nearest CPU of the node that the device locates
2) cpuhp callbacks we registered where holds the cpumap upate lock.

Actually we allow hisi_pmu::associated_cpus contains offline CPUs which is also
mentioned in the commit.

Based on above it's safe to use the cpu_online_mask here. But I find one case
doesn't covered by this patch - if boot with maxcpus=1, offline CPU X and offline
CPU0 (both are not assocaited CPUs), hisi_pmu::on_cpu will not be updated. Since
hisi_pmu::associated_cpus won't be updated when onlining an unassociated CPU
and hisi_pmu::on_cpu is selected from the intersection of the associated CPUs
and the online CPUs, the intersection will be empty in this case.

I'll see how to handle in this case and update the patch.

Thanks.



  reply	other threads:[~2024-11-07 14:13 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-26  7:24 [PATCH v3 0/8] Refactor the common parts to the HiSilicon Uncore PMU core and cleanups Yicong Yang
2024-10-26  7:24 ` [PATCH v3 1/8] drivers/perf: hisi: Define a symbol namespace for HiSilicon Uncore PMUs Yicong Yang
2024-10-26  7:24 ` [PATCH v3 2/8] drivers/perf: hisi: Improve the detection of associated CPUs Yicong Yang
2024-10-29 13:28   ` Will Deacon
2024-10-30 14:04     ` Yicong Yang
2024-11-06  8:33       ` Yicong Yang
2024-11-06 11:51         ` Will Deacon
2024-11-07 14:11           ` Yicong Yang [this message]
2024-10-26  7:24 ` [PATCH v3 3/8] drivers/perf: hisi: Extract topology information to a separate structure Yicong Yang
2024-10-26  7:24 ` [PATCH v3 4/8] drivers/perf: hisi: Add a common function to retrieve topology from firmware Yicong Yang
2024-10-26  7:24 ` [PATCH v3 5/8] drivers/perf: hisi: Provide a generic implementation of cpumask/identifier Yicong Yang
2024-10-26  7:24 ` [PATCH v3 6/8] drivers/perf: hisi: Export associated CPUs of each PMU through sysfs Yicong Yang
2024-10-26  7:24 ` [PATCH v3 7/8] drivers/perf: hisi: Fix incorrect variable name "hha_pmu" in DDRC PMU driver Yicong Yang
2024-10-26  7:24 ` [PATCH v3 8/8] drivers/perf: hisi: Delete redundant blank line of DDRC PMU Yicong Yang

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=df38a326-bb5c-5a17-9375-f1695cd7d937@huawei.com \
    --to=yangyicong@huawei.com \
    --cc=hejunhao3@huawei.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linuxarm@huawei.com \
    --cc=mark.rutland@arm.com \
    --cc=prime.zeng@hisilicon.com \
    --cc=wangyushan12@huawei.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