diff options
author | Steffen Klassert <steffen.klassert@secunet.com> | 2010-01-06 03:47:10 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2010-01-06 03:47:10 -0500 |
commit | 16295bec6398a3eedc9377e1af6ff4c71b98c300 (patch) | |
tree | 992d82d920b5e6b81fe08df58f8c2d677244f759 /include/linux/padata.h | |
parent | 863b557a88f8c033f7419fabafef4712a5055f85 (diff) |
padata: Generic parallelization/serialization interface
This patch introduces an interface to process data objects
in parallel. The parallelized objects return after serialization
in the same order as they were before the parallelization.
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'include/linux/padata.h')
-rw-r--r-- | include/linux/padata.h | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/include/linux/padata.h b/include/linux/padata.h new file mode 100644 index 000000000000..51611da9c498 --- /dev/null +++ b/include/linux/padata.h | |||
@@ -0,0 +1,88 @@ | |||
1 | /* | ||
2 | * padata.h - header for the padata parallelization interface | ||
3 | * | ||
4 | * Copyright (C) 2008, 2009 secunet Security Networks AG | ||
5 | * Copyright (C) 2008, 2009 Steffen Klassert <steffen.klassert@secunet.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify it | ||
8 | * under the terms and conditions of the GNU General Public License, | ||
9 | * version 2, as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
14 | * more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along with | ||
17 | * this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | */ | ||
20 | |||
21 | #ifndef PADATA_H | ||
22 | #define PADATA_H | ||
23 | |||
24 | #include <linux/workqueue.h> | ||
25 | #include <linux/spinlock.h> | ||
26 | #include <linux/list.h> | ||
27 | |||
28 | struct padata_priv { | ||
29 | struct list_head list; | ||
30 | struct parallel_data *pd; | ||
31 | int cb_cpu; | ||
32 | int seq_nr; | ||
33 | int info; | ||
34 | void (*parallel)(struct padata_priv *padata); | ||
35 | void (*serial)(struct padata_priv *padata); | ||
36 | }; | ||
37 | |||
38 | struct padata_list { | ||
39 | struct list_head list; | ||
40 | spinlock_t lock; | ||
41 | }; | ||
42 | |||
43 | struct padata_queue { | ||
44 | struct padata_list parallel; | ||
45 | struct padata_list reorder; | ||
46 | struct padata_list serial; | ||
47 | struct work_struct pwork; | ||
48 | struct work_struct swork; | ||
49 | struct parallel_data *pd; | ||
50 | atomic_t num_obj; | ||
51 | int cpu_index; | ||
52 | }; | ||
53 | |||
54 | struct parallel_data { | ||
55 | struct padata_instance *pinst; | ||
56 | struct padata_queue *queue; | ||
57 | atomic_t seq_nr; | ||
58 | atomic_t reorder_objects; | ||
59 | atomic_t refcnt; | ||
60 | unsigned int max_seq_nr; | ||
61 | cpumask_var_t cpumask; | ||
62 | spinlock_t lock; | ||
63 | }; | ||
64 | |||
65 | struct padata_instance { | ||
66 | struct notifier_block cpu_notifier; | ||
67 | struct workqueue_struct *wq; | ||
68 | struct parallel_data *pd; | ||
69 | cpumask_var_t cpumask; | ||
70 | struct mutex lock; | ||
71 | u8 flags; | ||
72 | #define PADATA_INIT 1 | ||
73 | #define PADATA_RESET 2 | ||
74 | }; | ||
75 | |||
76 | extern struct padata_instance *padata_alloc(const struct cpumask *cpumask, | ||
77 | struct workqueue_struct *wq); | ||
78 | extern void padata_free(struct padata_instance *pinst); | ||
79 | extern int padata_do_parallel(struct padata_instance *pinst, | ||
80 | struct padata_priv *padata, int cb_cpu); | ||
81 | extern void padata_do_serial(struct padata_priv *padata); | ||
82 | extern int padata_set_cpumask(struct padata_instance *pinst, | ||
83 | cpumask_var_t cpumask); | ||
84 | extern int padata_add_cpu(struct padata_instance *pinst, int cpu); | ||
85 | extern int padata_remove_cpu(struct padata_instance *pinst, int cpu); | ||
86 | extern void padata_start(struct padata_instance *pinst); | ||
87 | extern void padata_stop(struct padata_instance *pinst); | ||
88 | #endif | ||