[PATCH] trace: Do some cleanups for osnoise tracer

From: Tang Yizhou
Date: Sun Sep 12 2021 - 23:13:38 EST


1. Add 'static' and 'const' qualifier when necessary.
2. Use DEFINE_MUTEX() to define a mutex.

Signed-off-by: Tang Yizhou <tangyizhou@xxxxxxxxxx>
---
kernel/trace/trace_osnoise.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
index ce053619f289..c1a8dc6a154e 100644
--- a/kernel/trace/trace_osnoise.c
+++ b/kernel/trace/trace_osnoise.c
@@ -105,7 +105,7 @@ struct osnoise_variables {
/*
* Per-cpu runtime information.
*/
-DEFINE_PER_CPU(struct osnoise_variables, per_cpu_osnoise_var);
+static DEFINE_PER_CPU(struct osnoise_variables, per_cpu_osnoise_var);

/*
* this_cpu_osn_var - Return the per-cpu osnoise_variables on its relative CPU
@@ -128,7 +128,7 @@ struct timerlat_variables {
u64 count;
};

-DEFINE_PER_CPU(struct timerlat_variables, per_cpu_timerlat_var);
+static DEFINE_PER_CPU(struct timerlat_variables, per_cpu_timerlat_var);

/*
* this_cpu_tmr_var - Return the per-cpu timerlat_variables on its relative CPU
@@ -220,7 +220,7 @@ struct timerlat_sample {
/*
* Protect the interface.
*/
-struct mutex interface_lock;
+static DEFINE_MUTEX(interface_lock);

/*
* Tracer data.
@@ -1818,8 +1818,8 @@ static struct trace_min_max_param osnoise_print_stack = {
/*
* osnoise/timerlat_period: min 100 us, max 1 s
*/
-u64 timerlat_min_period = 100;
-u64 timerlat_max_period = 1000000;
+static const u64 timerlat_min_period = 100;
+static const u64 timerlat_max_period = 1000000;
static struct trace_min_max_param timerlat_period = {
.lock = &interface_lock,
.val = &osnoise_data.timerlat_period,
@@ -2087,8 +2087,6 @@ __init static int init_osnoise_tracer(void)
{
int ret;

- mutex_init(&interface_lock);
-
cpumask_copy(&osnoise_cpumask, cpu_all_mask);

ret = register_tracer(&osnoise_tracer);
--
2.17.1