s390/mm: let vmalloc area size depend on physical memory size
authorHeiko Carstens <hca@linux.ibm.com>
Fri, 18 Sep 2020 10:25:37 +0000 (12:25 +0200)
committerHeiko Carstens <hca@linux.ibm.com>
Mon, 9 Nov 2020 10:20:59 +0000 (11:20 +0100)
To make sure that the vmalloc area size is for almost all cases large
enough let it depend on the (potential) physical memory size. There is
still the possibility to override this with the vmalloc kernel command
line parameter.

Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
arch/s390/boot/boot.h
arch/s390/boot/ipl_parm.c
arch/s390/boot/startup.c

index 2ea603f70c3bd683ddcfa51bac0e45d30de972b4..4d453629978984e945678d65681f908a8f11ca5e 100644 (file)
@@ -14,6 +14,7 @@ void print_pgm_check_info(void);
 unsigned long get_random_base(unsigned long safe_addr);
 
 extern int kaslr_enabled;
+extern int vmalloc_size_set;
 extern const char kernel_version[];
 
 unsigned long read_ipl_report(unsigned long safe_offset);
index f94b91d72620ec740eaa77aaa5496c84dc392d5c..33f43a7d03f3e0370adb5ac763b7fe7727f32472 100644 (file)
@@ -21,6 +21,7 @@ unsigned long __bootdata(memory_end);
 int __bootdata(memory_end_set);
 int __bootdata(noexec_disabled);
 
+int vmalloc_size_set;
 int kaslr_enabled;
 
 static inline int __diag308(unsigned long subcode, void *addr)
@@ -242,8 +243,10 @@ void parse_boot_command_line(void)
                        memory_end_set = 1;
                }
 
-               if (!strcmp(param, "vmalloc") && val)
+               if (!strcmp(param, "vmalloc") && val) {
                        vmalloc_size = round_up(memparse(val, NULL), PAGE_SIZE);
+                       vmalloc_size_set = 1;
+               }
 
                if (!strcmp(param, "dfltcc") && val) {
                        if (!strcmp(val, "off"))
index cc96b04cc0ba736576b94b95f5a4b739cc9ef110..95d13a252ed9185792da6c55206b9089ee495701 100644 (file)
@@ -126,6 +126,21 @@ static void clear_bss_section(void)
        memset((void *)vmlinux.default_lma + vmlinux.image_size, 0, vmlinux.bss_size);
 }
 
+/*
+ * Set vmalloc area size to an 8th of (potential) physical memory
+ * size, unless size has been set by kernel command line parameter.
+ */
+static void setup_vmalloc_size(void)
+{
+       unsigned long size;
+
+       if (vmalloc_size_set)
+               return;
+       size = (memory_end ?: max_physmem_end) >> 3;
+       size = round_up(size, _SEGMENT_SIZE);
+       vmalloc_size = max(size, vmalloc_size);
+}
+
 void startup_kernel(void)
 {
        unsigned long random_lma;
@@ -142,6 +157,7 @@ void startup_kernel(void)
        parse_boot_command_line();
        setup_memory_end();
        detect_memory();
+       setup_vmalloc_size();
 
        random_lma = __kaslr_offset = 0;
        if (IS_ENABLED(CONFIG_RANDOMIZE_BASE) && kaslr_enabled) {