aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>2010-05-13 15:32:28 -0400
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>2010-06-14 19:37:26 -0400
commita25909a4d4a29e272f953e12595bf2f04a292dbd (patch)
tree86b54bc29aa126eff797b98728133ea960f8bd01 /kernel
parent71d1d5c722db9ae3b3f9c08ef7ddcd7759fbb1e0 (diff)
lockdep: Add an in_workqueue_context() lockdep-based test function
Some recent uses of RCU make use of workqueues. In these uses, execution within the context of a specific workqueue takes the place of the usual RCU read-side primitives such as rcu_read_lock(), and flushing of workqueues takes the place of the usual RCU grace-period primitives. Checking for correct use of rcu_dereference() in such cases requires a test of whether the code is executing in the context of a particular workqueue. This commit adds an in_workqueue_context() function that provides this test. This new function is only defined when lockdep is enabled, which allows it to be used as the second argument of rcu_dereference_check(). Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/workqueue.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 327d2deb4451..59fef1531dd2 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -68,6 +68,21 @@ struct workqueue_struct {
68#endif 68#endif
69}; 69};
70 70
71#ifdef CONFIG_LOCKDEP
72/**
73 * in_workqueue_context() - in context of specified workqueue?
74 * @wq: the workqueue of interest
75 *
76 * Checks lockdep state to see if the current task is executing from
77 * within a workqueue item. This function exists only if lockdep is
78 * enabled.
79 */
80int in_workqueue_context(struct workqueue_struct *wq)
81{
82 return lock_is_held(&wq->lockdep_map);
83}
84#endif
85
71#ifdef CONFIG_DEBUG_OBJECTS_WORK 86#ifdef CONFIG_DEBUG_OBJECTS_WORK
72 87
73static struct debug_obj_descr work_debug_descr; 88static struct debug_obj_descr work_debug_descr;