diff options
| author | Vlastimil Babka <vbabka@suse.cz> | 2015-02-11 18:27:15 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-11 20:06:04 -0500 |
| commit | be97a41b291e495d6cb767b3ee0f84ed05804892 (patch) | |
| tree | 9cb11c679252de5a1d921f24e4693640f8aa47dc /include | |
| parent | 077fcf116c8c2bd7ee9487b645aa3b50368db7e1 (diff) | |
mm/mempolicy.c: merge alloc_hugepage_vma to alloc_pages_vma
The previous commit ("mm/thp: Allocate transparent hugepages on local
node") introduced alloc_hugepage_vma() to mm/mempolicy.c to perform a
special policy for THP allocations. The function has the same interface
as alloc_pages_vma(), shares a lot of boilerplate code and a long
comment.
This patch merges the hugepage special case into alloc_pages_vma. The
extra if condition should be cheap enough price to pay. We also prevent
a (however unlikely) race with parallel mems_allowed update, which could
make hugepage allocation restart only within the fallback call to
alloc_hugepage_vma() and not reconsider the special rule in
alloc_hugepage_vma().
Also by making sure mpol_cond_put(pol) is always called before actual
allocation attempt, we can use a single exit path within the function.
Also update the comment for missing node parameter and obsolete reference
to mm_sem.
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: David Rientjes <rientjes@google.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/gfp.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/include/linux/gfp.h b/include/linux/gfp.h index 60110e06419d..51bd1e72a917 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h | |||
| @@ -334,22 +334,22 @@ alloc_pages(gfp_t gfp_mask, unsigned int order) | |||
| 334 | } | 334 | } |
| 335 | extern struct page *alloc_pages_vma(gfp_t gfp_mask, int order, | 335 | extern struct page *alloc_pages_vma(gfp_t gfp_mask, int order, |
| 336 | struct vm_area_struct *vma, unsigned long addr, | 336 | struct vm_area_struct *vma, unsigned long addr, |
| 337 | int node); | 337 | int node, bool hugepage); |
| 338 | extern struct page *alloc_hugepage_vma(gfp_t gfp, struct vm_area_struct *vma, | 338 | #define alloc_hugepage_vma(gfp_mask, vma, addr, order) \ |
| 339 | unsigned long addr, int order); | 339 | alloc_pages_vma(gfp_mask, order, vma, addr, numa_node_id(), true) |
| 340 | #else | 340 | #else |
| 341 | #define alloc_pages(gfp_mask, order) \ | 341 | #define alloc_pages(gfp_mask, order) \ |
| 342 | alloc_pages_node(numa_node_id(), gfp_mask, order) | 342 | alloc_pages_node(numa_node_id(), gfp_mask, order) |
| 343 | #define alloc_pages_vma(gfp_mask, order, vma, addr, node) \ | 343 | #define alloc_pages_vma(gfp_mask, order, vma, addr, node, false)\ |
| 344 | alloc_pages(gfp_mask, order) | 344 | alloc_pages(gfp_mask, order) |
| 345 | #define alloc_hugepage_vma(gfp_mask, vma, addr, order) \ | 345 | #define alloc_hugepage_vma(gfp_mask, vma, addr, order) \ |
| 346 | alloc_pages(gfp_mask, order) | 346 | alloc_pages(gfp_mask, order) |
| 347 | #endif | 347 | #endif |
| 348 | #define alloc_page(gfp_mask) alloc_pages(gfp_mask, 0) | 348 | #define alloc_page(gfp_mask) alloc_pages(gfp_mask, 0) |
| 349 | #define alloc_page_vma(gfp_mask, vma, addr) \ | 349 | #define alloc_page_vma(gfp_mask, vma, addr) \ |
| 350 | alloc_pages_vma(gfp_mask, 0, vma, addr, numa_node_id()) | 350 | alloc_pages_vma(gfp_mask, 0, vma, addr, numa_node_id(), false) |
| 351 | #define alloc_page_vma_node(gfp_mask, vma, addr, node) \ | 351 | #define alloc_page_vma_node(gfp_mask, vma, addr, node) \ |
| 352 | alloc_pages_vma(gfp_mask, 0, vma, addr, node) | 352 | alloc_pages_vma(gfp_mask, 0, vma, addr, node, false) |
| 353 | 353 | ||
| 354 | extern struct page *alloc_kmem_pages(gfp_t gfp_mask, unsigned int order); | 354 | extern struct page *alloc_kmem_pages(gfp_t gfp_mask, unsigned int order); |
| 355 | extern struct page *alloc_kmem_pages_node(int nid, gfp_t gfp_mask, | 355 | extern struct page *alloc_kmem_pages_node(int nid, gfp_t gfp_mask, |
