diff options
author | Geert Uytterhoeven <geert@linux-m68k.org> | 2016-08-03 13:58:19 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-08-03 18:20:12 -0400 |
commit | 4620a06e4b3c5d076feb9a42ab43dce77c385358 (patch) | |
tree | 82ddf106f95965a6b70a987134f6e0c2da169cd7 /mm | |
parent | 25fd91dc72de6b0491b8cd298a079b9176c0c48e (diff) |
shmem: Fix link error if huge pages support is disabled
If CONFIG_TRANSPARENT_HUGE_PAGECACHE=n, HPAGE_PMD_NR evaluates to
BUILD_BUG_ON(), and may cause (e.g. with gcc 4.12):
mm/built-in.o: In function `shmem_alloc_hugepage':
shmem.c:(.text+0x17570): undefined reference to `__compiletime_assert_1365'
To fix this, move the assignment to hindex after the check for huge
pages support.
Fixes: 800d8c63b2e9 ("shmem: add huge pages support")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/shmem.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/mm/shmem.c b/mm/shmem.c index 2ac19a61d565..7f7748a0f9e1 100644 --- a/mm/shmem.c +++ b/mm/shmem.c | |||
@@ -1362,13 +1362,14 @@ static struct page *shmem_alloc_hugepage(gfp_t gfp, | |||
1362 | struct vm_area_struct pvma; | 1362 | struct vm_area_struct pvma; |
1363 | struct inode *inode = &info->vfs_inode; | 1363 | struct inode *inode = &info->vfs_inode; |
1364 | struct address_space *mapping = inode->i_mapping; | 1364 | struct address_space *mapping = inode->i_mapping; |
1365 | pgoff_t idx, hindex = round_down(index, HPAGE_PMD_NR); | 1365 | pgoff_t idx, hindex; |
1366 | void __rcu **results; | 1366 | void __rcu **results; |
1367 | struct page *page; | 1367 | struct page *page; |
1368 | 1368 | ||
1369 | if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGE_PAGECACHE)) | 1369 | if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGE_PAGECACHE)) |
1370 | return NULL; | 1370 | return NULL; |
1371 | 1371 | ||
1372 | hindex = round_down(index, HPAGE_PMD_NR); | ||
1372 | rcu_read_lock(); | 1373 | rcu_read_lock(); |
1373 | if (radix_tree_gang_lookup_slot(&mapping->page_tree, &results, &idx, | 1374 | if (radix_tree_gang_lookup_slot(&mapping->page_tree, &results, &idx, |
1374 | hindex, 1) && idx < hindex + HPAGE_PMD_NR) { | 1375 | hindex, 1) && idx < hindex + HPAGE_PMD_NR) { |