summaryrefslogtreecommitdiff
path: root/samples
diff options
context:
space:
mode:
authorAlex Shi <alex.shi@linaro.org>2017-11-09 12:01:32 +0800
committerAlex Shi <alex.shi@linaro.org>2017-11-09 12:01:32 +0800
commit7effd4c8ef8779ef8dcb90b5dc3dd38c12210c11 (patch)
treec681a7f96d19a8163118f842f8dcd0a3c4520cb3 /samples
parent2f68ef7576fc0a106d5cd77f31175fd498c9f995 (diff)
parentc54d0707aa09a824413ebb4195c98bfb9b9e1fc0 (diff)
Merge tag 'v4.4.97' into linux-linaro-lsk-v4.4
This is the 4.4.97 stable release
Diffstat (limited to 'samples')
-rw-r--r--samples/trace_events/trace-events-sample.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/samples/trace_events/trace-events-sample.c b/samples/trace_events/trace-events-sample.c
index 880a7d1d27d2..4ccff66523c9 100644
--- a/samples/trace_events/trace-events-sample.c
+++ b/samples/trace_events/trace-events-sample.c
@@ -78,28 +78,36 @@ static int simple_thread_fn(void *arg)
}
static DEFINE_MUTEX(thread_mutex);
+static int simple_thread_cnt;
void foo_bar_reg(void)
{
+ mutex_lock(&thread_mutex);
+ if (simple_thread_cnt++)
+ goto out;
+
pr_info("Starting thread for foo_bar_fn\n");
/*
* We shouldn't be able to start a trace when the module is
* unloading (there's other locks to prevent that). But
* for consistency sake, we still take the thread_mutex.
*/
- mutex_lock(&thread_mutex);
simple_tsk_fn = kthread_run(simple_thread_fn, NULL, "event-sample-fn");
+ out:
mutex_unlock(&thread_mutex);
}
void foo_bar_unreg(void)
{
- pr_info("Killing thread for foo_bar_fn\n");
- /* protect against module unloading */
mutex_lock(&thread_mutex);
+ if (--simple_thread_cnt)
+ goto out;
+
+ pr_info("Killing thread for foo_bar_fn\n");
if (simple_tsk_fn)
kthread_stop(simple_tsk_fn);
simple_tsk_fn = NULL;
+ out:
mutex_unlock(&thread_mutex);
}