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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1401257890-30535-2-git-send-email-zheng.z.yan@intel.com>
Date:	Wed, 28 May 2014 14:18:04 +0800
From:	"Yan, Zheng" <zheng.z.yan@...el.com>
To:	linux-kernel@...r.kernel.org
Cc:	a.p.zijlstra@...llo.nl, mingo@...e.hu, eranian@...gle.com,
	ak@...ux.intel.com, "Yan, Zheng" <zheng.z.yan@...el.com>
Subject: [RFC PATCH 1/7] perf, core: Add all PMUs to pmu_idr

Currently, the build-in PMUs are not added to pmu_idr. This makes
a inconvenience for finding PMU by type.

Signed-off-by: Yan, Zheng <zheng.z.yan@...el.com>
---
 kernel/events/core.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index ed50b09..bafc416 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -6496,14 +6496,15 @@ int perf_pmu_register(struct pmu *pmu, const char *name, int type)
 		goto skip_type;
 	pmu->name = name;
 
-	if (type < 0) {
-		type = idr_alloc(&pmu_idr, pmu, PERF_TYPE_MAX, 0, GFP_KERNEL);
-		if (type < 0) {
-			ret = type;
-			goto free_pdc;
-		}
+	ret = idr_alloc(&pmu_idr, pmu, type >= 0 ? type : PERF_TYPE_MAX,
+			0, GFP_KERNEL);
+	if (ret < 0)
+		goto free_pdc;
+	pmu->type = ret;
+	if (WARN_ON_ONCE(type >= 0 && pmu->type != type)) {
+		ret = -EINVAL;
+		goto free_idr;
 	}
-	pmu->type = type;
 
 	if (pmu_bus_running) {
 		ret = pmu_dev_alloc(pmu);
@@ -6575,8 +6576,7 @@ free_dev:
 	put_device(pmu->dev);
 
 free_idr:
-	if (pmu->type >= PERF_TYPE_MAX)
-		idr_remove(&pmu_idr, pmu->type);
+	idr_remove(&pmu_idr, pmu->type);
 
 free_pdc:
 	free_percpu(pmu->pmu_disable_count);
@@ -6598,8 +6598,7 @@ void perf_pmu_unregister(struct pmu *pmu)
 	synchronize_rcu();
 
 	free_percpu(pmu->pmu_disable_count);
-	if (pmu->type >= PERF_TYPE_MAX)
-		idr_remove(&pmu_idr, pmu->type);
+	idr_remove(&pmu_idr, pmu->type);
 	device_del(pmu->dev);
 	put_device(pmu->dev);
 	free_pmu_context(pmu);
-- 
1.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ