Commit 4620a06e authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by Linus Torvalds

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: 800d8c63 ("shmem: add huge pages support")
Signed-off-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Acked-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 25fd91dc
...@@ -1362,13 +1362,14 @@ static struct page *shmem_alloc_hugepage(gfp_t gfp, ...@@ -1362,13 +1362,14 @@ static struct page *shmem_alloc_hugepage(gfp_t gfp,
struct vm_area_struct pvma; struct vm_area_struct pvma;
struct inode *inode = &info->vfs_inode; struct inode *inode = &info->vfs_inode;
struct address_space *mapping = inode->i_mapping; struct address_space *mapping = inode->i_mapping;
pgoff_t idx, hindex = round_down(index, HPAGE_PMD_NR); pgoff_t idx, hindex;
void __rcu **results; void __rcu **results;
struct page *page; struct page *page;
if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGE_PAGECACHE)) if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGE_PAGECACHE))
return NULL; return NULL;
hindex = round_down(index, HPAGE_PMD_NR);
rcu_read_lock(); rcu_read_lock();
if (radix_tree_gang_lookup_slot(&mapping->page_tree, &results, &idx, if (radix_tree_gang_lookup_slot(&mapping->page_tree, &results, &idx,
hindex, 1) && idx < hindex + HPAGE_PMD_NR) { hindex, 1) && idx < hindex + HPAGE_PMD_NR) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment