From: Mauricio Faria de Oliveira <hidden> Date: 2018-03-14 22:40:53
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 d8443ef (March 14).
Testcase and results sent as the last email in the series.
v3: add patch 4 to tell flush types are 'available' and not 'Using'.
remove plumbing patch.
v2: add plumbing patch between platforms and setup code to
force init fallback flush.
Mauricio Faria de Oliveira (1):
rfi-flush: Differentiate enabled and patched flush types
Michael Ellerman (4):
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: Always enable fallback flush on pseries
rfi-flush: Call setup_rfi_flush() after LPM migration
arch/powerpc/include/asm/setup.h | 2 +-
arch/powerpc/kernel/setup_64.c | 25 ++++++++++++++++---------
arch/powerpc/lib/feature-fixups.c | 9 ++++++++-
arch/powerpc/platforms/pseries/mobility.c | 3 +++
arch/powerpc/platforms/pseries/pseries.h | 2 ++
arch/powerpc/platforms/pseries/setup.c | 12 ++----------
6 files changed, 32 insertions(+), 21 deletions(-)
--
2.7.4
From: Mauricio Faria de Oliveira <hidden> Date: 2018-03-14 22:40:55
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 <redacted>
---
arch/powerpc/kernel/setup_64.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
@@ -902,13 +899,19 @@ void __init setup_rfi_flush(enum l1d_flush_type types, bool enable)#ifdef CONFIG_DEBUG_FSstaticintrfi_flush_set(void*data,u64val){+boolenable;+if(val==1)-rfi_flush_enable(true);+enable=true;elseif(val==0)-rfi_flush_enable(false);+enable=false;elsereturn-EINVAL;+/* Only do anything if we're changing state */+if(enable!=rfi_flush)+rfi_flush_enable(enable);+return0;}
From: Mauricio Faria de Oliveira <hidden> Date: 2018-03-14 22:40:59
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 <redacted>
---
arch/powerpc/include/asm/setup.h | 2 +-
arch/powerpc/kernel/setup_64.c | 6 +++++-
2 files changed, 6 insertions(+), 2 deletions(-)
@@ -860,6 +860,10 @@ static void init_fallback_flush(void)u64l1d_size,limit;intcpu;+/* 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);
From: Mauricio Faria de Oliveira <hidden> Date: 2018-03-14 22:41:00
From: Michael Ellerman <mpe@ellerman.id.au>
This ensures the fallback flush area is always allocated on pseries,
so in case a LPAR is migrated from a patched to an unpatched system,
it is possible to enable the fallback flush in the target system.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Mauricio Faria de Oliveira <redacted>
---
arch/powerpc/platforms/pseries/setup.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
@@ -468,26 +468,18 @@ static void pseries_setup_rfi_flush(void)/* Enable by default */enable=true;+types=L1D_FLUSH_FALLBACK;rc=plpar_get_cpu_characteristics(&result);if(rc==H_SUCCESS){-types=L1D_FLUSH_NONE;-if(result.character&H_CPU_CHAR_L1D_FLUSH_TRIG2)types|=L1D_FLUSH_MTTRIG;if(result.character&H_CPU_CHAR_L1D_FLUSH_ORI30)types|=L1D_FLUSH_ORI;-/* Use fallback if nothing set in hcall */-if(types==L1D_FLUSH_NONE)-types=L1D_FLUSH_FALLBACK;-if((!(result.behaviour&H_CPU_BEHAV_L1D_FLUSH_PR))||(!(result.behaviour&H_CPU_BEHAV_FAVOUR_SECURITY)))enable=false;-}else{-/* Default to fallback if case hcall is not available */-types=L1D_FLUSH_FALLBACK;}setup_rfi_flush(types,enable);
From: Mauricio Faria de Oliveira <hidden> Date: 2018-03-14 22:41:04
Currently the rfi-flush messages print 'Using <type> flush' for all
enabled_flush_types, but that is not necessarily true -- as now the
fallback flush is always enabled on pseries, but the fixup function
overwrites its nop/branch slot with other flush types, if available.
So, replace the 'Using <type> flush' messages with '<type> flush is
available'.
Also, print the patched flush types in the fixup function, so users
can know what is (not) being used (e.g., the slower, fallback flush,
or no flush type at all if flush is disabled via the debugfs switch).
Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Mauricio Faria de Oliveira <redacted>
---
P.S.: Michael, you suggested only hunk 1. please feel free to discard
hunk 2 if you don't like it.
arch/powerpc/kernel/setup_64.c | 6 +++---
arch/powerpc/lib/feature-fixups.c | 9 ++++++++-
2 files changed, 11 insertions(+), 4 deletions(-)
@@ -884,15 +884,15 @@ static void init_fallback_flush(void)voidsetup_rfi_flush(enuml1d_flush_typetypes,boolenable){if(types&L1D_FLUSH_FALLBACK){-pr_info("rfi-flush: Using fallback displacement flush\n");+pr_info("rfi-flush: fallback displacement flush available\n");init_fallback_flush();}if(types&L1D_FLUSH_ORI)-pr_info("rfi-flush: Using ori type flush\n");+pr_info("rfi-flush: ori type flush available\n");if(types&L1D_FLUSH_MTTRIG)-pr_info("rfi-flush: Using mttrig type flush\n");+pr_info("rfi-flush: mttrig type flush available\n");enabled_flush_types=types;
From: Mauricio Faria de Oliveira <hidden> Date: 2018-03-14 22:41:05
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 <redacted>
---
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(-)
@@ -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;}
@@ -326,6 +326,7 @@ int pseries_devicetree_update(s32 scope)voidpost_mobility_fixup(void){+#if 0intrc;intactivate_fw_token;
@@ -348,6 +349,7 @@ void post_mobility_fixup(void)printk(KERN_ERR"Post-mobility device tree update ""failed: %d\n",rc);+#endif/* Possibly switch to a new RFI flush type */pseries_setup_rfi_flush();
@@ -358,6 +360,7 @@ static ssize_t migration_store(struct class *class,structclass_attribute*attr,constchar*buf,size_tcount){+#if 0u64streamid;intrc;
@@ -374,6 +377,7 @@ static ssize_t migration_store(struct class *class,if(rc)returnrc;+#endifpost_mobility_fixup();returncount;}
On 03/14/2018 07:40 PM, Mauricio Faria de Oliveira wrote:
quoted hunk
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 <redacted>
---
arch/powerpc/kernel/setup_64.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
@@ -902,13 +899,19 @@ void __init setup_rfi_flush(enum l1d_flush_type types, bool enable)#ifdef CONFIG_DEBUG_FSstaticintrfi_flush_set(void*data,u64val){+boolenable;+if(val==1)-rfi_flush_enable(true);+enable=true;elseif(val==0)-rfi_flush_enable(false);+enable=false;elsereturn-EINVAL;+/* Only do anything if we're changing state */+if(enable!=rfi_flush)
Hi, Mauricio.
Do we need to take into account if no_rfi_flush == true?
if ((enable != rfi_flush) && !no_rfi_flush)
From: Michal Suchánek <hidden> Date: 2018-03-16 08:52:05
On Thu, 15 Mar 2018 17:36:00 -0300
Murilo Opsfelder Araujo [off-list ref] wrote:
On 03/14/2018 07:40 PM, Mauricio Faria de Oliveira wrote:
quoted
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
[off-list ref] ---
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
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)
Hi, Mauricio.
Do we need to take into account if no_rfi_flush == true?
I think it makes sense you are able to override that using debugfs.
It's interface used for diagnostics and testing.
If this was in sysfs it would be a different story.
Thanks
Michal
From: Mauricio Faria de Oliveira <hidden> Date: 2018-03-16 16:42:15
Hi Murilo and Michal,
On 03/16/2018 05:52 AM, Michal Suchánek wrote:
quoted
Do we need to take into account if no_rfi_flush == true?
I think it makes sense you are able to override that using debugfs.
It's interface used for diagnostics and testing.
If this was in sysfs it would be a different story.
Yes, I agree. The debugfs is way to override the cmdline option.
Thanks for looking carefully at this :)
cheers,
Mauricio
From: Michael Ellerman <hidden> Date: 2018-03-28 14:13:25
On Wed, 2018-03-14 at 22:40:38 UTC, Mauricio Faria de Oliveira wrote:
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 <redacted>