lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220822021520.6996-6-kernelfans@gmail.com>
Date:   Mon, 22 Aug 2022 10:15:15 +0800
From:   Pingfan Liu <kernelfans@...il.com>
To:     linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Cc:     Pingfan Liu <kernelfans@...il.com>, Will Deacon <will@...nel.org>,
        Mark Rutland <mark.rutland@....com>
Subject: [RFC 05/10] perf/arm-dsu: Make dsu_pmu_cpu_teardown() parallel

In the case of kexec quick reboot, dsu_pmu_cpu_teardown() confronts
parallel and lock are needed to protect the contest on a dsu_pmu.

Signed-off-by: Pingfan Liu <kernelfans@...il.com>
Cc: Will Deacon <will@...nel.org>
Cc: Mark Rutland <mark.rutland@....com>
To: linux-arm-kernel@...ts.infradead.org
To: linux-kernel@...r.kernel.org
---
 drivers/perf/arm_dsu_pmu.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/perf/arm_dsu_pmu.c b/drivers/perf/arm_dsu_pmu.c
index a36698a90d2f..aa9f4393ff0c 100644
--- a/drivers/perf/arm_dsu_pmu.c
+++ b/drivers/perf/arm_dsu_pmu.c
@@ -833,16 +833,23 @@ static int dsu_pmu_cpu_teardown(unsigned int cpu, struct hlist_node *node)
 	struct dsu_pmu *dsu_pmu = hlist_entry_safe(node, struct dsu_pmu,
 						   cpuhp_node);
 
-	if (!cpumask_test_and_clear_cpu(cpu, &dsu_pmu->active_cpu))
+	raw_spin_lock(&dsu_pmu->pmu_lock);
+	if (!cpumask_test_and_clear_cpu(cpu, &dsu_pmu->active_cpu)) {
+		raw_spin_unlock(&dsu_pmu->pmu_lock);
 		return 0;
+	}
 
 	dst = dsu_pmu_get_online_cpu_any_but(dsu_pmu, cpu);
 	/* If there are no active CPUs in the DSU, leave IRQ disabled */
-	if (dst >= nr_cpu_ids)
+	if (dst >= nr_cpu_ids) {
+		raw_spin_unlock(&dsu_pmu->pmu_lock);
 		return 0;
+	}
 
-	perf_pmu_migrate_context(&dsu_pmu->pmu, cpu, dst);
+	/* dst should not be in dying mask. So after setting, blocking parallel */
 	dsu_pmu_set_active_cpu(dst, dsu_pmu);
+	raw_spin_unlock(&dsu_pmu->pmu_lock);
+	perf_pmu_migrate_context(&dsu_pmu->pmu, cpu, dst);
 
 	return 0;
 }
@@ -858,6 +865,7 @@ static int __init dsu_pmu_init(void)
 	if (ret < 0)
 		return ret;
 	dsu_pmu_cpuhp_state = ret;
+	cpuhp_set_step_parallel(ret);
 	return platform_driver_register(&dsu_pmu_driver);
 }
 
-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ