mask, or MAX_THREADS_MASK. How to create a task able to run anywhere
(checks, Lua, ...) ?
-Profiling
+Profiling -> completed
---------
There should be one task_profiling_mask per thread group. Enabling or
disabling profiling should be made per group (possibly by iterating).
+-> not needed anymore, one flag per thread in each thread's context.
Thread isolation
----------------
- lock debugging must reproduce tgid
- - task profiling must be made per-group (annoying), unless we want to add a
+ * task profiling must be made per-group (annoying), unless we want to add a
per-thread TH_FL_* flag and have the rare places where the bit is changed
iterate over all threads if needed. Sounds preferable overall.
#include <haproxy/api.h>
extern unsigned int profiling;
-extern unsigned long task_profiling_mask;
extern struct activity activity[MAX_THREADS];
extern struct sched_activity sched_activity[256];
tl->debug.caller_idx = !tl->debug.caller_idx;
tl->debug.caller_file[tl->debug.caller_idx] = file;
tl->debug.caller_line[tl->debug.caller_idx] = line;
- if (task_profiling_mask & tid_bit)
+ if (th_ctx->flags & TH_FL_TASK_PROFILING)
tl->call_date = now_mono_time();
#endif
__tasklet_wakeup_on(tl, thr);
tl->debug.caller_idx = !tl->debug.caller_idx;
tl->debug.caller_file[tl->debug.caller_idx] = file;
tl->debug.caller_line[tl->debug.caller_idx] = line;
- if (task_profiling_mask & tid_bit)
+ if (th_ctx->flags & TH_FL_TASK_PROFILING)
tl->call_date = now_mono_time();
#endif
__tasklet_wakeup_on(tl, thr);
/* thread_ctx flags, for ha_thread_ctx[].flags */
#define TH_FL_STUCK 0x00000001
+#define TH_FL_TASK_PROFILING 0x00000002
/* Thread group information. This defines a base and a count of global thread
* IDs which belong to it, and which can be looked up into thread_info/ctx. It
/* bit field of profiling options. Beware, may be modified at runtime! */
unsigned int profiling __read_mostly = HA_PROF_TASKS_AOFF;
-unsigned long task_profiling_mask __read_mostly = 0;
/* One struct per thread containing all collected measurements */
struct activity activity[MAX_THREADS] __attribute__((aligned(64))) = { };
* profiling to "on" when automatic, and going back below the "down"
* threshold switches to off. The forced modes don't check the load.
*/
- if (!(task_profiling_mask & tid_bit)) {
+ if (!(th_ctx->flags & TH_FL_TASK_PROFILING)) {
if (unlikely((profiling & HA_PROF_TASKS_MASK) == HA_PROF_TASKS_ON ||
((profiling & HA_PROF_TASKS_MASK) == HA_PROF_TASKS_AON &&
swrate_avg(run_time, TIME_STATS_SAMPLES) >= up)))
- _HA_ATOMIC_OR(&task_profiling_mask, tid_bit);
+ _HA_ATOMIC_OR(&th_ctx->flags, TH_FL_TASK_PROFILING);
} else {
if (unlikely((profiling & HA_PROF_TASKS_MASK) == HA_PROF_TASKS_OFF ||
((profiling & HA_PROF_TASKS_MASK) == HA_PROF_TASKS_AOFF &&
swrate_avg(run_time, TIME_STATS_SAMPLES) <= down)))
- _HA_ATOMIC_AND(&task_profiling_mask, ~tid_bit);
+ _HA_ATOMIC_AND(&th_ctx->flags, ~TH_FL_TASK_PROFILING);
}
}
ha_thread_ctx[thr].rq_total,
ha_thread_info[thr].tg->tgid, ha_thread_info[thr].ltid + 1,
stuck,
- !!(task_profiling_mask & thr_bit));
+ !!(th_ctx->flags & TH_FL_TASK_PROFILING));
chunk_appendf(buf,
" harmless=%d wantrdv=%d",
!!(threads_harmless_mask & thr_bit),
- !!(threads_want_rdv_mask & thr_bit));
+ !!(th_ctx->flags & TH_FL_TASK_PROFILING));
chunk_appendf(buf, "\n");
chunk_appendf(buf, " cpu_ns: poll=%llu now=%llu diff=%llu\n", p, n, n-p);
t->rq.key += offset;
}
- if (task_profiling_mask & tid_bit)
+ if (th_ctx->flags & TH_FL_TASK_PROFILING)
t->call_date = now_mono_time();
eb32sc_insert(root, &t->rq, t->thread_mask);
LIST_DEL_INIT(&((struct tasklet *)t)->list);
__ha_barrier_store();
- if (unlikely(task_profiling_mask & tid_bit)) {
+ if (unlikely(th_ctx->flags & TH_FL_TASK_PROFILING)) {
profile_entry = sched_activity_entry(sched_activity, t->process);
before = now_mono_time();
#ifdef DEBUG_TASK
continue;
}
- if (unlikely(task_profiling_mask & tid_bit)) {
+ if (unlikely(th_ctx->flags & TH_FL_TASK_PROFILING)) {
HA_ATOMIC_INC(&profile_entry->calls);
HA_ATOMIC_ADD(&profile_entry->cpu_time, now_mono_time() - before);
}