Skip to content

Commit

Permalink
trace/hwlat: Switch disable_migrate to mode none
Browse files Browse the repository at this point in the history
When in the round-robin mode, if the tracer detects a change in the
hwlatd thread affinity by an external tool, e.g., taskset, the
round-robin logic is disabled. The disable_migrate variable currently
tracks this.

With the addition of the "mode" config and the mode "none," the
disable_migrate logic is equivalent to switch to the "none" mode.

Hence, instead of using a hidden variable to track this behavior,
switch the mode to none, informing the user about this change.

Link: https://lkml.kernel.org/r/a679af672458d6b1f62252605905c5214030f247.1624372313.git.bristot@redhat.com

Cc: Phil Auld <pauld@redhat.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Kate Carcia <kcarcia@redhat.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Alexandre Chartre <alexandre.chartre@oracle.com>
Cc: Clark Willaims <williams@redhat.com>
Cc: John Kacur <jkacur@redhat.com>
Cc: Juri Lelli <juri.lelli@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Daniel Bristot de Oliveira <bristot@redhat.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
  • Loading branch information
Daniel Bristot de Oliveira authored and rostedt committed Jun 24, 2021
1 parent 8fa826b commit 7bb7d80
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions kernel/trace/trace_hwlat.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,23 +286,20 @@ static int get_sample(void)
}

static struct cpumask save_cpumask;
static bool disable_migrate;

static void move_to_next_cpu(void)
{
struct cpumask *current_mask = &save_cpumask;
struct trace_array *tr = hwlat_trace;
int next_cpu;

if (disable_migrate)
return;
/*
* If for some reason the user modifies the CPU affinity
* of this thread, then stop migrating for the duration
* of the current test.
*/
if (!cpumask_equal(current_mask, current->cpus_ptr))
goto disable;
goto change_mode;

get_online_cpus();
cpumask_and(current_mask, cpu_online_mask, tr->tracing_cpumask);
Expand All @@ -313,16 +310,17 @@ static void move_to_next_cpu(void)
next_cpu = cpumask_first(current_mask);

if (next_cpu >= nr_cpu_ids) /* Shouldn't happen! */
goto disable;
goto change_mode;

cpumask_clear(current_mask);
cpumask_set_cpu(next_cpu, current_mask);

sched_setaffinity(0, current_mask);
return;

disable:
disable_migrate = true;
change_mode:
hwlat_data.thread_mode = MODE_NONE;
pr_info(BANNER "cpumask changed while in round-robin mode, switching to mode none\n");
}

/*
Expand Down Expand Up @@ -744,7 +742,6 @@ static int hwlat_tracer_init(struct trace_array *tr)

hwlat_trace = tr;

disable_migrate = false;
hwlat_data.count = 0;
tr->max_latency = 0;
save_tracing_thresh = tracing_thresh;
Expand Down

0 comments on commit 7bb7d80

Please sign in to comment.