提交 74e27e44 编写于 作者: L Lee Schermerhorn 提交者: Greg Kroah-Hartman

PCI: Mem Policy: fix mempolicy usage in pci driver

In an attempt to ensure memory allocation from the local node, the pci
driver temporarily replaces the current task's memory policy with the
system default policy.  Trying to be a good citizen, the driver then call's
mpol_get() on the new policy.  When it's finished probing, it undoes the
'_get by calling mpol_free() [on the system default policy] and then
restores the current task's saved mempolicy.

A couple of issues here:

1) it's never necessary to set a task's mempolicy to the
   system default policy in order to get system default
   allocation behavior.  Simply set the current task's
   mempolicy to NULL and allocations will fall back to
   system default policy.

2) we should never [need to] call mpol_free() on the system
   default policy.  [I plan on trapping this with a VM_BUG_ON()
   in a subsequent patch.]

This patch removes the calls to mpol_get() and mpol_free()
and uses NULL for the temporary task mempolicy to effect
default allocation behavior.
Signed-off-by: NLee Schermerhorn <lee.schermerhorn@hp.com>
Acked-by: NChristoph Lameter <clameter@sgi.com>
Acked-by: NMel Gorman <mel@csn.ul.ie>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 53a9bf42
...@@ -186,13 +186,11 @@ static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev, ...@@ -186,13 +186,11 @@ static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev,
set_cpus_allowed(current, node_to_cpumask(node)); set_cpus_allowed(current, node_to_cpumask(node));
/* And set default memory allocation policy */ /* And set default memory allocation policy */
oldpol = current->mempolicy; oldpol = current->mempolicy;
current->mempolicy = &default_policy; current->mempolicy = NULL; /* fall back to system default policy */
mpol_get(current->mempolicy);
#endif #endif
error = drv->probe(dev, id); error = drv->probe(dev, id);
#ifdef CONFIG_NUMA #ifdef CONFIG_NUMA
set_cpus_allowed(current, oldmask); set_cpus_allowed(current, oldmask);
mpol_free(current->mempolicy);
current->mempolicy = oldpol; current->mempolicy = oldpol;
#endif #endif
return error; return error;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册