From d6cd33893c73544640e2e0f9b57bf51163a9311a Mon Sep 17 00:00:00 2001 From: David Howells Date: Thu, 19 Nov 2009 18:10:53 +0000 Subject: [PATCH] --- yaml --- r: 168819 b: refs/heads/master c: 31ba99d304494cb28fa8671ccc769c5543e1165d h: refs/heads/master i: 168817: 4ea6abfdc56ab245748a6d890c0fca34fc3ac01f 168815: 12b510aaff0a43c71e2c399f3c97b228553febfd v: v3 --- [refs] | 2 +- trunk/Documentation/slow-work.txt | 15 +++++++++++++++ trunk/include/linux/slow-work.h | 19 +++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 22bda1f06ec6..540e64948ddd 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 8fba10a42d191de612e60e7009c8f0313f90a9b3 +refs/heads/master: 31ba99d304494cb28fa8671ccc769c5543e1165d diff --git a/trunk/Documentation/slow-work.txt b/trunk/Documentation/slow-work.txt index f120238e70fe..0169c9d9dd16 100644 --- a/trunk/Documentation/slow-work.txt +++ b/trunk/Documentation/slow-work.txt @@ -144,6 +144,21 @@ from being taken away before it completes. module should almost certainly be THIS_MODULE. +================ +HELPER FUNCTIONS +================ + +The slow-work facility provides a function by which it can be determined +whether or not an item is queued for later execution: + + bool queued = slow_work_is_queued(struct slow_work *work); + +If it returns false, then the item is not on the queue (it may be executing +with a requeue pending). This can be used to work out whether an item on which +another depends is on the queue, thus allowing a dependent item to be queued +after it. + + =============== ITEM OPERATIONS =============== diff --git a/trunk/include/linux/slow-work.h b/trunk/include/linux/slow-work.h index f41485145ed1..bfd3ab4c8898 100644 --- a/trunk/include/linux/slow-work.h +++ b/trunk/include/linux/slow-work.h @@ -120,6 +120,25 @@ static inline void vslow_work_init(struct slow_work *work, INIT_LIST_HEAD(&work->link); } +/** + * slow_work_is_queued - Determine if a slow work item is on the work queue + * work: The work item to test + * + * Determine if the specified slow-work item is on the work queue. This + * returns true if it is actually on the queue. + * + * If the item is executing and has been marked for requeue when execution + * finishes, then false will be returned. + * + * Anyone wishing to wait for completion of execution can wait on the + * SLOW_WORK_EXECUTING bit. + */ +static inline bool slow_work_is_queued(struct slow_work *work) +{ + unsigned long flags = work->flags; + return flags & SLOW_WORK_PENDING && !(flags & SLOW_WORK_EXECUTING); +} + extern int slow_work_enqueue(struct slow_work *work); extern void slow_work_cancel(struct slow_work *work); extern int slow_work_register_user(struct module *owner);