diff options
-rw-r--r-- | drivers/pci/pci-driver.c | 31 | ||||
-rw-r--r-- | include/linux/mempolicy.h | 1 | ||||
-rw-r--r-- | mm/mempolicy.c | 2 |
3 files changed, 32 insertions, 2 deletions
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index e4115a0d5ba6..414c77299c7d 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <linux/module.h> | 7 | #include <linux/module.h> |
8 | #include <linux/init.h> | 8 | #include <linux/init.h> |
9 | #include <linux/device.h> | 9 | #include <linux/device.h> |
10 | #include <linux/mempolicy.h> | ||
10 | #include "pci.h" | 11 | #include "pci.h" |
11 | 12 | ||
12 | /* | 13 | /* |
@@ -163,6 +164,34 @@ const struct pci_device_id *pci_match_device(struct pci_driver *drv, | |||
163 | return NULL; | 164 | return NULL; |
164 | } | 165 | } |
165 | 166 | ||
167 | static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev, | ||
168 | const struct pci_device_id *id) | ||
169 | { | ||
170 | int error; | ||
171 | #ifdef CONFIG_NUMA | ||
172 | /* Execute driver initialization on node where the | ||
173 | device's bus is attached to. This way the driver likely | ||
174 | allocates its local memory on the right node without | ||
175 | any need to change it. */ | ||
176 | struct mempolicy *oldpol; | ||
177 | cpumask_t oldmask = current->cpus_allowed; | ||
178 | int node = pcibus_to_node(dev->bus); | ||
179 | if (node >= 0 && node_online(node)) | ||
180 | set_cpus_allowed(current, node_to_cpumask(node)); | ||
181 | /* And set default memory allocation policy */ | ||
182 | oldpol = current->mempolicy; | ||
183 | current->mempolicy = &default_policy; | ||
184 | mpol_get(current->mempolicy); | ||
185 | #endif | ||
186 | error = drv->probe(dev, id); | ||
187 | #ifdef CONFIG_NUMA | ||
188 | set_cpus_allowed(current, oldmask); | ||
189 | mpol_free(current->mempolicy); | ||
190 | current->mempolicy = oldpol; | ||
191 | #endif | ||
192 | return error; | ||
193 | } | ||
194 | |||
166 | /** | 195 | /** |
167 | * __pci_device_probe() | 196 | * __pci_device_probe() |
168 | * | 197 | * |
@@ -180,7 +209,7 @@ __pci_device_probe(struct pci_driver *drv, struct pci_dev *pci_dev) | |||
180 | 209 | ||
181 | id = pci_match_device(drv, pci_dev); | 210 | id = pci_match_device(drv, pci_dev); |
182 | if (id) | 211 | if (id) |
183 | error = drv->probe(pci_dev, id); | 212 | error = pci_call_probe(drv, pci_dev, id); |
184 | if (error >= 0) { | 213 | if (error >= 0) { |
185 | pci_dev->driver = drv; | 214 | pci_dev->driver = drv; |
186 | error = 0; | 215 | error = 0; |
diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h index 94a46f38c532..58385ee1c0ac 100644 --- a/include/linux/mempolicy.h +++ b/include/linux/mempolicy.h | |||
@@ -155,6 +155,7 @@ struct mempolicy *get_vma_policy(struct task_struct *task, | |||
155 | 155 | ||
156 | extern void numa_default_policy(void); | 156 | extern void numa_default_policy(void); |
157 | extern void numa_policy_init(void); | 157 | extern void numa_policy_init(void); |
158 | extern struct mempolicy default_policy; | ||
158 | 159 | ||
159 | #else | 160 | #else |
160 | 161 | ||
diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 13492d66b7c8..afa06e184d88 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c | |||
@@ -88,7 +88,7 @@ static kmem_cache_t *sn_cache; | |||
88 | policied. */ | 88 | policied. */ |
89 | static int policy_zone; | 89 | static int policy_zone; |
90 | 90 | ||
91 | static struct mempolicy default_policy = { | 91 | struct mempolicy default_policy = { |
92 | .refcnt = ATOMIC_INIT(1), /* never free it */ | 92 | .refcnt = ATOMIC_INIT(1), /* never free it */ |
93 | .policy = MPOL_DEFAULT, | 93 | .policy = MPOL_DEFAULT, |
94 | }; | 94 | }; |