mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-12-24 19:11:00 +01:00
MINOR: wdt: use is_sched_alive() instead of keeping a local ctxsw copy
Now we can simply call is_sched_alive() on the local thread to verify that the scheduler is still ticking instead of having to keep a copy of the ctxsw and comparing it. It's cleaner, doesn't require to maintain a local copy, doesn't rely on activity[] (whose purpose is mainly for observation and debugging), and shows how this could be extended later to cover other use cases. Practically speaking this doesn't change anything however, the algorithm is still the same.
This commit is contained in:
parent
36ec70c526
commit
5901164789
11
src/wdt.c
11
src/wdt.c
@ -20,6 +20,7 @@
|
||||
#include <haproxy/errors.h>
|
||||
#include <haproxy/global.h>
|
||||
#include <haproxy/signal-t.h>
|
||||
#include <haproxy/task.h>
|
||||
#include <haproxy/thread.h>
|
||||
#include <haproxy/tools.h>
|
||||
|
||||
@ -40,7 +41,6 @@
|
||||
*/
|
||||
static struct {
|
||||
timer_t timer;
|
||||
uint prev_ctxsw;
|
||||
} per_thread_wd_ctx[MAX_THREADS];
|
||||
|
||||
/* warn about stuck tasks after this delay (ns) */
|
||||
@ -65,7 +65,6 @@ int wdt_ping(int thr)
|
||||
void wdt_handler(int sig, siginfo_t *si, void *arg)
|
||||
{
|
||||
unsigned long long n, p;
|
||||
uint prev_ctxsw, curr_ctxsw;
|
||||
ulong thr_bit;
|
||||
int thr, tgrp;
|
||||
|
||||
@ -185,13 +184,9 @@ void wdt_handler(int sig, siginfo_t *si, void *arg)
|
||||
if (_HA_ATOMIC_LOAD(&th_ctx->flags) & TH_FL_STUCK)
|
||||
ha_panic();
|
||||
|
||||
prev_ctxsw = per_thread_wd_ctx[tid].prev_ctxsw;
|
||||
curr_ctxsw = activity[tid].ctxsw;
|
||||
|
||||
if (curr_ctxsw == prev_ctxsw)
|
||||
if (!is_sched_alive())
|
||||
ha_stuck_warning();
|
||||
else
|
||||
per_thread_wd_ctx[tid].prev_ctxsw = curr_ctxsw;
|
||||
|
||||
/* let's go on */
|
||||
|
||||
update_and_leave:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user