diff options
Diffstat (limited to 'include/linux/padata.h')
-rw-r--r-- | include/linux/padata.h | 121 |
1 files changed, 85 insertions, 36 deletions
diff --git a/include/linux/padata.h b/include/linux/padata.h index 8d8406246eef..bdcd1e9eacea 100644 --- a/include/linux/padata.h +++ b/include/linux/padata.h | |||
@@ -25,6 +25,11 @@ | |||
25 | #include <linux/spinlock.h> | 25 | #include <linux/spinlock.h> |
26 | #include <linux/list.h> | 26 | #include <linux/list.h> |
27 | #include <linux/timer.h> | 27 | #include <linux/timer.h> |
28 | #include <linux/notifier.h> | ||
29 | #include <linux/kobject.h> | ||
30 | |||
31 | #define PADATA_CPU_SERIAL 0x01 | ||
32 | #define PADATA_CPU_PARALLEL 0x02 | ||
28 | 33 | ||
29 | /** | 34 | /** |
30 | * struct padata_priv - Embedded to the users data structure. | 35 | * struct padata_priv - Embedded to the users data structure. |
@@ -59,7 +64,20 @@ struct padata_list { | |||
59 | }; | 64 | }; |
60 | 65 | ||
61 | /** | 66 | /** |
62 | * struct padata_queue - The percpu padata queues. | 67 | * struct padata_serial_queue - The percpu padata serial queue |
68 | * | ||
69 | * @serial: List to wait for serialization after reordering. | ||
70 | * @work: work struct for serialization. | ||
71 | * @pd: Backpointer to the internal control structure. | ||
72 | */ | ||
73 | struct padata_serial_queue { | ||
74 | struct padata_list serial; | ||
75 | struct work_struct work; | ||
76 | struct parallel_data *pd; | ||
77 | }; | ||
78 | |||
79 | /** | ||
80 | * struct padata_parallel_queue - The percpu padata parallel queue | ||
63 | * | 81 | * |
64 | * @parallel: List to wait for parallelization. | 82 | * @parallel: List to wait for parallelization. |
65 | * @reorder: List to wait for reordering after parallel processing. | 83 | * @reorder: List to wait for reordering after parallel processing. |
@@ -67,18 +85,28 @@ struct padata_list { | |||
67 | * @pwork: work struct for parallelization. | 85 | * @pwork: work struct for parallelization. |
68 | * @swork: work struct for serialization. | 86 | * @swork: work struct for serialization. |
69 | * @pd: Backpointer to the internal control structure. | 87 | * @pd: Backpointer to the internal control structure. |
88 | * @work: work struct for parallelization. | ||
70 | * @num_obj: Number of objects that are processed by this cpu. | 89 | * @num_obj: Number of objects that are processed by this cpu. |
71 | * @cpu_index: Index of the cpu. | 90 | * @cpu_index: Index of the cpu. |
72 | */ | 91 | */ |
73 | struct padata_queue { | 92 | struct padata_parallel_queue { |
74 | struct padata_list parallel; | 93 | struct padata_list parallel; |
75 | struct padata_list reorder; | 94 | struct padata_list reorder; |
76 | struct padata_list serial; | 95 | struct parallel_data *pd; |
77 | struct work_struct pwork; | 96 | struct work_struct work; |
78 | struct work_struct swork; | 97 | atomic_t num_obj; |
79 | struct parallel_data *pd; | 98 | int cpu_index; |
80 | atomic_t num_obj; | 99 | }; |
81 | int cpu_index; | 100 | |
101 | /** | ||
102 | * struct padata_cpumask - The cpumasks for the parallel/serial workers | ||
103 | * | ||
104 | * @pcpu: cpumask for the parallel workers. | ||
105 | * @cbcpu: cpumask for the serial (callback) workers. | ||
106 | */ | ||
107 | struct padata_cpumask { | ||
108 | cpumask_var_t pcpu; | ||
109 | cpumask_var_t cbcpu; | ||
82 | }; | 110 | }; |
83 | 111 | ||
84 | /** | 112 | /** |
@@ -86,25 +114,29 @@ struct padata_queue { | |||
86 | * that depends on the cpumask in use. | 114 | * that depends on the cpumask in use. |
87 | * | 115 | * |
88 | * @pinst: padata instance. | 116 | * @pinst: padata instance. |
89 | * @queue: percpu padata queues. | 117 | * @pqueue: percpu padata queues used for parallelization. |
118 | * @squeue: percpu padata queues used for serialuzation. | ||
90 | * @seq_nr: The sequence number that will be attached to the next object. | 119 | * @seq_nr: The sequence number that will be attached to the next object. |
91 | * @reorder_objects: Number of objects waiting in the reorder queues. | 120 | * @reorder_objects: Number of objects waiting in the reorder queues. |
92 | * @refcnt: Number of objects holding a reference on this parallel_data. | 121 | * @refcnt: Number of objects holding a reference on this parallel_data. |
93 | * @max_seq_nr: Maximal used sequence number. | 122 | * @max_seq_nr: Maximal used sequence number. |
94 | * @cpumask: cpumask in use. | 123 | * @cpumask: The cpumasks in use for parallel and serial workers. |
95 | * @lock: Reorder lock. | 124 | * @lock: Reorder lock. |
125 | * @processed: Number of already processed objects. | ||
96 | * @timer: Reorder timer. | 126 | * @timer: Reorder timer. |
97 | */ | 127 | */ |
98 | struct parallel_data { | 128 | struct parallel_data { |
99 | struct padata_instance *pinst; | 129 | struct padata_instance *pinst; |
100 | struct padata_queue *queue; | 130 | struct padata_parallel_queue *pqueue; |
101 | atomic_t seq_nr; | 131 | struct padata_serial_queue *squeue; |
102 | atomic_t reorder_objects; | 132 | atomic_t seq_nr; |
103 | atomic_t refcnt; | 133 | atomic_t reorder_objects; |
104 | unsigned int max_seq_nr; | 134 | atomic_t refcnt; |
105 | cpumask_var_t cpumask; | 135 | unsigned int max_seq_nr; |
106 | spinlock_t lock; | 136 | struct padata_cpumask cpumask; |
107 | struct timer_list timer; | 137 | spinlock_t lock ____cacheline_aligned; |
138 | unsigned int processed; | ||
139 | struct timer_list timer; | ||
108 | }; | 140 | }; |
109 | 141 | ||
110 | /** | 142 | /** |
@@ -113,31 +145,48 @@ struct parallel_data { | |||
113 | * @cpu_notifier: cpu hotplug notifier. | 145 | * @cpu_notifier: cpu hotplug notifier. |
114 | * @wq: The workqueue in use. | 146 | * @wq: The workqueue in use. |
115 | * @pd: The internal control structure. | 147 | * @pd: The internal control structure. |
116 | * @cpumask: User supplied cpumask. | 148 | * @cpumask: User supplied cpumasks for parallel and serial works. |
149 | * @cpumask_change_notifier: Notifiers chain for user-defined notify | ||
150 | * callbacks that will be called when either @pcpu or @cbcpu | ||
151 | * or both cpumasks change. | ||
152 | * @kobj: padata instance kernel object. | ||
117 | * @lock: padata instance lock. | 153 | * @lock: padata instance lock. |
118 | * @flags: padata flags. | 154 | * @flags: padata flags. |
119 | */ | 155 | */ |
120 | struct padata_instance { | 156 | struct padata_instance { |
121 | struct notifier_block cpu_notifier; | 157 | struct notifier_block cpu_notifier; |
122 | struct workqueue_struct *wq; | 158 | struct workqueue_struct *wq; |
123 | struct parallel_data *pd; | 159 | struct parallel_data *pd; |
124 | cpumask_var_t cpumask; | 160 | struct padata_cpumask cpumask; |
125 | struct mutex lock; | 161 | struct blocking_notifier_head cpumask_change_notifier; |
126 | u8 flags; | 162 | struct kobject kobj; |
127 | #define PADATA_INIT 1 | 163 | struct mutex lock; |
128 | #define PADATA_RESET 2 | 164 | u8 flags; |
165 | #define PADATA_INIT 1 | ||
166 | #define PADATA_RESET 2 | ||
167 | #define PADATA_INVALID 4 | ||
129 | }; | 168 | }; |
130 | 169 | ||
131 | extern struct padata_instance *padata_alloc(const struct cpumask *cpumask, | 170 | extern struct padata_instance *padata_alloc_possible( |
132 | struct workqueue_struct *wq); | 171 | struct workqueue_struct *wq); |
172 | extern struct padata_instance *padata_alloc(struct workqueue_struct *wq, | ||
173 | const struct cpumask *pcpumask, | ||
174 | const struct cpumask *cbcpumask); | ||
133 | extern void padata_free(struct padata_instance *pinst); | 175 | extern void padata_free(struct padata_instance *pinst); |
134 | extern int padata_do_parallel(struct padata_instance *pinst, | 176 | extern int padata_do_parallel(struct padata_instance *pinst, |
135 | struct padata_priv *padata, int cb_cpu); | 177 | struct padata_priv *padata, int cb_cpu); |
136 | extern void padata_do_serial(struct padata_priv *padata); | 178 | extern void padata_do_serial(struct padata_priv *padata); |
137 | extern int padata_set_cpumask(struct padata_instance *pinst, | 179 | extern int padata_set_cpumask(struct padata_instance *pinst, int cpumask_type, |
138 | cpumask_var_t cpumask); | 180 | cpumask_var_t cpumask); |
139 | extern int padata_add_cpu(struct padata_instance *pinst, int cpu); | 181 | extern int padata_set_cpumasks(struct padata_instance *pinst, |
140 | extern int padata_remove_cpu(struct padata_instance *pinst, int cpu); | 182 | cpumask_var_t pcpumask, |
141 | extern void padata_start(struct padata_instance *pinst); | 183 | cpumask_var_t cbcpumask); |
184 | extern int padata_add_cpu(struct padata_instance *pinst, int cpu, int mask); | ||
185 | extern int padata_remove_cpu(struct padata_instance *pinst, int cpu, int mask); | ||
186 | extern int padata_start(struct padata_instance *pinst); | ||
142 | extern void padata_stop(struct padata_instance *pinst); | 187 | extern void padata_stop(struct padata_instance *pinst); |
188 | extern int padata_register_cpumask_notifier(struct padata_instance *pinst, | ||
189 | struct notifier_block *nblock); | ||
190 | extern int padata_unregister_cpumask_notifier(struct padata_instance *pinst, | ||
191 | struct notifier_block *nblock); | ||
143 | #endif | 192 | #endif |