Skip to content

Commit

Permalink
perf: Don't use -ENOSPC for out of PMU resources
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Nov 14, 2011
1 parent 1d5f003 commit aa2bc1a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions arch/arm/kernel/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions arch/mips/kernel/perf_event_mipsxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
10 changes: 5 additions & 5 deletions arch/x86/kernel/cpu/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ int x86_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign)
x86_pmu.put_event_constraints(cpuc, cpuc->event_list[i]);
}
}
return num ? -ENOSPC : 0;
return num ? -EINVAL : 0;
}

/*
Expand All @@ -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++;
}
Expand All @@ -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++;
Expand Down Expand Up @@ -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);
Expand All @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/kernel/cpu/perf_event_p4.c
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,7 @@ static int p4_pmu_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign
}

done:
return num ? -ENOSPC : 0;
return num ? -EINVAL : 0;
}

static __initconst const struct x86_pmu p4_pmu = {
Expand Down

0 comments on commit aa2bc1a

Please sign in to comment.