linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Breno Leitao <leitao@debian.org>
To: linuxppc-dev@lists.ozlabs.org
Cc: mikey@neuling.org, paulus@ozlabs.org, gromero@linux.vnet.ibm.com,
	mpe@ellerman.id.au, ldufour@linux.vnet.ibm.com,
	Breno Leitao <leitao@debian.org>
Subject: [RFC PATCH 02/11] powerpc/tm: Reclaim on unavailable exception
Date: Wed, 12 Sep 2018 16:40:10 -0300	[thread overview]
Message-ID: <1536781219-13938-3-git-send-email-leitao@debian.org> (raw)
In-Reply-To: <1536781219-13938-1-git-send-email-leitao@debian.org>

If there is a FP/VEC/Altivec touch inside a transaction and the facility is
disabled, then a facility unavailable exception is raised and ends up
calling {fp,vec,vsx}_unavailable_tm, which was reclaiming and recheckpointing.

This is not required anymore, since the checkpointed state was reclaimed in
the trap entrace itself, and it will be recheckpointed by restore_tm_state
later.

With this new patchset, we only reclaim at exception entrance (except at
syscall level if the transaction is suspended), and always recheckpoint on
restore_tm_state.

Adding a WARN_ON() warning if we hit the _unavailable_tm() in suspended
mode, i.e, the reclaim was not executed somehow in the trap entrance.

Signed-off-by: Breno Leitao <leitao@debian.org>
---
 arch/powerpc/kernel/exceptions-64s.S |  3 +++
 arch/powerpc/kernel/traps.c          | 16 ++++------------
 2 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index 78aba71a4b2d..4108f3944bdd 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -874,6 +874,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_TM)
 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
 2:	/* User process was in a transaction */
 	bl	save_nvgprs
+	TM_KERNEL_ENTRY(TM_CAUSE_FAC_UNAV)
 	RECONCILE_IRQ_STATE(r10, r11)
 	addi	r3,r1,STACK_FRAME_OVERHEAD
 	bl	fp_unavailable_tm
@@ -1216,6 +1217,7 @@ BEGIN_FTR_SECTION
 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
 2:	/* User process was in a transaction */
 	bl	save_nvgprs
+	TM_KERNEL_ENTRY(TM_CAUSE_FAC_UNAV)
 	RECONCILE_IRQ_STATE(r10, r11)
 	addi	r3,r1,STACK_FRAME_OVERHEAD
 	bl	altivec_unavailable_tm
@@ -1252,6 +1254,7 @@ BEGIN_FTR_SECTION
 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
 2:	/* User process was in a transaction */
 	bl	save_nvgprs
+	TM_KERNEL_ENTRY(TM_CAUSE_FAC_UNAV)
 	RECONCILE_IRQ_STATE(r10, r11)
 	addi	r3,r1,STACK_FRAME_OVERHEAD
 	bl	vsx_unavailable_tm
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index c85adb858271..b973fdb72826 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -1749,19 +1749,12 @@ void fp_unavailable_tm(struct pt_regs *regs)
          * transaction, and probably retry but now with FP enabled.  So the
          * checkpointed FP registers need to be loaded.
 	 */
-	tm_reclaim_current(TM_CAUSE_FAC_UNAV);
+	WARN_ON(MSR_TM_SUSPENDED(mfmsr()));
 	/* Reclaim didn't save out any FPRs to transact_fprs. */
 
 	/* Enable FP for the task: */
 	current->thread.load_fp = 1;
 
-	/* This loads and recheckpoints the FP registers from
-	 * thread.fpr[].  They will remain in registers after the
-	 * checkpoint so we don't need to reload them after.
-	 * If VMX is in use, the VRs now hold checkpointed values,
-	 * so we don't want to load the VRs from the thread_struct.
-	 */
-	tm_recheckpoint(&current->thread);
 }
 
 void altivec_unavailable_tm(struct pt_regs *regs)
@@ -1773,10 +1766,10 @@ void altivec_unavailable_tm(struct pt_regs *regs)
 	TM_DEBUG("Vector Unavailable trap whilst transactional at 0x%lx,"
 		 "MSR=%lx\n",
 		 regs->nip, regs->msr);
-	tm_reclaim_current(TM_CAUSE_FAC_UNAV);
+	WARN_ON(MSR_TM_SUSPENDED(mfmsr()));
 	current->thread.load_vec = 1;
-	tm_recheckpoint(&current->thread);
 	current->thread.used_vr = 1;
+
 }
 
 void vsx_unavailable_tm(struct pt_regs *regs)
@@ -1795,12 +1788,11 @@ void vsx_unavailable_tm(struct pt_regs *regs)
 	current->thread.used_vsr = 1;
 
 	/* This reclaims FP and/or VR regs if they're already enabled */
-	tm_reclaim_current(TM_CAUSE_FAC_UNAV);
+	WARN_ON(MSR_TM_SUSPENDED(mfmsr()));
 
 	current->thread.load_vec = 1;
 	current->thread.load_fp = 1;
 
-	tm_recheckpoint(&current->thread);
 }
 #endif /* CONFIG_PPC_TRANSACTIONAL_MEM */
 
-- 
2.19.0

  parent reply	other threads:[~2018-09-12 19:40 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-12 19:40 [RFC PATCH 00/11] New TM Model Breno Leitao
2018-09-12 19:40 ` [RFC PATCH 01/11] powerpc/tm: Reclaim transaction on kernel entry Breno Leitao
2018-09-18  1:31   ` Michael Neuling
2018-09-27 20:28     ` Breno Leitao
2018-09-27 20:28       ` Breno Leitao
2018-09-12 19:40 ` Breno Leitao [this message]
2018-09-12 19:40 ` [RFC PATCH 03/11] powerpc/tm: Recheckpoint when exiting from kernel Breno Leitao
2018-09-12 19:40 ` [RFC PATCH 04/11] powerpc/tm: Always set TIF_RESTORE_TM on reclaim Breno Leitao
2018-09-12 19:40 ` [RFC PATCH 05/11] powerpc/tm: Function that updates the failure code Breno Leitao
2018-09-17  5:29   ` Michael Neuling
2018-09-18  1:29   ` Michael Neuling
2018-09-27 20:58     ` Breno Leitao
2018-09-28  5:27       ` Michael Neuling
2018-09-18  3:27   ` Michael Neuling
2018-09-12 19:40 ` [RFC PATCH 06/11] powerpc/tm: Refactor the __switch_to_tm code Breno Leitao
2018-09-18  4:04   ` Michael Neuling
2018-09-27 20:48     ` Breno Leitao
2018-09-12 19:40 ` [RFC PATCH 07/11] powerpc/tm: Do not recheckpoint at sigreturn Breno Leitao
2018-09-18  5:32   ` Michael Neuling
2018-09-12 19:40 ` [RFC PATCH 08/11] powerpc/tm: Do not reclaim on ptrace Breno Leitao
2018-09-18  5:36   ` Michael Neuling
2018-09-27 21:03     ` Breno Leitao
2018-09-28  5:36       ` Michael Neuling
2018-09-30 23:51         ` Breno Leitao
2018-10-01  0:34           ` Michael Neuling
2018-09-12 19:40 ` [RFC PATCH 09/11] powerpc/tm: Do not restore default DSCR Breno Leitao
2018-09-18  5:41   ` Michael Neuling
2018-09-27 20:51     ` Breno Leitao
2018-09-28  5:03       ` Michael Neuling
2018-09-12 19:40 ` [RFC PATCH 10/11] powerpc/tm: Set failure summary Breno Leitao
2018-09-18  5:50   ` Michael Neuling
2018-09-27 20:52     ` Breno Leitao
2018-09-28  5:17       ` Michael Neuling
2018-09-12 19:40 ` [RFC PATCH 11/11] selftests/powerpc: Adapt the test Breno Leitao
2018-09-18  6:36   ` Michael Neuling
2018-09-27 20:57     ` Breno Leitao
2018-09-28  5:25       ` Michael Neuling
2018-10-01 17:50         ` Breno Leitao
2018-09-17  5:25 ` [RFC PATCH 00/11] New TM Model Michael Neuling
2018-09-27 20:13   ` Breno Leitao
2018-09-27 20:13     ` Breno Leitao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1536781219-13938-3-git-send-email-leitao@debian.org \
    --to=leitao@debian.org \
    --cc=gromero@linux.vnet.ibm.com \
    --cc=ldufour@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mikey@neuling.org \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).