linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: will.deacon@arm.com, mark.rutland@arm.com
Cc: suzuki.poulose@arm.com, peterz@infradead.org,
	bigeasy@linutronix.de, linux-kernel@vger.kernel.org,
	tglx@linutronix.de, linux-arm-kernel@lists.infradead.org
Subject: [PATCH 5/5] perf/arm_dsu: Fix CPU hotplug races
Date: Mon,  4 Feb 2019 17:09:08 +0000	[thread overview]
Message-ID: <d376f6bbd5804616b38145780789785b19a37543.1549299188.git.robin.murphy@arm.com> (raw)
In-Reply-To: <cover.1549299188.git.robin.murphy@arm.com>

Like other system PMUs which associate themselves with an arbitrary CPU
for housekeeping purposes, arm_dsu has a race between registering the
hotplug notifier and registering the PMU device, such that the hotplug
niotifier can potentially fire and attempt to migrate the PMU context
before the latter is valid. This is easily resolved by inhibiting
hotplug until both the notifier and PMU device are successfully set up.

For the same reason, also suppress any synchronous notifier calls in the
cleanup path if PMU registration fails.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
---
 drivers/perf/arm_dsu_pmu.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/perf/arm_dsu_pmu.c b/drivers/perf/arm_dsu_pmu.c
index 660cb8ac886a..cfaca06b964a 100644
--- a/drivers/perf/arm_dsu_pmu.c
+++ b/drivers/perf/arm_dsu_pmu.c
@@ -717,7 +717,8 @@ static int dsu_pmu_device_probe(struct platform_device *pdev)
 
 	dsu_pmu->irq = irq;
 	platform_set_drvdata(pdev, dsu_pmu);
-	rc = cpuhp_state_add_instance(dsu_pmu_cpuhp_state,
+	cpus_read_lock();
+	rc = cpuhp_state_add_instance_cpuslocked(dsu_pmu_cpuhp_state,
 						&dsu_pmu->cpuhp_node);
 	if (rc)
 		return rc;
@@ -738,9 +739,10 @@ static int dsu_pmu_device_probe(struct platform_device *pdev)
 	};
 
 	rc = perf_pmu_register(&dsu_pmu->pmu, name, -1);
+	cpus_read_unlock();
 	if (rc) {
-		cpuhp_state_remove_instance(dsu_pmu_cpuhp_state,
-						 &dsu_pmu->cpuhp_node);
+		cpuhp_state_remove_instance_nocalls(dsu_pmu_cpuhp_state,
+						    &dsu_pmu->cpuhp_node);
 		irq_set_affinity_hint(dsu_pmu->irq, NULL);
 	}
 
-- 
2.20.1.dirty


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2019-02-04 17:10 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-04 17:09 [PATCH 0/5] Fix Arm system PMU hotplug issues Robin Murphy
2019-02-04 17:09 ` [PATCH 1/5] perf/arm-cci: Fix CPU hotplug race avoidance Robin Murphy
2019-02-05 10:10   ` Corentin Labbe
2019-02-05 11:19   ` Suzuki K Poulose
2019-02-10 20:43   ` Thomas Gleixner
2019-02-04 17:09 ` [PATCH 2/5] cpu/hotplug: Export __cpuhp_state_add_instance_cpuslocked() Robin Murphy
2019-02-04 17:09 ` [PATCH 3/5] perf/arm-ccn: Fix CPU hotplug race avoidance Robin Murphy
2019-02-05 11:38   ` Suzuki K Poulose
2019-02-10 20:44   ` Thomas Gleixner
2019-02-04 17:09 ` [PATCH 4/5] cpu/hotplug: Add locked variant of cpuhp_state_add_instance() Robin Murphy
2019-02-04 17:09 ` Robin Murphy [this message]
2019-02-05 11:40   ` [PATCH 5/5] perf/arm_dsu: Fix CPU hotplug races Suzuki K Poulose
2019-02-05 13:04     ` Robin Murphy
2019-02-05  9:25 ` [PATCH 0/5] Fix Arm system PMU hotplug issues Mark Rutland

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=d376f6bbd5804616b38145780789785b19a37543.1549299188.git.robin.murphy@arm.com \
    --to=robin.murphy@arm.com \
    --cc=bigeasy@linutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=peterz@infradead.org \
    --cc=suzuki.poulose@arm.com \
    --cc=tglx@linutronix.de \
    --cc=will.deacon@arm.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;
as well as URLs for NNTP newsgroup(s).