]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drivers/perf: hisi: Migrate to one online CPU if no associated one online
authorYicong Yang <yangyicong@hisilicon.com>
Tue, 10 Dec 2024 14:15:18 +0000 (22:15 +0800)
committerWill Deacon <will@kernel.org>
Tue, 10 Dec 2024 15:57:24 +0000 (15:57 +0000)
If the selected CPU hisi_pmu::on_cpu goes offline, driver will select
a new online CPU from hisi_pmu::associated_cpus, or if no online CPU
found the PMU context won't be migrated. However for uncore PMUs the
associated CPUs are just a peference and it also works to schedule
the events on any online CPUs. So add a fallback to choose an online
CPU if no associated CPUs found.

Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
Link: https://lore.kernel.org/r/20241210141525.37788-4-yangyicong@huawei.com
Signed-off-by: Will Deacon <will@kernel.org>
drivers/perf/hisilicon/hisi_uncore_pmu.c

index 8c404f8b3f39dbb650376fc3b2f66d8c32a3bfc3..c775e4722dac48738779c5574e505f220eac52c4 100644 (file)
@@ -499,9 +499,16 @@ int hisi_uncore_pmu_offline_cpu(unsigned int cpu, struct hlist_node *node)
        /* Give up ownership of the PMU */
        hisi_pmu->on_cpu = -1;
 
-       /* Choose a new CPU to migrate ownership of the PMU to */
+       /*
+        * Migrate ownership of the PMU to a new CPU chosen from PMU's online
+        * associated CPUs if possible, if no associated CPU online then
+        * migrate to one online CPU.
+        */
        target = cpumask_any_and_but(&hisi_pmu->associated_cpus,
                                     cpu_online_mask, cpu);
+       if (target >= nr_cpu_ids)
+               target = cpumask_any_but(cpu_online_mask, cpu);
+
        if (target >= nr_cpu_ids)
                return 0;