aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/padata.txt
diff options
context:
space:
mode:
authorSteffen Klassert <steffen.klassert@secunet.com>2010-07-27 01:20:47 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2010-07-31 07:53:07 -0400
commit313910d3b98029a867bb4aa3ee552ae573db0458 (patch)
treecaec2d33a99ada7dcb66523b0d4459565a46fd4e /Documentation/padata.txt
parent0500e9b3f11ce84fc6ee48a3e29909145e58ba48 (diff)
padata: update API documentation
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'Documentation/padata.txt')
-rw-r--r--Documentation/padata.txt76
1 files changed, 64 insertions, 12 deletions
diff --git a/Documentation/padata.txt b/Documentation/padata.txt
index 93dd4e6db975..473ebf22cd69 100644
--- a/Documentation/padata.txt
+++ b/Documentation/padata.txt
@@ -1,5 +1,5 @@
1The padata parallel execution mechanism 1The padata parallel execution mechanism
2Last updated for 2.6.34 2Last updated for 2.6.36
3 3
4Padata is a mechanism by which the kernel can farm work out to be done in 4Padata is a mechanism by which the kernel can farm work out to be done in
5parallel on multiple CPUs while retaining the ordering of tasks. It was 5parallel on multiple CPUs while retaining the ordering of tasks. It was
@@ -13,12 +13,28 @@ overall control of how tasks are to be run:
13 13
14 #include <linux/padata.h> 14 #include <linux/padata.h>
15 15
16 struct padata_instance *padata_alloc(const struct cpumask *cpumask, 16 struct padata_instance *padata_alloc(struct workqueue_struct *wq,
17 struct workqueue_struct *wq); 17 const struct cpumask *pcpumask,
18 const struct cpumask *cbcpumask);
18 19
19The cpumask describes which processors will be used to execute work 20The pcpumask describes which processors will be used to execute work
20submitted to this instance. The workqueue wq is where the work will 21submitted to this instance in parallel. The cbcpumask defines which
21actually be done; it should be a multithreaded queue, naturally. 22processors are allowed to use as the serialization callback processor.
23The workqueue wq is where the work will actually be done; it should be
24a multithreaded queue, naturally.
25
26To allocate a padata instance with the cpu_possible_mask for both
27cpumasks this helper function can be used:
28
29 struct padata_instance *padata_alloc_possible(struct workqueue_struct *wq);
30
31Note: Padata maintains two kinds of cpumasks internally. The user supplied
32cpumasks, submitted by padata_alloc/padata_alloc_possible and the 'usable'
33cpumasks. The usable cpumasks are always the subset of active cpus in the
34user supplied cpumasks, these are the cpumasks padata actually use. So
35it is legal to supply a cpumask to padata that contains offline cpus.
36Once a offline cpu in the user supplied cpumask comes online, padata
37is going to use it.
22 38
23There are functions for enabling and disabling the instance: 39There are functions for enabling and disabling the instance:
24 40
@@ -34,13 +50,49 @@ is unused.
34 50
35The list of CPUs to be used can be adjusted with these functions: 51The list of CPUs to be used can be adjusted with these functions:
36 52
37 int padata_set_cpumask(struct padata_instance *pinst, 53 int padata_set_cpumasks(struct padata_instance *pinst,
54 cpumask_var_t pcpumask,
55 cpumask_var_t cbcpumask);
56 int padata_set_cpumask(struct padata_instance *pinst, int cpumask_type,
38 cpumask_var_t cpumask); 57 cpumask_var_t cpumask);
39 int padata_add_cpu(struct padata_instance *pinst, int cpu); 58 int padata_add_cpu(struct padata_instance *pinst, int cpu, int mask);
40 int padata_remove_cpu(struct padata_instance *pinst, int cpu); 59 int padata_remove_cpu(struct padata_instance *pinst, int cpu, int mask);
60
61Changing the CPU masks are expensive operations, though, so it should not be
62done with great frequency.
63
64It's possible to change both cpumasks of a padata instance with
65padata_set_cpumasks by specifying the cpumasks for parallel execution (pcpumask)
66and for the serial callback function (cbcpumask). padata_set_cpumask is to
67change just one of the cpumasks. Here cpumask_type is one of PADATA_CPU_SERIAL,
68PADATA_CPU_PARALLEL and cpumask specifies the new cpumask to use.
69To simply add or remove one cpu from a certain cpumask the functions
70padata_add_cpu/padata_remove_cpu are used. cpu specifies the cpu to add or
71remove and mask is one of PADATA_CPU_SERIAL, PADATA_CPU_PARALLEL.
72
73If a user is interested in padata cpumask changes, he can register to
74the padata cpumask change notifier:
75
76 int padata_register_cpumask_notifier(struct padata_instance *pinst,
77 struct notifier_block *nblock);
78
79To unregister from that notifier:
80
81 int padata_unregister_cpumask_notifier(struct padata_instance *pinst,
82 struct notifier_block *nblock);
83
84The padata cpumask change notifier notifies about changes of the usable
85cpumasks, i.e. the subset of active cpus in the user supplied cpumask.
86
87Padata calls the notifier chain with:
88
89 blocking_notifier_call_chain(&pinst->cpumask_change_notifier,
90 notification_mask,
91 &pd_new->cpumask);
41 92
42Changing the CPU mask has the look of an expensive operation, though, so it 93Here cpumask_change_notifier is registered notifier, notification_mask
43probably should not be done with great frequency. 94is one of PADATA_CPU_SERIAL, PADATA_CPU_PARALLEL and cpumask is a pointer
95to a struct padata_cpumask that contains the new cpumask informations.
44 96
45Actually submitting work to the padata instance requires the creation of a 97Actually submitting work to the padata instance requires the creation of a
46padata_priv structure: 98padata_priv structure:
@@ -53,7 +105,7 @@ padata_priv structure:
53 105
54This structure will almost certainly be embedded within some larger 106This structure will almost certainly be embedded within some larger
55structure specific to the work to be done. Most its fields are private to 107structure specific to the work to be done. Most its fields are private to
56padata, but the structure should be zeroed at initialization time, and the 108padata, but the structure should be zeroed at initialisation time, and the
57parallel() and serial() functions should be provided. Those functions will 109parallel() and serial() functions should be provided. Those functions will
58be called in the process of getting the work done as we will see 110be called in the process of getting the work done as we will see
59momentarily. 111momentarily.