Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 22540
b: refs/heads/master
c: 1fa44ec
h: refs/heads/master
v: v3
  • Loading branch information
James Bottomley authored and James Bottomley committed Feb 28, 2006
1 parent d9c8920 commit 646bd4b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ba3af0aff042caa1f41b5f7164cab37c717b8811
refs/heads/master: 1fa44ecad2b86475e038aed81b0bf333fa484f8b
6 changes: 6 additions & 0 deletions trunk/include/linux/workqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ struct work_struct {
struct timer_list timer;
};

struct execute_work {
struct work_struct work;
};

#define __WORK_INITIALIZER(n, f, d) { \
.entry = { &(n).entry, &(n).entry }, \
.func = (f), \
Expand Down Expand Up @@ -74,6 +78,8 @@ extern void init_workqueues(void);
void cancel_rearming_delayed_work(struct work_struct *work);
void cancel_rearming_delayed_workqueue(struct workqueue_struct *,
struct work_struct *);
int execute_in_process_context(void (*fn)(void *), void *,
struct execute_work *);

/*
* Kill off a pending schedule_delayed_work(). Note that the work callback
Expand Down
29 changes: 29 additions & 0 deletions trunk/kernel/workqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <linux/cpu.h>
#include <linux/notifier.h>
#include <linux/kthread.h>
#include <linux/hardirq.h>

/*
* The per-CPU workqueue (if single thread, we always use the first
Expand Down Expand Up @@ -476,6 +477,34 @@ void cancel_rearming_delayed_work(struct work_struct *work)
}
EXPORT_SYMBOL(cancel_rearming_delayed_work);

/**
* execute_in_process_context - reliably execute the routine with user context
* @fn: the function to execute
* @data: data to pass to the function
* @ew: guaranteed storage for the execute work structure (must
* be available when the work executes)
*
* Executes the function immediately if process context is available,
* otherwise schedules the function for delayed execution.
*
* Returns: 0 - function was executed
* 1 - function was scheduled for execution
*/
int execute_in_process_context(void (*fn)(void *data), void *data,
struct execute_work *ew)
{
if (!in_interrupt()) {
fn(data);
return 0;
}

INIT_WORK(&ew->work, fn, data);
schedule_work(&ew->work);

return 1;
}
EXPORT_SYMBOL_GPL(execute_in_process_context);

int keventd_up(void)
{
return keventd_wq != NULL;
Expand Down

0 comments on commit 646bd4b

Please sign in to comment.