The kernel currently clamps large system hashes to MAX_ORDER when
hashdist is not set, which is rather arbitrary.

vmalloc space is limited on 32-bit machines, but this shouldn't
result in much more used because of small physical memory.

Signed-off-by: Nicholas Piggin <npig...@gmail.com>
---
 mm/page_alloc.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 59661106da16..1683d54d6405 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -7978,7 +7978,7 @@ void *__init alloc_large_system_hash(const char 
*tablename,
                        else
                                table = memblock_alloc_raw(size,
                                                           SMP_CACHE_BYTES);
-               } else if (hashdist) {
+               } else if (get_order(size) >= MAX_ORDER || hashdist) {
                        table = __vmalloc(size, gfp_flags, PAGE_KERNEL);
                } else {
                        /*
@@ -7986,10 +7986,8 @@ void *__init alloc_large_system_hash(const char 
*tablename,
                         * some pages at the end of hash table which
                         * alloc_pages_exact() automatically does
                         */
-                       if (get_order(size) < MAX_ORDER) {
-                               table = alloc_pages_exact(size, gfp_flags);
-                               kmemleak_alloc(table, size, 1, gfp_flags);
-                       }
+                       table = alloc_pages_exact(size, gfp_flags);
+                       kmemleak_alloc(table, size, 1, gfp_flags);
                }
        } while (!table && size > PAGE_SIZE && --log2qty);
 
-- 
2.20.1

Reply via email to