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, gromero@linux.vnet.ibm.com,
	Breno Leitao <leitao@debian.org>,
	ldufour@linux.vnet.ibm.com, cyrilbur@gmail.com
Subject: [RFC PATCH 08/14] powerpc/tm: Recheckpoint at exit path
Date: Tue,  6 Nov 2018 10:40:22 -0200	[thread overview]
Message-ID: <1541508028-31865-9-git-send-email-leitao@debian.org> (raw)
In-Reply-To: <1541508028-31865-1-git-send-email-leitao@debian.org>

In the past, TIF_RESTORE_TM was being handled with the rest of the TIF workers,
but, that was too early, and can cause some IRQ to be replayed in suspended
state (after recheckpoint).

This patch moves TIF_RESTORE_TM handler to as late as possible, it also
forces the IRQ to be disabled, and it will continue to be until RFID, so,
no IRQ will be replayed at all. I.e, if trecheckpoint happens, it will RFID
to userspace.

This makes TIF_RESTORE_TM a special case that should not be handled
similarly to the _TIF_USER_WORK_MASK.

Since _TIF_RESTORE_TM is not part of _TIF_USER_WORK_MASK anymore, we
need to force system_call_exit to continue to leaves through
fast_exception_return, so, we add the flags together with
_TIF_USER_WORK_MASK at system_call_exist path.

If this flag is set at system_call_exit, it means that recheckpoint
will be called, and doing it through fast_exception_return is the only
way to do so.

Signed-off-by: Breno Leitao <leitao@debian.org>
---
 arch/powerpc/include/asm/thread_info.h |  2 +-
 arch/powerpc/kernel/entry_64.S         | 23 ++++++++++++++---------
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
index 544cac0474cb..2835d60bc9ef 100644
--- a/arch/powerpc/include/asm/thread_info.h
+++ b/arch/powerpc/include/asm/thread_info.h
@@ -139,7 +139,7 @@ void arch_setup_new_exec(void);
 
 #define _TIF_USER_WORK_MASK	(_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
 				 _TIF_NOTIFY_RESUME | _TIF_UPROBE | \
-				 _TIF_RESTORE_TM | _TIF_PATCH_PENDING | \
+				 _TIF_PATCH_PENDING | \
 				 _TIF_FSCHECK)
 #define _TIF_PERSYSCALL_MASK	(_TIF_RESTOREALL|_TIF_NOERROR)
 
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 17484ebda66c..a86619edf29d 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -255,7 +255,7 @@ system_call_exit:
 
 	ld	r9,TI_FLAGS(r12)
 	li	r11,-MAX_ERRNO
-	andi.	r0,r9,(_TIF_SYSCALL_DOTRACE|_TIF_SINGLESTEP|_TIF_USER_WORK_MASK|_TIF_PERSYSCALL_MASK)
+	andi.   r0,r9,(_TIF_SYSCALL_DOTRACE|_TIF_SINGLESTEP|_TIF_USER_WORK_MASK|_TIF_PERSYSCALL_MASK |_TIF_RESTORE_TM)
 	bne-	.Lsyscall_exit_work
 
 	andi.	r0,r8,MSR_FP
@@ -784,14 +784,6 @@ _GLOBAL(ret_from_except_lite)
 	SCHEDULE_USER
 	b	ret_from_except_lite
 2:
-#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
-	andi.	r0,r4,_TIF_USER_WORK_MASK & ~_TIF_RESTORE_TM
-	bne	3f		/* only restore TM if nothing else to do */
-	addi	r3,r1,STACK_FRAME_OVERHEAD
-	bl	restore_tm_state
-	b	restore
-3:
-#endif
 	bl	save_nvgprs
 	/*
 	 * Use a non volatile GPR to save and restore our thread_info flags
@@ -938,6 +930,19 @@ ALT_FTR_SECTION_END_IFCLR(CPU_FTR_STCX_CHECKS_ADDRESS)
 	 */
 	.globl	fast_exception_return
 fast_exception_return:
+
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+	CURRENT_THREAD_INFO(r4, r1)
+	ld	r4,TI_FLAGS(r4)
+	andi.   r0,r4,_TIF_RESTORE_TM
+	beq	22f
+	ld	r4,_MSR(r1) 	/* TODO: MSR[!PR] shouldn't be here */
+	andi.	r0,r4,MSR_PR
+	beq	22f  /* Skip if Kernel thread */
+	addi	r3,r1,STACK_FRAME_OVERHEAD
+	bl	restore_tm_state
+22:
+#endif
 	ld	r3,_MSR(r1)
 	ld	r4,_CTR(r1)
 	ld	r0,_LINK(r1)
-- 
2.19.0


  parent reply	other threads:[~2018-11-06 13:09 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-06 12:40 [RFC PATCH v2 00/14] New TM Model Breno Leitao
2018-11-06 12:40 ` [RFC PATCH 01/14] powerpc/tm: Reclaim transaction on kernel entry Breno Leitao
2018-11-15  0:06   ` Michael Neuling
2018-11-15  0:51   ` Nicholas Piggin
2018-11-06 12:40 ` [RFC PATCH 02/14] powerpc/tm: Reclaim on unavailable exception Breno Leitao
2018-11-15  0:06   ` Michael Neuling
2018-11-06 12:40 ` [RFC PATCH 03/14] powerpc/tm: Recheckpoint when exiting from kernel Breno Leitao
2018-11-15  0:11   ` Michael Neuling
2018-11-06 12:40 ` [RFC PATCH 04/14] powerpc/tm: Always set TIF_RESTORE_TM on reclaim Breno Leitao
2018-11-06 12:40 ` [RFC PATCH 05/14] powerpc/tm: Refactor the __switch_to_tm code Breno Leitao
2018-11-15  1:04   ` Michael Neuling
2018-11-06 12:40 ` [RFC PATCH 06/14] powerpc/tm: Do not recheckpoint at sigreturn Breno Leitao
2018-11-06 12:40 ` [RFC PATCH 07/14] powerpc/tm: Do not reclaim on ptrace Breno Leitao
2018-11-06 12:40 ` Breno Leitao [this message]
2018-11-15  2:45   ` [RFC PATCH 08/14] powerpc/tm: Recheckpoint at exit path Michael Neuling
2018-11-06 12:40 ` [RFC PATCH 09/14] powerpc/tm: Warn if state is transactional Breno Leitao
2018-11-15  2:48   ` Michael Neuling
2018-11-06 12:40 ` [RFC PATCH 10/14] powerpc/tm: Improve TM debug information Breno Leitao
2018-11-06 12:40 ` [RFC PATCH 11/14] powerpc/tm: Save MSR to PACA before RFID Breno Leitao
2018-11-06 12:40 ` [RFC PATCH 12/14] powerpc/tm: Restore transactional SPRs Breno Leitao
2018-11-06 12:40 ` [RFC PATCH 13/14] powerpc/tm: Do not restore TM without SPRs Breno Leitao
2018-11-15  3:02   ` Michael Neuling
2018-11-06 12:40 ` [RFC PATCH 14/14] selftests/powerpc: Adapt tm-syscall test to no suspend Breno Leitao
2018-11-06 18:32 ` [RFC PATCH v2 00/14] New TM Model Florian Weimer
2018-11-06 19:31   ` Breno Leitao
2018-11-07  0:39     ` Michael Neuling

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=1541508028-31865-9-git-send-email-leitao@debian.org \
    --to=leitao@debian.org \
    --cc=cyrilbur@gmail.com \
    --cc=gromero@linux.vnet.ibm.com \
    --cc=ldufour@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mikey@neuling.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).