Watchdog
include/watchdog.h View source View on GitHubStructs
Section titled “Structs”watchdog_bucket
Section titled “watchdog_bucket”struct watchdog_bucket {
size_t epoch;
size_t heartbeats;
}; watchdog_buckets
Section titled “watchdog_buckets”struct watchdog_buckets {
struct seqcount seq;
struct watchdog_bucket buckets_internal[WATCHDOG_NUM_BUCKETS];
size_t idx;
size_t curr_epoch;
time_ms_t last_heartbeat_ms;
}; watchdog_bucket_snapshot
Section titled “watchdog_bucket_snapshot”struct watchdog_bucket_snapshot {
size_t idx;
size_t curr_epoch;
time_ms_t last_heartbeat_ms;
struct watchdog_bucket buckets[WATCHDOG_NUM_BUCKETS];
}; watchdog_percpu_response
Section titled “watchdog_percpu_response”struct watchdog_percpu_response {
time_ms_t finished_ms;
struct seqcount seqcount;
}; watchdog_callback
Section titled “watchdog_callback”struct watchdog_callback {
struct list_head list;
void (*fn)(struct watchdog_callback *);
void *private;
}; watchdog_percpu
Section titled “watchdog_percpu”struct watchdog_percpu {
cpu_id_t id;
bool pets_enabled;
struct seqcount pets_seq;
_Atomic size_t pets;
_Atomic size_t anti_pets;
_Atomic uint64_t heartbeat_seq;
struct watchdog_percpu_response response;
struct watchdog_buckets buckets;
struct timer timer;
struct locked_list callback_list;
}; watchdog_master_cpu
Section titled “watchdog_master_cpu”struct watchdog_master_cpu {
cpu_id_t id;
struct watchdog_percpu *pcpu;
enum watchdog_master_state state;
struct ewma lockup_ewma;
fx32_32_t lockup_score;
time_ms_t critical_tests[WATCHDOG_CRITICAL_IPI_TESTS];
time_ms_t critical_test_start;
size_t critical_tests_done;
size_t critical_start_tick;
size_t suspect_start_tick;
uint64_t last_seen_heartbeat;
size_t last_progress_tick;
}; watchdog_master
Section titled “watchdog_master”struct watchdog_master {
size_t tick;
struct cpu_mask cpu_masks[WATCHDOG_STATE_MAX];
struct cpu_mask scratch_mask;
struct watchdog_master_cpu *cpus;
char msg_buf[WATCHDOG_MSG_LEN_MAX];
}; watchdog_config
Section titled “watchdog_config”struct watchdog_config {
time_ns_t master_tick_interval;
time_ns_t worker_heartbeat_interval;
time_ns_t bucket_interval;
fx32_32_t master_panic_score;
fx32_32_t master_critical_score;
time_ns_t master_stall_timeout;
time_ns_t master_print_interval;
fx32_32_t master_suspect_score;
}; watchdog_globals
Section titled “watchdog_globals”struct watchdog_globals {
time_ms_t bucket_interval_ms;
size_t expected_heartbeats_per_bucket;
size_t stall_timeout_ticks;
irq_t critical_test_irq;
}; watchdog_master_state
Section titled “watchdog_master_state”enum watchdog_master_state {
WATCHDOG_STATE_NORMAL,
WATCHDOG_STATE_SUSPECT,
WATCHDOG_STATE_CRITICAL,
WATCHDOG_STATE_PANIC,
WATCHDOG_STATE_MAX,
}; Functions
Section titled “Functions”watchdog_init
Section titled “watchdog_init”void watchdog_init(void); watchdog_start
Section titled “watchdog_start”void watchdog_start(void); watchdog_anti_pet
Section titled “watchdog_anti_pet”void watchdog_anti_pet(void); watchdog_pet
Section titled “watchdog_pet”void watchdog_pet(void); watchdog_callback_add
Section titled “watchdog_callback_add”void watchdog_callback_add(cpu_id_t cpu, struct watchdog_callback *cb); watchdog_callback_remove
Section titled “watchdog_callback_remove”void watchdog_callback_remove(cpu_id_t cpu, struct watchdog_callback *cb); Macros
Section titled “Macros”WATCHDOG_WINDOW_BUCKETS
Section titled “WATCHDOG_WINDOW_BUCKETS”#define WATCHDOG_WINDOW_BUCKETS 8 WATCHDOG_MASTER_SEQCOUNT_SPINS
Section titled “WATCHDOG_MASTER_SEQCOUNT_SPINS”#define WATCHDOG_MASTER_SEQCOUNT_SPINS 3 WATCHDOG_NUM_BUCKETS
Section titled “WATCHDOG_NUM_BUCKETS”#define WATCHDOG_NUM_BUCKETS 64 WATCHDOG_MSG_LEN_MAX
Section titled “WATCHDOG_MSG_LEN_MAX”#define WATCHDOG_MSG_LEN_MAX 512 WATCHDOG_EWMA_ALPHA
Section titled “WATCHDOG_EWMA_ALPHA”#define WATCHDOG_EWMA_ALPHA FX(0.15) WATCHDOG_SUSPECT_LOG_TICK_THRESHOLD
Section titled “WATCHDOG_SUSPECT_LOG_TICK_THRESHOLD”#define WATCHDOG_SUSPECT_LOG_TICK_THRESHOLD (40) WATCHDOG_CRITICAL_LOG_TICK_THRESHOLD
Section titled “WATCHDOG_CRITICAL_LOG_TICK_THRESHOLD”#define WATCHDOG_CRITICAL_LOG_TICK_THRESHOLD (20) WATCHDOG_CRITICAL_IPI_TESTS
Section titled “WATCHDOG_CRITICAL_IPI_TESTS”#define WATCHDOG_CRITICAL_IPI_TESTS \
40 /* Test an IPI ping pong \
* times to get the avg, this is 4s */ WATCHDOG_CRITICAL_PASS_THRESHOLD_MS
Section titled “WATCHDOG_CRITICAL_PASS_THRESHOLD_MS”#define WATCHDOG_CRITICAL_PASS_THRESHOLD_MS 250 WATCHDOG_CRITICAL_PANIC_THRESHOLD_MS
Section titled “WATCHDOG_CRITICAL_PANIC_THRESHOLD_MS”#define WATCHDOG_CRITICAL_PANIC_THRESHOLD_MS \
10000 /* If we delay this long, panic */ WATCHDOG_CRITICAL_TESTS_FACTOR
Section titled “WATCHDOG_CRITICAL_TESTS_FACTOR”#define WATCHDOG_CRITICAL_TESTS_FACTOR FX(0.4) WATCHDOG_CRITICAL_PETS_FACTOR
Section titled “WATCHDOG_CRITICAL_PETS_FACTOR”#define WATCHDOG_CRITICAL_PETS_FACTOR FX(0.6) WATCHDOG_STALL_TIMEOUT_DEFAULT_MS
Section titled “WATCHDOG_STALL_TIMEOUT_DEFAULT_MS”#define WATCHDOG_STALL_TIMEOUT_DEFAULT_MS 15000 WATCHDOG_STALL_GRACE_TICKS
Section titled “WATCHDOG_STALL_GRACE_TICKS”#define WATCHDOG_STALL_GRACE_TICKS 20 watchdog_cpu_for_each
Section titled “watchdog_cpu_for_each”#define watchdog_cpu_for_each(__i, state) \
cpu_mask_for_each(__i, watchdog_master.cpu_masks[state])