diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-04-06 03:02:57 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-04-06 03:02:57 -0400 |
commit | f541ae326fa120fa5c57433e4d9a133df212ce41 (patch) | |
tree | bdbd94ec72cfc601118051cb35e8617d55510177 /include/linux/slow-work.h | |
parent | e255357764f92afcafafbd4879b222b8c752065a (diff) | |
parent | 0221c81b1b8eb0cbb6b30a0ced52ead32d2b4e4c (diff) |
Merge branch 'linus' into perfcounters/core-v2
Merge reason: we have gathered quite a few conflicts, need to merge upstream
Conflicts:
arch/powerpc/kernel/Makefile
arch/x86/ia32/ia32entry.S
arch/x86/include/asm/hardirq.h
arch/x86/include/asm/unistd_32.h
arch/x86/include/asm/unistd_64.h
arch/x86/kernel/cpu/common.c
arch/x86/kernel/irq.c
arch/x86/kernel/syscall_table_32.S
arch/x86/mm/iomap_32.c
include/linux/sched.h
kernel/Makefile
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/linux/slow-work.h')
-rw-r--r-- | include/linux/slow-work.h | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/include/linux/slow-work.h b/include/linux/slow-work.h new file mode 100644 index 000000000000..85958277f83d --- /dev/null +++ b/include/linux/slow-work.h | |||
@@ -0,0 +1,95 @@ | |||
1 | /* Worker thread pool for slow items, such as filesystem lookups or mkdirs | ||
2 | * | ||
3 | * Copyright (C) 2008 Red Hat, Inc. All Rights Reserved. | ||
4 | * Written by David Howells (dhowells@redhat.com) | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public Licence | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the Licence, or (at your option) any later version. | ||
10 | * | ||
11 | * See Documentation/slow-work.txt | ||
12 | */ | ||
13 | |||
14 | #ifndef _LINUX_SLOW_WORK_H | ||
15 | #define _LINUX_SLOW_WORK_H | ||
16 | |||
17 | #ifdef CONFIG_SLOW_WORK | ||
18 | |||
19 | #include <linux/sysctl.h> | ||
20 | |||
21 | struct slow_work; | ||
22 | |||
23 | /* | ||
24 | * The operations used to support slow work items | ||
25 | */ | ||
26 | struct slow_work_ops { | ||
27 | /* get a ref on a work item | ||
28 | * - return 0 if successful, -ve if not | ||
29 | */ | ||
30 | int (*get_ref)(struct slow_work *work); | ||
31 | |||
32 | /* discard a ref to a work item */ | ||
33 | void (*put_ref)(struct slow_work *work); | ||
34 | |||
35 | /* execute a work item */ | ||
36 | void (*execute)(struct slow_work *work); | ||
37 | }; | ||
38 | |||
39 | /* | ||
40 | * A slow work item | ||
41 | * - A reference is held on the parent object by the thread pool when it is | ||
42 | * queued | ||
43 | */ | ||
44 | struct slow_work { | ||
45 | unsigned long flags; | ||
46 | #define SLOW_WORK_PENDING 0 /* item pending (further) execution */ | ||
47 | #define SLOW_WORK_EXECUTING 1 /* item currently executing */ | ||
48 | #define SLOW_WORK_ENQ_DEFERRED 2 /* item enqueue deferred */ | ||
49 | #define SLOW_WORK_VERY_SLOW 3 /* item is very slow */ | ||
50 | const struct slow_work_ops *ops; /* operations table for this item */ | ||
51 | struct list_head link; /* link in queue */ | ||
52 | }; | ||
53 | |||
54 | /** | ||
55 | * slow_work_init - Initialise a slow work item | ||
56 | * @work: The work item to initialise | ||
57 | * @ops: The operations to use to handle the slow work item | ||
58 | * | ||
59 | * Initialise a slow work item. | ||
60 | */ | ||
61 | static inline void slow_work_init(struct slow_work *work, | ||
62 | const struct slow_work_ops *ops) | ||
63 | { | ||
64 | work->flags = 0; | ||
65 | work->ops = ops; | ||
66 | INIT_LIST_HEAD(&work->link); | ||
67 | } | ||
68 | |||
69 | /** | ||
70 | * slow_work_init - Initialise a very slow work item | ||
71 | * @work: The work item to initialise | ||
72 | * @ops: The operations to use to handle the slow work item | ||
73 | * | ||
74 | * Initialise a very slow work item. This item will be restricted such that | ||
75 | * only a certain number of the pool threads will be able to execute items of | ||
76 | * this type. | ||
77 | */ | ||
78 | static inline void vslow_work_init(struct slow_work *work, | ||
79 | const struct slow_work_ops *ops) | ||
80 | { | ||
81 | work->flags = 1 << SLOW_WORK_VERY_SLOW; | ||
82 | work->ops = ops; | ||
83 | INIT_LIST_HEAD(&work->link); | ||
84 | } | ||
85 | |||
86 | extern int slow_work_enqueue(struct slow_work *work); | ||
87 | extern int slow_work_register_user(void); | ||
88 | extern void slow_work_unregister_user(void); | ||
89 | |||
90 | #ifdef CONFIG_SYSCTL | ||
91 | extern ctl_table slow_work_sysctls[]; | ||
92 | #endif | ||
93 | |||
94 | #endif /* CONFIG_SLOW_WORK */ | ||
95 | #endif /* _LINUX_SLOW_WORK_H */ | ||