diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-12-21 07:50:42 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-12-23 06:45:19 -0500 |
commit | 95cdd2e7851cce79ab839cb0b3cbe68d7911d0f1 (patch) | |
tree | fad7723f344027dd64a1ca44d0117c3da61b75ca /arch/x86/kernel/cpu/perf_counter.c | |
parent | 78b6084c907cea15bb40a564b974e072f5163781 (diff) |
perfcounters: enable lowlevel pmc code to schedule counters
Allow lowlevel ->enable() op to return an error if a counter can not be
added. This can be used to handle counter constraints.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/cpu/perf_counter.c')
-rw-r--r-- | arch/x86/kernel/cpu/perf_counter.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/arch/x86/kernel/cpu/perf_counter.c b/arch/x86/kernel/cpu/perf_counter.c index b67557121425..74090a393a7c 100644 --- a/arch/x86/kernel/cpu/perf_counter.c +++ b/arch/x86/kernel/cpu/perf_counter.c | |||
@@ -244,7 +244,7 @@ static int fixed_mode_idx(struct hw_perf_counter *hwc) | |||
244 | /* | 244 | /* |
245 | * Find a PMC slot for the freshly enabled / scheduled in counter: | 245 | * Find a PMC slot for the freshly enabled / scheduled in counter: |
246 | */ | 246 | */ |
247 | static void pmc_generic_enable(struct perf_counter *counter) | 247 | static int pmc_generic_enable(struct perf_counter *counter) |
248 | { | 248 | { |
249 | struct cpu_hw_counters *cpuc = &__get_cpu_var(cpu_hw_counters); | 249 | struct cpu_hw_counters *cpuc = &__get_cpu_var(cpu_hw_counters); |
250 | struct hw_perf_counter *hwc = &counter->hw; | 250 | struct hw_perf_counter *hwc = &counter->hw; |
@@ -253,6 +253,8 @@ static void pmc_generic_enable(struct perf_counter *counter) | |||
253 | /* Try to get the previous counter again */ | 253 | /* Try to get the previous counter again */ |
254 | if (test_and_set_bit(idx, cpuc->used)) { | 254 | if (test_and_set_bit(idx, cpuc->used)) { |
255 | idx = find_first_zero_bit(cpuc->used, nr_counters_generic); | 255 | idx = find_first_zero_bit(cpuc->used, nr_counters_generic); |
256 | if (idx == nr_counters_generic) | ||
257 | return -EAGAIN; | ||
256 | set_bit(idx, cpuc->used); | 258 | set_bit(idx, cpuc->used); |
257 | hwc->idx = idx; | 259 | hwc->idx = idx; |
258 | } | 260 | } |
@@ -265,6 +267,8 @@ static void pmc_generic_enable(struct perf_counter *counter) | |||
265 | 267 | ||
266 | __hw_perf_counter_set_period(counter, hwc, idx); | 268 | __hw_perf_counter_set_period(counter, hwc, idx); |
267 | __pmc_generic_enable(counter, hwc, idx); | 269 | __pmc_generic_enable(counter, hwc, idx); |
270 | |||
271 | return 0; | ||
268 | } | 272 | } |
269 | 273 | ||
270 | void perf_counter_print_debug(void) | 274 | void perf_counter_print_debug(void) |