diff options
author | Vasily Gorbik <gor@linux.ibm.com> | 2018-04-11 19:15:24 +0200 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2018-10-09 11:21:12 +0200 |
commit | 54c57795e848100a2502b7a39b12b784292f4576 (patch) | |
tree | ae93ff66373017b80bbeecd2bc74aa5e04746246 /arch/s390/boot | |
parent | cd45c995610420755c5fe0d09afee3106c586e26 (diff) | |
download | linux-54c57795e848100a2502b7a39b12b784292f4576.tar.bz2 |
s390/mem_detect: replace tprot loop with binary search
In a situation when other memory detection methods are not available
(no SCLP and no z/VM diag260), continuous online memory is assumed.
Replacing tprot loop with faster binary search, as only online memory
end has to be found.
Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Reviewed-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390/boot')
-rw-r--r-- | arch/s390/boot/mem_detect.c | 49 |
1 files changed, 17 insertions, 32 deletions
diff --git a/arch/s390/boot/mem_detect.c b/arch/s390/boot/mem_detect.c index 3becf6bbe4c7..65ae3c926042 100644 --- a/arch/s390/boot/mem_detect.c +++ b/arch/s390/boot/mem_detect.c @@ -3,12 +3,10 @@ #include <asm/sclp.h> #include <asm/sections.h> #include <asm/mem_detect.h> +#include <asm/sparsemem.h> #include "compressed/decompressor.h" #include "boot.h" -#define CHUNK_READ_WRITE 0 -#define CHUNK_READ_ONLY 1 - unsigned long __bootdata(max_physmem_end); struct mem_detect_info __bootdata(mem_detect); @@ -141,38 +139,25 @@ static int tprot(unsigned long addr) return rc; } -static void scan_memory(unsigned long rzm) +static void search_mem_end(void) { - unsigned long addr, size; - int type; - - if (!rzm) - rzm = 1UL << 20; - - addr = 0; - do { - size = 0; - /* assume lowcore is writable */ - type = addr ? tprot(addr) : CHUNK_READ_WRITE; - do { - size += rzm; - if (max_physmem_end && addr + size >= max_physmem_end) - break; - } while (type == tprot(addr + size)); - if (type == CHUNK_READ_WRITE || type == CHUNK_READ_ONLY) { - if (max_physmem_end && (addr + size > max_physmem_end)) - size = max_physmem_end - addr; - add_mem_detect_block(addr, addr + size); - } - addr += size; - } while (addr < max_physmem_end); + unsigned long range = 1 << (MAX_PHYSMEM_BITS - 20); /* in 1MB blocks */ + unsigned long offset = 0; + unsigned long pivot; + + while (range > 1) { + range >>= 1; + pivot = offset + range; + if (!tprot(pivot << 20)) + offset = pivot; + } + + add_mem_detect_block(0, (offset + 1) << 20); } void detect_memory(void) { - unsigned long rzm; - - sclp_early_get_meminfo(&max_physmem_end, &rzm); + sclp_early_get_memsize(&max_physmem_end); if (!sclp_early_read_storage_info()) { mem_detect.info_source = MEM_DETECT_SCLP_STOR_INFO; @@ -190,7 +175,7 @@ void detect_memory(void) return; } - scan_memory(rzm); - mem_detect.info_source = MEM_DETECT_TPROT_LOOP; + search_mem_end(); + mem_detect.info_source = MEM_DETECT_BIN_SEARCH; max_physmem_end = get_mem_detect_end(); } |