diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c index a4ac764..dc511cb 100644 --- a/arch/x86/kernel/pci-dma.c +++ b/arch/x86/kernel/pci-dma.c @@ -152,12 +152,21 @@ void *dma_generic_alloc_coherent(struct device *dev, size_t size, unsigned long dma_mask; struct page *page; dma_addr_t addr; + int nid; dma_mask = dma_alloc_coherent_mask(dev, flag); flag |= __GFP_ZERO; again: - page = alloc_pages_node(dev_to_node(dev), flag, get_order(size)); + nid = dev_to_node(dev); + /* + * If pci-dma maintainer makes sure nid never has NUMA_NO_NODE + * we can remove this ugly checking. + */ + if (nid == NUMA_NO_NODE) + page = alloc_pages_any_node(flag, get_order(size)); + else + page = alloc_pages_exact_node(nid, flag, get_order(size)); if (!page) return NULL; diff --git a/include/linux/gfp.h b/include/linux/gfp.h index 4c6d413..47fba21 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h @@ -278,13 +278,10 @@ __alloc_pages(gfp_t gfp_mask, unsigned int order, return __alloc_pages_nodemask(gfp_mask, order, zonelist, NULL); } -static inline struct page *alloc_pages_node(int nid, gfp_t gfp_mask, +static inline struct page *alloc_pagse_any_node(gfp_t gfp_mask, unsigned int order) { - /* Unknown node is current node */ - if (nid < 0) - nid = numa_node_id(); - + int nid = numa_node_id(); return __alloc_pages(gfp_mask, order, node_zonelist(nid, gfp_mask)); } @@ -308,7 +305,7 @@ extern struct page *alloc_page_vma(gfp_t gfp_mask, struct vm_area_struct *vma, unsigned long addr); #else #define alloc_pages(gfp_mask, order) \ - alloc_pages_node(numa_node_id(), gfp_mask, order) + alloc_pages_exact_node(numa_node_id(), gfp_mask, order) #define alloc_page_vma(gfp_mask, vma, addr) alloc_pages(gfp_mask, 0) #endif #define alloc_page(gfp_mask) alloc_pages(gfp_mask, 0)