Skip to contentSkip to conversation

perf: Don't use -ENOSPC for out of PMU resources

tip:perf/urgent tip-bot for Peter Zijlstra 1 participant 1 message Nov 18, 2011

Subsystems (5)
Arm (32-bit) x86 MIPS perf events +1 more subsystems
lore
Share & tools
lore
#0 lore raw
Commit-ID:  aa2bc1ade59003a379ffc485d6da2d92ea3370a6
Gitweb:     http://git.kernel.org/tip/aa2bc1ade59003a379ffc485d6da2d92ea3370a6
Author:     Peter Zijlstra <[email protected]>
AuthorDate: Wed, 9 Nov 2011 17:56:37 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 14 Nov 2011 13:01:24 +0100

perf: Don't use -ENOSPC for out of PMU resources

People (Linus) objected to using -ENOSPC to signal not having enough resources on the PMU to satisfy the request. Use -EINVAL.

Cc Stephane Eranian <[email protected]>
Cc Will Deacon <[email protected]>
Cc Deng-Cheng Zhu <[email protected]>
Cc David Daney <[email protected]>
Cc Ralf Baechle <[email protected]>
[ merged to newer kernel, fixed up MIPS impact ]
---
 arch/arm/kernel/perf_event.c         |    6 +++---
 arch/mips/kernel/perf_event_mipsxx.c |    8 ++++----
 arch/x86/kernel/cpu/perf_event.c     |   10 +++++-----
 arch/x86/kernel/cpu/perf_event_p4.c  |    2 +-
 4 files changed, 13 insertions(+), 13 deletions(-)
arch/arm/kernel/perf_event.c +3 -3
index 24e2347..ff17b17 100644
@@ -347,15 +347,15 @@ validate_group(struct perf_event *event)
 	memset(&fake_pmu, 0, sizeof(fake_pmu));
 
 	if (!validate_event(&fake_pmu, leader))
-		return -ENOSPC;
+		return -EINVAL;
 
 	list_for_each_entry(sibling, &leader->sibling_list, group_entry) {
 		if (!validate_event(&fake_pmu, sibling))
-			return -ENOSPC;
+			return -EINVAL;
 	}
 
 	if (!validate_event(&fake_pmu, event))
-		return -ENOSPC;
+		return -EINVAL;
 
 	return 0;
 }
arch/mips/kernel/perf_event_mipsxx.c +4 -4
index 4f2971b..315fc0b 100644
@@ -623,7 +623,7 @@ static int mipspmu_event_init(struct perf_event *event)
 	if (!atomic_inc_not_zero(&active_events)) {
 		if (atomic_read(&active_events) > MIPS_MAX_HWEVENTS) {
 			atomic_dec(&active_events);
-			return -ENOSPC;
+			return -EINVAL;
 		}
 
 		mutex_lock(&pmu_reserve_mutex);
@@ -732,15 +732,15 @@ static int validate_group(struct perf_event *event)
 	memset(&fake_cpuc, 0, sizeof(fake_cpuc));
 
 	if (!validate_event(&fake_cpuc, leader))
-		return -ENOSPC;
+		return -EINVAL;
 
 	list_for_each_entry(sibling, &leader->sibling_list, group_entry) {
 		if (!validate_event(&fake_cpuc, sibling))
-			return -ENOSPC;
+			return -EINVAL;
 	}
 
 	if (!validate_event(&fake_cpuc, event))
-		return -ENOSPC;
+		return -EINVAL;
 
 	return 0;
 }
arch/x86/kernel/cpu/perf_event.c +5 -5
index 6408910..ff0e8d4 100644
@@ -588,7 +588,7 @@ done:
 				x86_pmu.put_event_constraints(cpuc, cpuc->event_list[i]);
 		}
 	}
-	return num ? -ENOSPC : 0;
+	return num ? -EINVAL : 0;
 }
 
 /*
@@ -607,7 +607,7 @@ static int collect_events(struct cpu_hw_events *cpuc, struct perf_event *leader,
 
 	if (is_x86_event(leader)) {
 		if (n >= max_count)
-			return -ENOSPC;
+			return -EINVAL;
 		cpuc->event_list[n] = leader;
 		n++;
 	}
@@ -620,7 +620,7 @@ static int collect_events(struct cpu_hw_events *cpuc, struct perf_event *leader,
 			continue;
 
 		if (n >= max_count)
-			return -ENOSPC;
+			return -EINVAL;
 
 		cpuc->event_list[n] = event;
 		n++;
@@ -1316,7 +1316,7 @@ static int validate_event(struct perf_event *event)
 	c = x86_pmu.get_event_constraints(fake_cpuc, event);
 
 	if (!c || !c->weight)
-		ret = -ENOSPC;
+		ret = -EINVAL;
 
 	if (x86_pmu.put_event_constraints)
 		x86_pmu.put_event_constraints(fake_cpuc, event);
@@ -1341,7 +1341,7 @@ static int validate_group(struct perf_event *event)
 {
 	struct perf_event *leader = event->group_leader;
 	struct cpu_hw_events *fake_cpuc;
-	int ret = -ENOSPC, n;
+	int ret = -EINVAL, n;
 
 	fake_cpuc = allocate_fake_cpuc();
 	if (IS_ERR(fake_cpuc))
arch/x86/kernel/cpu/perf_event_p4.c +1 -1
index 492bf13..ef484d9 100644
@@ -1268,7 +1268,7 @@ reserve:
 	}
 
 done:
-	return num ? -ENOSPC : 0;
+	return num ? -EINVAL : 0;
 }
 
 static __initconst const struct x86_pmu p4_pmu = {