diff options
author | Ben Pfaff <blp@nicira.com> | 2014-04-25 17:46:21 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2014-04-28 15:25:49 -0700 |
commit | 8ba0a5227f6e6b50838c157bd303c2d5bf6f4e59 (patch) | |
tree | cefe70017f665e8d9a9c36d7645caa7261fd3dd4 /vswitchd | |
parent | 595ef8b10ad81c6033df53dfbfdb8c1b01f6de87 (diff) | |
download | openvswitch-8ba0a5227f6e6b50838c157bd303c2d5bf6f4e59.tar.gz |
ovs-thread: Make caller provide thread name when creating a thread.
Thread names are occasionally very useful for debugging, but from time to
time we've forgotten to set one. This commit adds the new thread's name
as a parameter to the function to start a thread, to make that mistake
impossible. This also simplifies code, since two function calls become
only one.
This makes a few other changes to the thread creation function:
* Since it is no longer a direct wrapper around a pthread function,
rename it to avoid giving that impression.
* Remove 'pthread_attr_t *' param that every caller supplied as NULL.
* Change 'pthread *' parameter into a return value, for convenience.
The system-stats code hadn't set a thread name, so this fixes that issue.
This patch is a prerequisite for making RCU report the name of a thread
that is blocking RCU synchronization, because the easiest way to do that is
for ovsrcu_quiesce_end() to record the current thread's name.
ovsrcu_quiesce_end() is called before the thread function is called, so it
won't get a name set within the thread function itself. Setting the thread
name earlier, as in this patch, avoids the problem.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Alex Wang <alexw@nicira.com>
Diffstat (limited to 'vswitchd')
-rw-r--r-- | vswitchd/system-stats.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/vswitchd/system-stats.c b/vswitchd/system-stats.c index 6c7393368..778978731 100644 --- a/vswitchd/system-stats.c +++ b/vswitchd/system-stats.c @@ -542,7 +542,8 @@ system_stats_enable(bool enable) ovs_mutex_lock(&mutex); if (enable) { if (!started) { - xpthread_create(NULL, NULL, system_stats_thread_func, NULL); + ovs_thread_create("system_stats", + system_stats_thread_func, NULL); latch_init(&latch); started = true; } |