powerpc/pseries: Use H_CLEAR_HPT to clear MMU hash table during kexec
authorAnton Blanchard <anton@samba.org>
Sat, 1 Oct 2016 10:41:56 +0000 (20:41 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 14 Nov 2016 00:11:51 +0000 (11:11 +1100)
An hcall was recently added that does exactly what we need during kexec
- it clears the entire MMU hash table, ignoring any VRMA mappings.

Try it and fall back to the old method if we get a failure.

On a POWER8 box with 5TB of memory, this reduces the time it takes to
kexec a new kernel from from 4 minutes to 1 minute.

Signed-off-by: Anton Blanchard <anton@samba.org>
Tested-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
[mpe: Split into separate functions and tweak function naming]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/hvcall.h
arch/powerpc/platforms/pseries/lpar.c

index 708edebcf14746d86bac457b110ab5710c63d32c..489748ed21b45a9d0eec744740e81bc0d59894c3 100644 (file)
 #define H_COP                  0x304
 #define H_GET_MPP_X            0x314
 #define H_SET_MODE             0x31C
-#define MAX_HCALL_OPCODE       H_SET_MODE
+#define H_CLEAR_HPT            0x358
+#define MAX_HCALL_OPCODE       H_CLEAR_HPT
 
 /* H_VIOCTL functions */
 #define H_GET_VIOA_DUMP_SIZE   0x01
index aa35245d8d6d337204806bbb5888e9df4d5455ef..24ad43afbb46bfba6a84e7bc1e924abda4478786 100644 (file)
@@ -221,7 +221,7 @@ static long pSeries_lpar_hpte_remove(unsigned long hpte_group)
        return -1;
 }
 
-static void pSeries_lpar_hptab_clear(void)
+static void manual_hpte_clear_all(void)
 {
        unsigned long size_bytes = 1UL << ppc64_pft_size;
        unsigned long hpte_count = size_bytes >> 4;
@@ -249,6 +249,26 @@ static void pSeries_lpar_hptab_clear(void)
                                        &(ptes[j].pteh), &(ptes[j].ptel));
                }
        }
+}
+
+static int hcall_hpte_clear_all(void)
+{
+       int rc;
+
+       do {
+               rc = plpar_hcall_norets(H_CLEAR_HPT);
+       } while (rc == H_CONTINUE);
+
+       return rc;
+}
+
+static void pseries_hpte_clear_all(void)
+{
+       int rc;
+
+       rc = hcall_hpte_clear_all();
+       if (rc != H_SUCCESS)
+               manual_hpte_clear_all();
 
 #ifdef __LITTLE_ENDIAN__
        /*
@@ -598,7 +618,7 @@ void __init hpte_init_pseries(void)
        mmu_hash_ops.hpte_remove         = pSeries_lpar_hpte_remove;
        mmu_hash_ops.hpte_removebolted   = pSeries_lpar_hpte_removebolted;
        mmu_hash_ops.flush_hash_range    = pSeries_lpar_flush_hash_range;
-       mmu_hash_ops.hpte_clear_all      = pSeries_lpar_hptab_clear;
+       mmu_hash_ops.hpte_clear_all      = pseries_hpte_clear_all;
        mmu_hash_ops.hugepage_invalidate = pSeries_lpar_hugepage_invalidate;
 }