MINOR: activity: make the profiling status per thread and not global
In order to later support automatic profiling turn on/off, we need to
have it per-thread. We're keeping the global option to know whether to
turn it or on off, but the profiling status is now set per thread. We're
updating the status in activity_count_runtime() which is called before
entering poll(). The reason is that we'll extend this with run time
measurement when deciding to automatically turn it on or off.
diff --git a/include/proto/activity.h b/include/proto/activity.h
index 098206e..922f493 100644
--- a/include/proto/activity.h
+++ b/include/proto/activity.h
@@ -32,6 +32,7 @@
#define HA_PROF_TASKS 0x00000001 /* enable per-task CPU profiling */
extern unsigned int profiling;
+extern unsigned long task_profiling_mask;
extern struct activity activity[MAX_THREADS];
@@ -67,6 +68,14 @@
run_time = (before_poll.tv_sec - after_poll.tv_sec) * 1000000U + (before_poll.tv_usec - after_poll.tv_usec);
swrate_add(&activity[tid].avg_loop_us, TIME_STATS_SAMPLES, run_time);
+
+ if (!(task_profiling_mask & tid_bit)) {
+ if (unlikely(profiling & HA_PROF_TASKS))
+ _HA_ATOMIC_OR(&task_profiling_mask, tid_bit);
+ } else {
+ if (unlikely(!(profiling & HA_PROF_TASKS)))
+ _HA_ATOMIC_AND(&task_profiling_mask, ~tid_bit);
+ }
}