aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2011-11-09 11:56:37 -0500
committerIngo Molnar <mingo@elte.hu>2011-11-14 07:01:24 -0500
commitaa2bc1ade59003a379ffc485d6da2d92ea3370a6 (patch)
tree6d3551cbc594f6827682db9ab931e6e22a37fd6a
parent1d5f003f5a964711853514b04ddc872eec0fdc7b (diff)
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. Requested-by: Linus Torvalds <torvalds@linux-foundation.org> Cc: Stephane Eranian <eranian@google.com> Cc: Will Deacon <will.deacon@arm.com> Cc: Deng-Cheng Zhu <dengcheng.zhu@gmail.com> Cc: David Daney <david.daney@cavium.com> Cc: Ralf Baechle <ralf@linux-mips.org> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/n/tip-xv8geaz2zpbjhlx0svmpp28n@git.kernel.org [ merged to newer kernel, fixed up MIPS impact ] Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--arch/arm/kernel/perf_event.c6
-rw-r--r--arch/mips/kernel/perf_event_mipsxx.c8
-rw-r--r--arch/x86/kernel/cpu/perf_event.c10
-rw-r--r--arch/x86/kernel/cpu/perf_event_p4.c2
4 files changed, 13 insertions, 13 deletions
diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c
index 24e2347be6b1..ff17b17b668e 100644
--- a/arch/arm/kernel/perf_event.c
+++ b/arch/arm/kernel/perf_event.c
@@ -347,15 +347,15 @@ validate_group(struct perf_event *event)
347 memset(&fake_pmu, 0, sizeof(fake_pmu)); 347 memset(&fake_pmu, 0, sizeof(fake_pmu));
348 348
349 if (!validate_event(&fake_pmu, leader)) 349 if (!validate_event(&fake_pmu, leader))
350 return -ENOSPC; 350 return -EINVAL;
351 351
352 list_for_each_entry(sibling, &leader->sibling_list, group_entry) { 352 list_for_each_entry(sibling, &leader->sibling_list, group_entry) {
353 if (!validate_event(&fake_pmu, sibling)) 353 if (!validate_event(&fake_pmu, sibling))
354 return -ENOSPC; 354 return -EINVAL;
355 } 355 }
356 356
357 if (!validate_event(&fake_pmu, event)) 357 if (!validate_event(&fake_pmu, event))
358 return -ENOSPC; 358 return -EINVAL;
359 359
360 return 0; 360 return 0;
361} 361}
diff --git a/arch/mips/kernel/perf_event_mipsxx.c b/arch/mips/kernel/perf_event_mipsxx.c
index 4f2971bcf8e5..315fc0b250f8 100644
--- a/arch/mips/kernel/perf_event_mipsxx.c
+++ b/arch/mips/kernel/perf_event_mipsxx.c
@@ -623,7 +623,7 @@ static int mipspmu_event_init(struct perf_event *event)
623 if (!atomic_inc_not_zero(&active_events)) { 623 if (!atomic_inc_not_zero(&active_events)) {
624 if (atomic_read(&active_events) > MIPS_MAX_HWEVENTS) { 624 if (atomic_read(&active_events) > MIPS_MAX_HWEVENTS) {
625 atomic_dec(&active_events); 625 atomic_dec(&active_events);
626 return -ENOSPC; 626 return -EINVAL;
627 } 627 }
628 628
629 mutex_lock(&pmu_reserve_mutex); 629 mutex_lock(&pmu_reserve_mutex);
@@ -732,15 +732,15 @@ static int validate_group(struct perf_event *event)
732 memset(&fake_cpuc, 0, sizeof(fake_cpuc)); 732 memset(&fake_cpuc, 0, sizeof(fake_cpuc));
733 733
734 if (!validate_event(&fake_cpuc, leader)) 734 if (!validate_event(&fake_cpuc, leader))
735 return -ENOSPC; 735 return -EINVAL;
736 736
737 list_for_each_entry(sibling, &leader->sibling_list, group_entry) { 737 list_for_each_entry(sibling, &leader->sibling_list, group_entry) {
738 if (!validate_event(&fake_cpuc, sibling)) 738 if (!validate_event(&fake_cpuc, sibling))
739 return -ENOSPC; 739 return -EINVAL;
740 } 740 }
741 741
742 if (!validate_event(&fake_cpuc, event)) 742 if (!validate_event(&fake_cpuc, event))
743 return -ENOSPC; 743 return -EINVAL;
744 744
745 return 0; 745 return 0;
746} 746}
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 640891014b2a..ff0e8d498750 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -588,7 +588,7 @@ done:
588 x86_pmu.put_event_constraints(cpuc, cpuc->event_list[i]); 588 x86_pmu.put_event_constraints(cpuc, cpuc->event_list[i]);
589 } 589 }
590 } 590 }
591 return num ? -ENOSPC : 0; 591 return num ? -EINVAL : 0;
592} 592}
593 593
594/* 594/*
@@ -607,7 +607,7 @@ static int collect_events(struct cpu_hw_events *cpuc, struct perf_event *leader,
607 607
608 if (is_x86_event(leader)) { 608 if (is_x86_event(leader)) {
609 if (n >= max_count) 609 if (n >= max_count)
610 return -ENOSPC; 610 return -EINVAL;
611 cpuc->event_list[n] = leader; 611 cpuc->event_list[n] = leader;
612 n++; 612 n++;
613 } 613 }
@@ -620,7 +620,7 @@ static int collect_events(struct cpu_hw_events *cpuc, struct perf_event *leader,
620 continue; 620 continue;
621 621
622 if (n >= max_count) 622 if (n >= max_count)
623 return -ENOSPC; 623 return -EINVAL;
624 624
625 cpuc->event_list[n] = event; 625 cpuc->event_list[n] = event;
626 n++; 626 n++;
@@ -1316,7 +1316,7 @@ static int validate_event(struct perf_event *event)
1316 c = x86_pmu.get_event_constraints(fake_cpuc, event); 1316 c = x86_pmu.get_event_constraints(fake_cpuc, event);
1317 1317
1318 if (!c || !c->weight) 1318 if (!c || !c->weight)
1319 ret = -ENOSPC; 1319 ret = -EINVAL;
1320 1320
1321 if (x86_pmu.put_event_constraints) 1321 if (x86_pmu.put_event_constraints)
1322 x86_pmu.put_event_constraints(fake_cpuc, event); 1322 x86_pmu.put_event_constraints(fake_cpuc, event);
@@ -1341,7 +1341,7 @@ static int validate_group(struct perf_event *event)
1341{ 1341{
1342 struct perf_event *leader = event->group_leader; 1342 struct perf_event *leader = event->group_leader;
1343 struct cpu_hw_events *fake_cpuc; 1343 struct cpu_hw_events *fake_cpuc;
1344 int ret = -ENOSPC, n; 1344 int ret = -EINVAL, n;
1345 1345
1346 fake_cpuc = allocate_fake_cpuc(); 1346 fake_cpuc = allocate_fake_cpuc();
1347 if (IS_ERR(fake_cpuc)) 1347 if (IS_ERR(fake_cpuc))
diff --git a/arch/x86/kernel/cpu/perf_event_p4.c b/arch/x86/kernel/cpu/perf_event_p4.c
index 492bf1358a7c..ef484d9d0a25 100644
--- a/arch/x86/kernel/cpu/perf_event_p4.c
+++ b/arch/x86/kernel/cpu/perf_event_p4.c
@@ -1268,7 +1268,7 @@ reserve:
1268 } 1268 }
1269 1269
1270done: 1270done:
1271 return num ? -ENOSPC : 0; 1271 return num ? -EINVAL : 0;
1272} 1272}
1273 1273
1274static __initconst const struct x86_pmu p4_pmu = { 1274static __initconst const struct x86_pmu p4_pmu = {