Skip to content

Commit 930f036

Browse files
rientjestorvalds
authored andcommitted
mm, vmalloc: constify allocation mask
tmp_mask in the __vmalloc_area_node() iteration never changes so it can be moved into function scope and marked with const. This causes the movl and orl to only be done once per call rather than area->nr_pages times. nested_gfp can also be marked const. Signed-off-by: David Rientjes <rientjes@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 660654f commit 930f036

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎mm/vmalloc.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,7 +1566,8 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
15661566
const int order = 0;
15671567
struct page **pages;
15681568
unsigned int nr_pages, array_size, i;
1569-
gfp_t nested_gfp = (gfp_mask & GFP_RECLAIM_MASK) | __GFP_ZERO;
1569+
const gfp_t nested_gfp = (gfp_mask & GFP_RECLAIM_MASK) | __GFP_ZERO;
1570+
const gfp_t alloc_mask = gfp_mask | __GFP_NOWARN;
15701571

15711572
nr_pages = get_vm_area_size(area) >> PAGE_SHIFT;
15721573
array_size = (nr_pages * sizeof(struct page *));
@@ -1589,12 +1590,11 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
15891590

15901591
for (i = 0; i < area->nr_pages; i++) {
15911592
struct page *page;
1592-
gfp_t tmp_mask = gfp_mask | __GFP_NOWARN;
15931593

15941594
if (node == NUMA_NO_NODE)
1595-
page = alloc_page(tmp_mask);
1595+
page = alloc_page(alloc_mask);
15961596
else
1597-
page = alloc_pages_node(node, tmp_mask, order);
1597+
page = alloc_pages_node(node, alloc_mask, order);
15981598

15991599
if (unlikely(!page)) {
16001600
/* Successfully allocated i pages, free them in __vunmap() */

0 commit comments

Comments
 (0)