Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1459115
| Path | csiph.com!goblin2!goblin.stu.neva.ru!gothmog.csi.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Chris Metcalf <cmetcalf@mellanox.com> |
| Newsgroups | linux.kernel |
| Subject | [PATCH v14 07/14] arm64: factor work_pending state machine to C |
| Date | Tue, 09 Aug 2016 22:40:02 +0200 |
| Message-ID | <s4lYC-3WM-27@gated-at.bofh.it> (permalink) |
| References | <s4lYB-3WM-3@gated-at.bofh.it> |
| X-Original-To | Gilad Ben Yossef <giladb@mellanox.com>, Steven Rostedt <rostedt@goodmis.org>, Ingo Molnar <mingo@kernel.org>, Peter Zijlstra <peterz@infradead.org>, Andrew Morton <akpm@linux-foundation.org>, Rik van Riel <riel@redhat.com>, Tejun Heo <tj@kernel.org>, Frederic Weisbecker <fweisbec@gmail.com>, Thomas Gleixner <tglx@linutronix.de>, "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>, Christoph Lameter <cl@linux.com>, Viresh Kumar <viresh.kumar@linaro.org>, Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will.deacon@arm.com>, Andy Lutomirski <luto@amacapital.net>, Mark Rutland <mark.rutland@arm.com>, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org |
| X-Mailer | git-send-email 2.7.2 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 104 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | Chris Metcalf <cmetcalf@mellanox.com> |
| X-Original-Date | Tue, 9 Aug 2016 16:29:49 -0400 |
| X-Original-Message-ID | <1470774596-17341-8-git-send-email-cmetcalf@mellanox.com> |
| X-Original-References | <1470774596-17341-1-git-send-email-cmetcalf@mellanox.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1459115 |
Show key headers only | View raw
Currently ret_fast_syscall, work_pending, and ret_to_user form an ad-hoc
state machine that can be difficult to reason about due to duplicated
code and a large number of branch targets.
This patch factors the common logic out into the existing
do_notify_resume function, converting the code to C in the process,
making the code more legible.
This patch tries to closely mirror the existing behaviour while using
the usual C control flow primitives. As local_irq_{disable,enable} may
be instrumented, we balance exception entry (where we will almost most
likely enable IRQs) with a call to trace_hardirqs_on just before the
return to userspace.
Signed-off-by: Chris Metcalf <cmetcalf@mellanox.com>
---
(Note: Will Deacon has said he will look at queueing this separately for 4.9)
arch/arm64/kernel/entry.S | 12 ++++--------
arch/arm64/kernel/signal.c | 36 ++++++++++++++++++++++++++----------
2 files changed, 30 insertions(+), 18 deletions(-)
diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
index 96e4a2b64cc1..4af25bb7f116 100644
--- a/arch/arm64/kernel/entry.S
+++ b/arch/arm64/kernel/entry.S
@@ -700,18 +700,13 @@ ret_fast_syscall_trace:
* Ok, we need to do extra processing, enter the slow path.
*/
work_pending:
- tbnz x1, #TIF_NEED_RESCHED, work_resched
- /* TIF_SIGPENDING, TIF_NOTIFY_RESUME or TIF_FOREIGN_FPSTATE case */
mov x0, sp // 'regs'
- enable_irq // enable interrupts for do_notify_resume()
bl do_notify_resume
- b ret_to_user
-work_resched:
#ifdef CONFIG_TRACE_IRQFLAGS
- bl trace_hardirqs_off // the IRQs are off here, inform the tracing code
+ bl trace_hardirqs_on // enabled while in userspace
#endif
- bl schedule
-
+ ldr x1, [tsk, #TI_FLAGS] // re-check for single-step
+ b finish_ret_to_user
/*
* "slow" syscall return path.
*/
@@ -720,6 +715,7 @@ ret_to_user:
ldr x1, [tsk, #TI_FLAGS]
and x2, x1, #_TIF_WORK_MASK
cbnz x2, work_pending
+finish_ret_to_user:
enable_step_tsk x1, x2
kernel_exit 0
ENDPROC(ret_to_user)
diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
index a8eafdbc7cb8..404dd67080b9 100644
--- a/arch/arm64/kernel/signal.c
+++ b/arch/arm64/kernel/signal.c
@@ -402,15 +402,31 @@ static void do_signal(struct pt_regs *regs)
asmlinkage void do_notify_resume(struct pt_regs *regs,
unsigned int thread_flags)
{
- if (thread_flags & _TIF_SIGPENDING)
- do_signal(regs);
-
- if (thread_flags & _TIF_NOTIFY_RESUME) {
- clear_thread_flag(TIF_NOTIFY_RESUME);
- tracehook_notify_resume(regs);
- }
-
- if (thread_flags & _TIF_FOREIGN_FPSTATE)
- fpsimd_restore_current_state();
+ /*
+ * The assembly code enters us with IRQs off, but it hasn't
+ * informed the tracing code of that for efficiency reasons.
+ * Update the trace code with the current status.
+ */
+ trace_hardirqs_off();
+ do {
+ if (thread_flags & _TIF_NEED_RESCHED) {
+ schedule();
+ } else {
+ local_irq_enable();
+
+ if (thread_flags & _TIF_SIGPENDING)
+ do_signal(regs);
+
+ if (thread_flags & _TIF_NOTIFY_RESUME) {
+ clear_thread_flag(TIF_NOTIFY_RESUME);
+ tracehook_notify_resume(regs);
+ }
+
+ if (thread_flags & _TIF_FOREIGN_FPSTATE)
+ fpsimd_restore_current_state();
+ }
+ local_irq_disable();
+ thread_flags = READ_ONCE(current_thread_info()->flags);
+ } while (thread_flags & _TIF_WORK_MASK);
}
--
2.7.2
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH v14 00/14] support "task_isolation" mode Chris Metcalf <cmetcalf@mellanox.com> - 2016-08-09 22:40 +0200
[PATCH v14 06/14] arch/x86: enable task isolation functionality Chris Metcalf <cmetcalf@mellanox.com> - 2016-08-09 22:40 +0200
Re: [PATCH v14 06/14] arch/x86: enable task isolation functionality Andy Lutomirski <luto@amacapital.net> - 2016-08-10 21:20 +0200
Re: [PATCH v14 06/14] arch/x86: enable task isolation functionality Andy Lutomirski <luto@amacapital.net> - 2016-08-10 22:10 +0200
Re: [PATCH v14 06/14] arch/x86: enable task isolation functionality Andy Lutomirski <luto@amacapital.net> - 2016-08-10 21:20 +0200
[PATCH v14 10/14] arm, tile: turn off timer tick for oneshot_stopped state Chris Metcalf <cmetcalf@mellanox.com> - 2016-08-09 22:40 +0200
[PATCH v14 02/14] vmstat: add vmstat_idle function Chris Metcalf <cmetcalf@mellanox.com> - 2016-08-09 22:40 +0200
[PATCH v14 08/14] arch/arm64: enable task isolation functionality Chris Metcalf <cmetcalf@mellanox.com> - 2016-08-09 22:40 +0200
[PATCH v14 05/14] task_isolation: track asynchronous interrupts Chris Metcalf <cmetcalf@mellanox.com> - 2016-08-09 22:40 +0200
[PATCH v14 09/14] arch/tile: enable task isolation functionality Chris Metcalf <cmetcalf@mellanox.com> - 2016-08-09 22:40 +0200
[PATCH v14 04/14] task_isolation: add initial support Chris Metcalf <cmetcalf@mellanox.com> - 2016-08-09 22:40 +0200
[PATCH v14 07/14] arm64: factor work_pending state machine to C Chris Metcalf <cmetcalf@mellanox.com> - 2016-08-09 22:40 +0200
csiph-web