All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] Setup RFI flush after PowerVM LPM migration
@ 2018-03-12 23:02 Mauricio Faria de Oliveira
  2018-03-12 23:02 ` [PATCH v2 1/4] rfi-flush: Move the logic to avoid a redo into the debugfs code Mauricio Faria de Oliveira
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Mauricio Faria de Oliveira @ 2018-03-12 23:02 UTC (permalink / raw)
  To: linuxppc-dev, mpe, msuchanek

This patchset allows for setup_rfi_flush() to be called again
after PowerVM LPM (live partition mobility) aka LPAR migration,
in order to possibly switch to a different flush method.

The patches are mostly from Michael Ellerman, I have rebased to
powerpc/linux.git merge branch as of commit 249d7ba (March 12th),
and added one extra commit to force init of fallback flush area
on pseries.

Testing:
-------

I've disabled most code in the LPM functions migration_store()
and post_mobility_fixup() to just reach pseries_setup_rfi_flush(),
and modified pseries_setup_rfi_flush() a few times to fake the
first and non-first calls to either enable instructions or the
fallback flush method, to cover all 4 possible scenarios.

Case 1) fallback -> fallback

    # dmesg | grep rfi-flush
    [    0.000000] rfi-flush: Using fallback displacement flush
    [    0.000000] rfi-flush: patched 8 locations

    # echo > /sys/kernel/mobility/migration 

    # dmesg | grep rfi-flush
    [    0.000000] rfi-flush: Using fallback displacement flush
    [    0.000000] rfi-flush: patched 8 locations
    [   20.583029] rfi-flush: Using fallback displacement flush
    [   20.583038] rfi-flush: patched 8 locations

Case 2) instructions -> fallback

    # dmesg | grep rfi-flush
    [    0.000000] rfi-flush: Using ori type flush
    [    0.000000] rfi-flush: Using mttrig type flush
    [    0.000000] rfi-flush: patched 8 locations

    # echo > /sys/kernel/mobility/migration 

    # dmesg | grep rfi-flush
    [    0.000000] rfi-flush: Using ori type flush
    [    0.000000] rfi-flush: Using mttrig type flush
    [    0.000000] rfi-flush: patched 8 locations
    [   36.023759] rfi-flush: Using fallback displacement flush
    [   36.023764] rfi-flush: patched 8 locations

Case 3) fallback -> instructions

    # dmesg | grep rfi-flush
    [    0.000000] rfi-flush: Using fallback displacement flush
    [    0.000000] rfi-flush: patched 8 locations

    # echo > /sys/kernel/mobility/migration 

    # dmesg | grep rfi-flush
    [    0.000000] rfi-flush: Using fallback displacement flush
    [    0.000000] rfi-flush: patched 8 locations
    [   23.373037] rfi-flush: Using ori type flush
    [   23.373039] rfi-flush: Using mttrig type flush
    [   23.373044] rfi-flush: patched 8 locations

Case 4) instructions -> instructions

    # dmesg | grep rfi-flush
    [    0.000000] rfi-flush: Using ori type flush
    [    0.000000] rfi-flush: Using mttrig type flush
    [    0.000000] rfi-flush: patched 8 locations

    # echo > /sys/kernel/mobility/migration 

    # dmesg | grep rfi-flush
    [    0.000000] rfi-flush: Using ori type flush
    [    0.000000] rfi-flush: Using mttrig type flush
    [    0.000000] rfi-flush: patched 8 locations
    [   23.243564] rfi-flush: Using ori type flush
    [   23.243566] rfi-flush: Using mttrig type flush
    [   23.243570] rfi-flush: patched 8 locations


Mauricio Faria de Oliveira (1):
  rfi-flush: Allow pseries to force init of fallback flush area

Michael Ellerman (3):
  rfi-flush: Move the logic to avoid a redo into the debugfs code
  rfi-flush: Make it possible to call setup_rfi_flush() again
  rfi-flush: Call setup_rfi_flush() after LPM migration

 arch/powerpc/include/asm/setup.h          |  2 +-
 arch/powerpc/kernel/setup_64.c            | 22 +++++++++++++++-------
 arch/powerpc/platforms/powernv/setup.c    |  3 ++-
 arch/powerpc/platforms/pseries/mobility.c |  3 +++
 arch/powerpc/platforms/pseries/pseries.h  |  2 ++
 arch/powerpc/platforms/pseries/setup.c    |  6 +++---
 6 files changed, 26 insertions(+), 12 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/4] rfi-flush: Move the logic to avoid a redo into the debugfs code
  2018-03-12 23:02 [PATCH v2 0/4] Setup RFI flush after PowerVM LPM migration Mauricio Faria de Oliveira
@ 2018-03-12 23:02 ` Mauricio Faria de Oliveira
  2018-03-12 23:02 ` [PATCH v2 2/4] rfi-flush: Make it possible to call setup_rfi_flush() again Mauricio Faria de Oliveira
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Mauricio Faria de Oliveira @ 2018-03-12 23:02 UTC (permalink / raw)
  To: linuxppc-dev, mpe, msuchanek

From: Michael Ellerman <mpe@ellerman.id.au>

rfi_flush_enable() includes a check to see if we're already
enabled (or disabled), and in that case does nothing.

But that means calling setup_rfi_flush() a 2nd time doesn't actually
work, which is a bit confusing.

Move that check into the debugfs code, where it really belongs.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
---
 arch/powerpc/kernel/setup_64.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index c388cc3..3efc01a 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -846,9 +846,6 @@ static void do_nothing(void *unused)
 
 void rfi_flush_enable(bool enable)
 {
-	if (rfi_flush == enable)
-		return;
-
 	if (enable) {
 		do_rfi_flush_fixups(enabled_flush_types);
 		on_each_cpu(do_nothing, NULL, 1);
@@ -902,13 +899,19 @@ void __init setup_rfi_flush(enum l1d_flush_type types, bool enable)
 #ifdef CONFIG_DEBUG_FS
 static int rfi_flush_set(void *data, u64 val)
 {
+	bool enable;
+
 	if (val == 1)
-		rfi_flush_enable(true);
+		enable = true;
 	else if (val == 0)
-		rfi_flush_enable(false);
+		enable = false;
 	else
 		return -EINVAL;
 
+	/* Only do anything if we're changing state */
+	if (enable != rfi_flush)
+		rfi_flush_enable(enable);
+
 	return 0;
 }
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/4] rfi-flush: Make it possible to call setup_rfi_flush() again
  2018-03-12 23:02 [PATCH v2 0/4] Setup RFI flush after PowerVM LPM migration Mauricio Faria de Oliveira
  2018-03-12 23:02 ` [PATCH v2 1/4] rfi-flush: Move the logic to avoid a redo into the debugfs code Mauricio Faria de Oliveira
@ 2018-03-12 23:02 ` Mauricio Faria de Oliveira
  2018-03-12 23:02 ` [PATCH v2 3/4] rfi-flush: Allow pseries to force init of fallback flush area Mauricio Faria de Oliveira
  2018-03-12 23:02 ` [PATCH v2 4/4] rfi-flush: Call setup_rfi_flush() after LPM migration Mauricio Faria de Oliveira
  3 siblings, 0 replies; 5+ messages in thread
From: Mauricio Faria de Oliveira @ 2018-03-12 23:02 UTC (permalink / raw)
  To: linuxppc-dev, mpe, msuchanek

From: Michael Ellerman <mpe@ellerman.id.au>

For PowerVM migration we want to be able to call setup_rfi_flush()
again after we've migrated the partition.

To support that we need to check that we're not trying to allocate the
fallback flush area after memblock has gone away (i.e., boot-time only).

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
---
 arch/powerpc/include/asm/setup.h | 2 +-
 arch/powerpc/kernel/setup_64.c   | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/setup.h b/arch/powerpc/include/asm/setup.h
index 469b7fd..bbcdf929 100644
--- a/arch/powerpc/include/asm/setup.h
+++ b/arch/powerpc/include/asm/setup.h
@@ -49,7 +49,7 @@ enum l1d_flush_type {
 	L1D_FLUSH_MTTRIG	= 0x8,
 };
 
-void __init setup_rfi_flush(enum l1d_flush_type, bool enable);
+void setup_rfi_flush(enum l1d_flush_type, bool enable);
 void do_rfi_flush_fixups(enum l1d_flush_type types);
 
 #endif /* !__ASSEMBLY__ */
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 3efc01a..d60e2f7 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -860,6 +860,10 @@ static void init_fallback_flush(void)
 	u64 l1d_size, limit;
 	int cpu;
 
+	/* Only allocate the fallback flush area once (at boot time). */
+	if (l1d_flush_fallback_area)
+		return;
+
 	l1d_size = ppc64_caches.l1d.size;
 	limit = min(ppc64_bolted_size(), ppc64_rma_size);
 
@@ -877,7 +881,7 @@ static void init_fallback_flush(void)
 	}
 }
 
-void __init setup_rfi_flush(enum l1d_flush_type types, bool enable)
+void setup_rfi_flush(enum l1d_flush_type types, bool enable)
 {
 	if (types & L1D_FLUSH_FALLBACK) {
 		pr_info("rfi-flush: Using fallback displacement flush\n");
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 3/4] rfi-flush: Allow pseries to force init of fallback flush area
  2018-03-12 23:02 [PATCH v2 0/4] Setup RFI flush after PowerVM LPM migration Mauricio Faria de Oliveira
  2018-03-12 23:02 ` [PATCH v2 1/4] rfi-flush: Move the logic to avoid a redo into the debugfs code Mauricio Faria de Oliveira
  2018-03-12 23:02 ` [PATCH v2 2/4] rfi-flush: Make it possible to call setup_rfi_flush() again Mauricio Faria de Oliveira
@ 2018-03-12 23:02 ` Mauricio Faria de Oliveira
  2018-03-12 23:02 ` [PATCH v2 4/4] rfi-flush: Call setup_rfi_flush() after LPM migration Mauricio Faria de Oliveira
  3 siblings, 0 replies; 5+ messages in thread
From: Mauricio Faria de Oliveira @ 2018-03-12 23:02 UTC (permalink / raw)
  To: linuxppc-dev, mpe, msuchanek

This ensures the fallback flush area is always allocated at boot time
on the pseries platform, so PowerVM migration to an unpatched system
can rely on the fallback flush method.

Signed-off-by: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
---
 arch/powerpc/include/asm/setup.h       | 2 +-
 arch/powerpc/kernel/setup_64.c         | 5 +++--
 arch/powerpc/platforms/powernv/setup.c | 3 ++-
 arch/powerpc/platforms/pseries/setup.c | 4 ++--
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/include/asm/setup.h b/arch/powerpc/include/asm/setup.h
index bbcdf929..efdaf10 100644
--- a/arch/powerpc/include/asm/setup.h
+++ b/arch/powerpc/include/asm/setup.h
@@ -49,7 +49,7 @@ enum l1d_flush_type {
 	L1D_FLUSH_MTTRIG	= 0x8,
 };
 
-void setup_rfi_flush(enum l1d_flush_type, bool enable);
+void setup_rfi_flush(enum l1d_flush_type, bool enable, bool force_init_fallback);
 void do_rfi_flush_fixups(enum l1d_flush_type types);
 
 #endif /* !__ASSEMBLY__ */
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index d60e2f7..cb886a8 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -881,12 +881,13 @@ static void init_fallback_flush(void)
 	}
 }
 
-void setup_rfi_flush(enum l1d_flush_type types, bool enable)
+void setup_rfi_flush(enum l1d_flush_type types, bool enable, bool force_init_fallback)
 {
 	if (types & L1D_FLUSH_FALLBACK) {
 		pr_info("rfi-flush: Using fallback displacement flush\n");
 		init_fallback_flush();
-	}
+	} else if (force_init_fallback)
+		init_fallback_flush();
 
 	if (types & L1D_FLUSH_ORI)
 		pr_info("rfi-flush: Using ori type flush\n");
diff --git a/arch/powerpc/platforms/powernv/setup.c b/arch/powerpc/platforms/powernv/setup.c
index 092715b..a4ab8f6 100644
--- a/arch/powerpc/platforms/powernv/setup.c
+++ b/arch/powerpc/platforms/powernv/setup.c
@@ -46,6 +46,7 @@ static void pnv_setup_rfi_flush(void)
 	struct device_node *np, *fw_features;
 	enum l1d_flush_type type;
 	int enable;
+	bool force_init_fallback = false;
 
 	/* Default to fallback in case fw-features are not available */
 	type = L1D_FLUSH_FALLBACK;
@@ -88,7 +89,7 @@ static void pnv_setup_rfi_flush(void)
 		of_node_put(fw_features);
 	}
 
-	setup_rfi_flush(type, enable > 0);
+	setup_rfi_flush(type, enable > 0, force_init_fallback);
 }
 
 static void __init pnv_setup_arch(void)
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index 1a52762..2f82bbb 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -463,7 +463,7 @@ static void pseries_setup_rfi_flush(void)
 {
 	struct h_cpu_char_result result;
 	enum l1d_flush_type types;
-	bool enable;
+	bool enable, force_init_fallback = true;
 	long rc;
 
 	/* Enable by default */
@@ -490,7 +490,7 @@ static void pseries_setup_rfi_flush(void)
 		types = L1D_FLUSH_FALLBACK;
 	}
 
-	setup_rfi_flush(types, enable);
+	setup_rfi_flush(types, enable, force_init_fallback);
 }
 
 #ifdef CONFIG_PCI_IOV
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 4/4] rfi-flush: Call setup_rfi_flush() after LPM migration
  2018-03-12 23:02 [PATCH v2 0/4] Setup RFI flush after PowerVM LPM migration Mauricio Faria de Oliveira
                   ` (2 preceding siblings ...)
  2018-03-12 23:02 ` [PATCH v2 3/4] rfi-flush: Allow pseries to force init of fallback flush area Mauricio Faria de Oliveira
@ 2018-03-12 23:02 ` Mauricio Faria de Oliveira
  3 siblings, 0 replies; 5+ messages in thread
From: Mauricio Faria de Oliveira @ 2018-03-12 23:02 UTC (permalink / raw)
  To: linuxppc-dev, mpe, msuchanek

From: Michael Ellerman <mpe@ellerman.id.au>

We might have migrated to a machine that uses a different flush type,
or doesn't need flushing at all.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
---
 arch/powerpc/platforms/pseries/mobility.c | 3 +++
 arch/powerpc/platforms/pseries/pseries.h  | 2 ++
 arch/powerpc/platforms/pseries/setup.c    | 2 +-
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/pseries/mobility.c b/arch/powerpc/platforms/pseries/mobility.c
index 0f7fb71..8a8033a 100644
--- a/arch/powerpc/platforms/pseries/mobility.c
+++ b/arch/powerpc/platforms/pseries/mobility.c
@@ -348,6 +348,9 @@ void post_mobility_fixup(void)
 		printk(KERN_ERR "Post-mobility device tree update "
 			"failed: %d\n", rc);
 
+	/* Possibly switch to a new RFI flush type */
+	pseries_setup_rfi_flush();
+
 	return;
 }
 
diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platforms/pseries/pseries.h
index 1ae1d9f..27cdcb6 100644
--- a/arch/powerpc/platforms/pseries/pseries.h
+++ b/arch/powerpc/platforms/pseries/pseries.h
@@ -100,4 +100,6 @@ static inline unsigned long cmo_get_page_size(void)
 
 int dlpar_workqueue_init(void);
 
+void pseries_setup_rfi_flush(void);
+
 #endif /* _PSERIES_PSERIES_H */
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index 2f82bbb..360efe7 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -459,7 +459,7 @@ static void __init find_and_init_phbs(void)
 	of_pci_check_probe_only();
 }
 
-static void pseries_setup_rfi_flush(void)
+void pseries_setup_rfi_flush(void)
 {
 	struct h_cpu_char_result result;
 	enum l1d_flush_type types;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-03-12 23:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-12 23:02 [PATCH v2 0/4] Setup RFI flush after PowerVM LPM migration Mauricio Faria de Oliveira
2018-03-12 23:02 ` [PATCH v2 1/4] rfi-flush: Move the logic to avoid a redo into the debugfs code Mauricio Faria de Oliveira
2018-03-12 23:02 ` [PATCH v2 2/4] rfi-flush: Make it possible to call setup_rfi_flush() again Mauricio Faria de Oliveira
2018-03-12 23:02 ` [PATCH v2 3/4] rfi-flush: Allow pseries to force init of fallback flush area Mauricio Faria de Oliveira
2018-03-12 23:02 ` [PATCH v2 4/4] rfi-flush: Call setup_rfi_flush() after LPM migration Mauricio Faria de Oliveira

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.