linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Sebastian Andrzej Siewior <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: bigeasy@linutronix.de, linux-kernel@vger.kernel.org,
	peterz@infradead.org, will.deacon@arm.com, olof@lixom.net,
	tglx@linutronix.de, suzuki.poulose@arm.com, mingo@kernel.org,
	mark.rutland@arm.com, hpa@zytor.com
Subject: [tip:smp/hotplug] bus/arm-cci: Use cpu-hp's multi instance support instead custom list
Date: Fri, 2 Sep 2016 11:17:36 -0700	[thread overview]
Message-ID: <tip-b230f0db913136f465a951806f2978b179df95d5@git.kernel.org> (raw)
In-Reply-To: <1471024183-12666-5-git-send-email-bigeasy@linutronix.de>

Commit-ID:  b230f0db913136f465a951806f2978b179df95d5
Gitweb:     http://git.kernel.org/tip/b230f0db913136f465a951806f2978b179df95d5
Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate: Fri, 12 Aug 2016 19:49:41 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 2 Sep 2016 20:05:06 +0200

bus/arm-cci: Use cpu-hp's multi instance support instead custom list

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: rt@linutronix.de
Cc: Olof Johansson <olof@lixom.net>
Link: http://lkml.kernel.org/r/1471024183-12666-5-git-send-email-bigeasy@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 drivers/bus/arm-cci.c | 45 ++++++++++++++++++---------------------------
 1 file changed, 18 insertions(+), 27 deletions(-)

diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
index 5755907f..4c44ba2 100644
--- a/drivers/bus/arm-cci.c
+++ b/drivers/bus/arm-cci.c
@@ -144,15 +144,12 @@ struct cci_pmu {
 	int num_cntrs;
 	atomic_t active_events;
 	struct mutex reserve_mutex;
-	struct list_head entry;
+	struct hlist_node node;
 	cpumask_t cpus;
 };
 
 #define to_cci_pmu(c)	(container_of(c, struct cci_pmu, pmu))
 
-static DEFINE_MUTEX(cci_pmu_mutex);
-static LIST_HEAD(cci_pmu_list);
-
 enum cci_models {
 #ifdef CONFIG_ARM_CCI400_PMU
 	CCI400_R0,
@@ -1506,25 +1503,21 @@ static int cci_pmu_init(struct cci_pmu *cci_pmu, struct platform_device *pdev)
 	return perf_pmu_register(&cci_pmu->pmu, name, -1);
 }
 
-static int cci_pmu_offline_cpu(unsigned int cpu)
+static int cci_pmu_offline_cpu(unsigned int cpu, struct hlist_node *node)
 {
-	struct cci_pmu *cci_pmu;
+	struct cci_pmu *cci_pmu = hlist_entry_safe(node, struct cci_pmu, node);
 	unsigned int target;
 
-	mutex_lock(&cci_pmu_mutex);
-	list_for_each_entry(cci_pmu, &cci_pmu_list, entry) {
-		if (!cpumask_test_and_clear_cpu(cpu, &cci_pmu->cpus))
-			continue;
-		target = cpumask_any_but(cpu_online_mask, cpu);
-		if (target >= nr_cpu_ids)
-			continue;
-		/*
-		 * TODO: migrate context once core races on event->ctx have
-		 * been fixed.
-		 */
-		cpumask_set_cpu(target, &cci_pmu->cpus);
-	}
-	mutex_unlock(&cci_pmu_mutex);
+	if (!cpumask_test_and_clear_cpu(cpu, &cci_pmu->cpus))
+		return 0;
+	target = cpumask_any_but(cpu_online_mask, cpu);
+	if (target >= nr_cpu_ids)
+		return 0;
+	/*
+	 * TODO: migrate context once core races on event->ctx have
+	 * been fixed.
+	 */
+	cpumask_set_cpu(target, &cci_pmu->cpus);
 	return 0;
 }
 
@@ -1768,10 +1761,8 @@ static int cci_pmu_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	mutex_lock(&cci_pmu_mutex);
-	list_add(&cci_pmu->entry, &cci_pmu_list);
-	mutex_unlock(&cci_pmu_mutex);
-
+	cpuhp_state_add_instance_nocalls(CPUHP_AP_PERF_ARM_CCI_ONLINE,
+					 &cci_pmu->node);
 	pr_info("ARM %s PMU driver probed", cci_pmu->model->name);
 	return 0;
 }
@@ -1804,9 +1795,9 @@ static int __init cci_platform_init(void)
 {
 	int ret;
 
-	ret = cpuhp_setup_state_nocalls(CPUHP_AP_PERF_ARM_CCI_ONLINE,
-					"AP_PERF_ARM_CCI_ONLINE", NULL,
-					cci_pmu_offline_cpu);
+	ret = cpuhp_setup_state_multi(CPUHP_AP_PERF_ARM_CCI_ONLINE,
+				      "AP_PERF_ARM_CCI_ONLINE", NULL,
+				      cci_pmu_offline_cpu);
 	if (ret)
 		return ret;
 

  parent reply	other threads:[~2016-09-02 18:18 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-12 17:49 cpu hotplug: add multi instance support Sebastian Andrzej Siewior
2016-08-12 17:49 ` [PATCH 1/6] cpu/hotplug: Rework callback invocation logic Sebastian Andrzej Siewior
2016-09-02  8:22   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2016-09-02 18:16   ` tip-bot for Thomas Gleixner
2016-08-12 17:49 ` [PATCH 2/6] cpu/hotplug: Add multi instance support Sebastian Andrzej Siewior
2016-09-02  8:22   ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2016-09-02 18:16   ` tip-bot for Thomas Gleixner
2016-08-12 17:49 ` [PATCH 3/6] arm/perf: Use multi instance instead of custom list Sebastian Andrzej Siewior
2016-08-17 17:14   ` [PATCH v2 " Sebastian Andrzej Siewior
2016-08-22 15:07     ` Will Deacon
2016-08-22 19:04       ` Sebastian Andrzej Siewior
2016-09-02  8:23     ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-09-02 18:17     ` tip-bot for Sebastian Andrzej Siewior
2016-08-12 17:49 ` [PATCH 4/6] bus/arm-cci: Use cpu-hp's multi instance support instead " Sebastian Andrzej Siewior
2016-09-02  8:23   ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-09-02 18:17   ` tip-bot for Sebastian Andrzej Siewior [this message]
2016-08-12 17:49 ` [PATCH 5/6] bus/arm-ccn: " Sebastian Andrzej Siewior
2016-09-02  8:24   ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-09-02 18:18   ` tip-bot for Sebastian Andrzej Siewior
2016-08-12 17:49 ` [PATCH 6/6] net: virtio-net: Convert to hotplug state machine Sebastian Andrzej Siewior
2016-09-02  8:24   ` [tip:smp/hotplug] net/virtio-net: " tip-bot for Sebastian Andrzej Siewior
2016-09-02 18:18   ` tip-bot for Sebastian Andrzej Siewior

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=tip-b230f0db913136f465a951806f2978b179df95d5@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=bigeasy@linutronix.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@kernel.org \
    --cc=olof@lixom.net \
    --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).