tracing: Fix hwlat kthread migration

The hwlat tracer creates a kernel thread at start of the tracer. It is
pinned to a single CPU and will move to the next CPU after each period of
running. If the user modifies the migration thread's affinity, it will not
change after that happens.

The original code created the thread at the first instance it was called,
but later was changed to destroy the thread after the tracer was finished,
and would not be created until the next instance of the tracer was
established. The code that initialized the affinity was only called on the
initial instantiation of the tracer. After that, it was not initialized, and
the previous affinity did not match the current newly created one, making
it appear that the user modified the thread's affinity when it did not, and
the thread failed to migrate again.

Cc: stable@vger.kernel.org
Fixes: 0330f7aa ("tracing: Have hwlat trace migrate across tracing_cpumask CPUs")
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent 0c744ea4
...@@ -266,7 +266,7 @@ static int get_sample(void) ...@@ -266,7 +266,7 @@ static int get_sample(void)
static struct cpumask save_cpumask; static struct cpumask save_cpumask;
static bool disable_migrate; static bool disable_migrate;
static void move_to_next_cpu(void) static void move_to_next_cpu(bool initmask)
{ {
static struct cpumask *current_mask; static struct cpumask *current_mask;
int next_cpu; int next_cpu;
...@@ -275,7 +275,7 @@ static void move_to_next_cpu(void) ...@@ -275,7 +275,7 @@ static void move_to_next_cpu(void)
return; return;
/* Just pick the first CPU on first iteration */ /* Just pick the first CPU on first iteration */
if (!current_mask) { if (initmask) {
current_mask = &save_cpumask; current_mask = &save_cpumask;
get_online_cpus(); get_online_cpus();
cpumask_and(current_mask, cpu_online_mask, tracing_buffer_mask); cpumask_and(current_mask, cpu_online_mask, tracing_buffer_mask);
...@@ -330,10 +330,12 @@ static void move_to_next_cpu(void) ...@@ -330,10 +330,12 @@ static void move_to_next_cpu(void)
static int kthread_fn(void *data) static int kthread_fn(void *data)
{ {
u64 interval; u64 interval;
bool initmask = true;
while (!kthread_should_stop()) { while (!kthread_should_stop()) {
move_to_next_cpu(); move_to_next_cpu(initmask);
initmask = false;
local_irq_disable(); local_irq_disable();
get_sample(); get_sample();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment