Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 205382
b: refs/heads/master
c: 96ca402
h: refs/heads/master
v: v3
  • Loading branch information
Don Zickus authored and Ingo Molnar committed Feb 17, 2010
1 parent c093687 commit 8adad5b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 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: 6081b6cd9702967889de34fe5da1f96bb96d0ab8
refs/heads/master: 96ca4028aca0638d0e11dcbfabc4283054072933
23 changes: 18 additions & 5 deletions trunk/kernel/nmi_watchdog.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,22 @@ static int __init setup_nmi_watchdog(char *str)
}
__setup("nmi_watchdog=", setup_nmi_watchdog);

struct perf_event_attr wd_attr = {
struct perf_event_attr wd_hw_attr = {
.type = PERF_TYPE_HARDWARE,
.config = PERF_COUNT_HW_CPU_CYCLES,
.size = sizeof(struct perf_event_attr),
.pinned = 1,
.disabled = 1,
};

struct perf_event_attr wd_sw_attr = {
.type = PERF_TYPE_SOFTWARE,
.config = PERF_COUNT_SW_CPU_CLOCK,
.size = sizeof(struct perf_event_attr),
.pinned = 1,
.disabled = 1,
};

void wd_overflow(struct perf_event *event, int nmi,
struct perf_sample_data *data,
struct pt_regs *regs)
Expand Down Expand Up @@ -105,18 +113,23 @@ void wd_overflow(struct perf_event *event, int nmi,
static int enable_nmi_watchdog(int cpu)
{
struct perf_event *event;
struct perf_event_attr *wd_attr;

event = per_cpu(nmi_watchdog_ev, cpu);
if (event && event->state > PERF_EVENT_STATE_OFF)
return 0;

if (event == NULL) {
/* Try to register using hardware perf events first */
wd_attr.sample_period = hw_nmi_get_sample_period();
event = perf_event_create_kernel_counter(&wd_attr, cpu, -1, wd_overflow);
wd_attr = &wd_hw_attr;
wd_attr->sample_period = hw_nmi_get_sample_period();
event = perf_event_create_kernel_counter(wd_attr, cpu, -1, wd_overflow);
if (IS_ERR(event)) {
wd_attr.type = PERF_TYPE_SOFTWARE;
event = perf_event_create_kernel_counter(&wd_attr, cpu, -1, wd_overflow);
/* hardware doesn't exist or not supported, fallback to software events */
printk("nmi_watchdog: hardware not available, trying software events\n");
wd_attr = &wd_sw_attr;
wd_attr->sample_period = NSEC_PER_SEC;
event = perf_event_create_kernel_counter(wd_attr, cpu, -1, wd_overflow);
if (IS_ERR(event)) {
printk(KERN_ERR "nmi watchdog failed to create perf event on %i: %p\n", cpu, event);
return -1;
Expand Down

0 comments on commit 8adad5b

Please sign in to comment.