Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 234428
b: refs/heads/master
c: 163ec43
h: refs/heads/master
v: v3
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Feb 16, 2011
1 parent e8a0807 commit bbe6aa2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 21 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4979d2729af22f6ce8faa325fc60a85a2c2daa02
refs/heads/master: 163ec4354a5135c6c38c3f4a9b46a31900ebdf48
4 changes: 4 additions & 0 deletions trunk/include/linux/perf_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,10 @@ extern int sysctl_perf_event_paranoid;
extern int sysctl_perf_event_mlock;
extern int sysctl_perf_event_sample_rate;

extern int perf_proc_update_handler(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp,
loff_t *ppos);

static inline bool perf_paranoid_tracepoint_raw(void)
{
return sysctl_perf_event_paranoid > -1;
Expand Down
43 changes: 24 additions & 19 deletions trunk/kernel/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,24 @@ int sysctl_perf_event_mlock __read_mostly = 512; /* 'free' kb per user */
/*
* max perf event sample rate
*/
int sysctl_perf_event_sample_rate __read_mostly = 100000;
#define DEFAULT_MAX_SAMPLE_RATE 100000
int sysctl_perf_event_sample_rate __read_mostly = DEFAULT_MAX_SAMPLE_RATE;
static int max_samples_per_tick __read_mostly =
DIV_ROUND_UP(DEFAULT_MAX_SAMPLE_RATE, HZ);

int perf_proc_update_handler(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp,
loff_t *ppos)
{
int ret = proc_dointvec(table, write, buffer, lenp, ppos);

if (ret || !write)
return ret;

max_samples_per_tick = DIV_ROUND_UP(sysctl_perf_event_sample_rate, HZ);

return 0;
}

static atomic64_t perf_event_id;

Expand Down Expand Up @@ -4941,26 +4958,14 @@ static int __perf_event_overflow(struct perf_event *event, int nmi,
if (unlikely(!is_sampling_event(event)))
return 0;

if (!throttle) {
hwc->interrupts++;
} else {
if (hwc->interrupts != MAX_INTERRUPTS) {
hwc->interrupts++;
if (HZ * hwc->interrupts >
(u64)sysctl_perf_event_sample_rate) {
hwc->interrupts = MAX_INTERRUPTS;
perf_log_throttle(event, 0);
ret = 1;
}
} else {
/*
* Keep re-disabling events even though on the previous
* pass we disabled it - just in case we raced with a
* sched-in and the event got enabled again:
*/
if (unlikely(hwc->interrupts >= max_samples_per_tick)) {
if (throttle) {
hwc->interrupts = MAX_INTERRUPTS;
perf_log_throttle(event, 0);
ret = 1;
}
}
} else
hwc->interrupts++;

if (event->attr.freq) {
u64 now = perf_clock();
Expand Down
2 changes: 1 addition & 1 deletion trunk/kernel/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ static struct ctl_table kern_table[] = {
.data = &sysctl_perf_event_sample_rate,
.maxlen = sizeof(sysctl_perf_event_sample_rate),
.mode = 0644,
.proc_handler = proc_dointvec,
.proc_handler = perf_proc_update_handler,
},
#endif
#ifdef CONFIG_KMEMCHECK
Expand Down

0 comments on commit bbe6aa2

Please sign in to comment.