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 (th_ctx->flags & TH_FL_TASK_PROFILING)
+ if (_HA_ATOMIC_LOAD(&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 (th_ctx->flags & TH_FL_TASK_PROFILING)
+ if (_HA_ATOMIC_LOAD(&th_ctx->flags) & TH_FL_TASK_PROFILING)
tl->call_date = now_mono_time();
#endif
__tasklet_wakeup_on(tl, thr);
* profiling to "on" when automatic, and going back below the "down"
* threshold switches to off. The forced modes don't check the load.
*/
- if (!(th_ctx->flags & TH_FL_TASK_PROFILING)) {
+ if (!(_HA_ATOMIC_LOAD(&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)))
* The calling thread ID needs to be passed in <calling_tid> to display a star
* in front of the calling thread's line (usually it's tid). Any stuck thread
* is also prefixed with a '>'.
+ * It must be called under thread isolation.
*/
void ha_thread_dump(struct buffer *buf, int thr, int calling_tid)
{
* if it didn't move.
*/
if (!((threads_harmless_mask|sleeping_thread_mask) & tid_bit))
- th_ctx->flags |= TH_FL_STUCK;
+ _HA_ATOMIC_OR(&th_ctx->flags, TH_FL_STUCK);
}
static int init_debug_per_thread()
uint new_flags, must_stop;
ulong rmask, tmask;
- th_ctx->flags &= ~TH_FL_STUCK; // this thread is still running
+ _HA_ATOMIC_AND(&th_ctx->flags, ~TH_FL_STUCK); // this thread is still running
/* do nothing if the FD was taken over under us */
do {
}
#endif
- th_ctx->flags &= ~TH_FL_STUCK; // this thread is still running
+ _HA_ATOMIC_AND(&th_ctx->flags, ~TH_FL_STUCK); // this thread is still running
} /* end of for (max_accept--) */
end:
t->rq.key += offset;
}
- if (th_ctx->flags & TH_FL_TASK_PROFILING)
+ if (_HA_ATOMIC_LOAD(&th_ctx->flags) & TH_FL_TASK_PROFILING)
t->call_date = now_mono_time();
eb32_insert(root, &t->rq);
process = t->process;
t->calls++;
th_ctx->current = t;
- th_ctx->flags &= ~TH_FL_STUCK; // this thread is still running
+ _HA_ATOMIC_AND(&th_ctx->flags, ~TH_FL_STUCK); // this thread is still running
_HA_ATOMIC_DEC(&th_ctx->rq_total);
LIST_DEL_INIT(&((struct tasklet *)t)->list);
__ha_barrier_store();
- if (unlikely(th_ctx->flags & TH_FL_TASK_PROFILING)) {
+ if (unlikely(_HA_ATOMIC_LOAD(&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(th_ctx->flags & TH_FL_TASK_PROFILING)) {
+ if (unlikely(_HA_ATOMIC_LOAD(&th_ctx->flags) & TH_FL_TASK_PROFILING)) {
HA_ATOMIC_INC(&profile_entry->calls);
HA_ATOMIC_ADD(&profile_entry->cpu_time, now_mono_time() - before);
}
int heavy_queued = 0;
int budget;
- th_ctx->flags &= ~TH_FL_STUCK; // this thread is still running
+ _HA_ATOMIC_AND(&th_ctx->flags, ~TH_FL_STUCK); // this thread is still running
if (!thread_has_tasks()) {
activity[tid].empty_rq++;
* If it's already set, then it's our second call with no
* progress and the thread is dead.
*/
- if (!(ha_thread_ctx[thr].flags & TH_FL_STUCK)) {
+ if (!(_HA_ATOMIC_LOAD(&ha_thread_ctx[thr].flags) & TH_FL_STUCK)) {
_HA_ATOMIC_OR(&ha_thread_ctx[thr].flags, TH_FL_STUCK);
goto update_and_leave;
}