Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Peter Zijlstra and committed by
Ingo Molnar
aa2bc1ad 1d5f003f

+13 -13
+3 -3
arch/arm/kernel/perf_event.c
··· 347 347 memset(&fake_pmu, 0, sizeof(fake_pmu)); 348 348 349 349 if (!validate_event(&fake_pmu, leader)) 350 - return -ENOSPC; 350 + return -EINVAL; 351 351 352 352 list_for_each_entry(sibling, &leader->sibling_list, group_entry) { 353 353 if (!validate_event(&fake_pmu, sibling)) 354 - return -ENOSPC; 354 + return -EINVAL; 355 355 } 356 356 357 357 if (!validate_event(&fake_pmu, event)) 358 - return -ENOSPC; 358 + return -EINVAL; 359 359 360 360 return 0; 361 361 }
+4 -4
arch/mips/kernel/perf_event_mipsxx.c
··· 623 623 if (!atomic_inc_not_zero(&active_events)) { 624 624 if (atomic_read(&active_events) > MIPS_MAX_HWEVENTS) { 625 625 atomic_dec(&active_events); 626 - return -ENOSPC; 626 + return -EINVAL; 627 627 } 628 628 629 629 mutex_lock(&pmu_reserve_mutex); ··· 732 732 memset(&fake_cpuc, 0, sizeof(fake_cpuc)); 733 733 734 734 if (!validate_event(&fake_cpuc, leader)) 735 - return -ENOSPC; 735 + return -EINVAL; 736 736 737 737 list_for_each_entry(sibling, &leader->sibling_list, group_entry) { 738 738 if (!validate_event(&fake_cpuc, sibling)) 739 - return -ENOSPC; 739 + return -EINVAL; 740 740 } 741 741 742 742 if (!validate_event(&fake_cpuc, event)) 743 - return -ENOSPC; 743 + return -EINVAL; 744 744 745 745 return 0; 746 746 }
+5 -5
arch/x86/kernel/cpu/perf_event.c
··· 588 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 607 608 608 if (is_x86_event(leader)) { 609 609 if (n >= max_count) 610 - return -ENOSPC; 610 + return -EINVAL; 611 611 cpuc->event_list[n] = leader; 612 612 n++; 613 613 } ··· 620 620 continue; 621 621 622 622 if (n >= max_count) 623 - return -ENOSPC; 623 + return -EINVAL; 624 624 625 625 cpuc->event_list[n] = event; 626 626 n++; ··· 1316 1316 c = x86_pmu.get_event_constraints(fake_cpuc, event); 1317 1317 1318 1318 if (!c || !c->weight) 1319 - ret = -ENOSPC; 1319 + ret = -EINVAL; 1320 1320 1321 1321 if (x86_pmu.put_event_constraints) 1322 1322 x86_pmu.put_event_constraints(fake_cpuc, event); ··· 1341 1341 { 1342 1342 struct perf_event *leader = event->group_leader; 1343 1343 struct cpu_hw_events *fake_cpuc; 1344 - int ret = -ENOSPC, n; 1344 + int ret = -EINVAL, n; 1345 1345 1346 1346 fake_cpuc = allocate_fake_cpuc(); 1347 1347 if (IS_ERR(fake_cpuc))
+1 -1
arch/x86/kernel/cpu/perf_event_p4.c
··· 1268 1268 } 1269 1269 1270 1270 done: 1271 - return num ? -ENOSPC : 0; 1271 + return num ? -EINVAL : 0; 1272 1272 } 1273 1273 1274 1274 static __initconst const struct x86_pmu p4_pmu = {