Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1301880

Re: [PATCH 2/2] arm64: factor work_pending state machine to C

From Chris Metcalf <cmetcalf@ezchip.com>
Newsgroups linux.kernel
Subject Re: [PATCH 2/2] arm64: factor work_pending state machine to C
Date 2016-01-05 20:00 +0100
Message-ID <qNEZQ-6P2-27@gated-at.bofh.it> (permalink)
References <qNDAK-5X5-7@gated-at.bofh.it> <qNDKq-61Z-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 01/05/2016 12:33 PM, Mark Rutland wrote:
> 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 mirror the existing behaviour as closely as possible
> while using the usual C control flow primitives. There should be no
> functional change as a result of this patch.
>
> Signed-off-by: Mark Rutland<mark.rutland@arm.com>
> Cc: Catalin Marinas<catalin.marinas@arm.com>
> Cc: Chris Metcalf<cmetcalf@ezchip.com>
> Cc: Will Deacon<will.deacon@arm.com>
> ---
>   arch/arm64/kernel/entry.S  | 24 +++---------------------
>   arch/arm64/kernel/signal.c | 36 ++++++++++++++++++++++++++----------
>   2 files changed, 29 insertions(+), 31 deletions(-)

This looks good, and also makes the task isolation change drop in
very cleanly (relatively speaking).  Since do_notify_resume() is
called unconditionally now, we don't have to worry about fussing
with the bit numbering for the TIF_xxx flags in asm/threadinfo.h, so
that whole part of the patch can be dropped, and the actual
change to do_notify_resume() becomes:

diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
index 3a6c60beadca..00d0ec3a8e60 100644
--- a/arch/arm64/kernel/signal.c
+++ b/arch/arm64/kernel/signal.c
@@ -25,6 +25,7 @@
  #include <linux/uaccess.h>
  #include <linux/tracehook.h>
  #include <linux/ratelimit.h>
+#include <linux/isolation.h>
  
  #include <asm/debug-monitors.h>
  #include <asm/elf.h>
@@ -408,7 +409,8 @@ asmlinkage void do_notify_resume(void)
                 local_irq_disable();
  
                 thread_flags = READ_ONCE(current_thread_info()->flags);
-               if (!(thread_flags & _TIF_WORK_MASK))
+               if (!(thread_flags & _TIF_WORK_MASK) &&
+                   task_isolation_ready())
                         break;
  
                 if (thread_flags & _TIF_NEED_RESCHED) {
@@ -428,5 +430,7 @@ asmlinkage void do_notify_resume(void)
  
                 if (thread_flags & _TIF_FOREIGN_FPSTATE)
                         fpsimd_restore_current_state();
+
+               task_isolation_enter();
         }
  }


For the moment I just added your two commits into my task-isolation
tree and pushed it up, but if your changes make it into 4.5 and the
task-isolation series doesn't, I will remove them and rebase on 4.5-rc1
once that's released.  I've similarly staged the arch/tile enablement
changes to go into 4.5 so I can drop them from the task-isolation tree
as well at that point.

-- 
Chris Metcalf, EZChip Semiconductor
http://www.ezchip.com

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH v9 08/13] arch/arm64: adopt prepare_exit_to_usermode()  model from x86 Mark Rutland <mark.rutland@arm.com> - 2016-01-04 21:40 +0100
  Re: [PATCH v9 08/13] arch/arm64: adopt prepare_exit_to_usermode()  model from x86 Chris Metcalf <cmetcalf@ezchip.com> - 2016-01-04 22:10 +0100
    Re: [PATCH v9 08/13] arch/arm64: adopt prepare_exit_to_usermode()  model from x86 Mark Rutland <mark.rutland@arm.com> - 2016-01-05 18:30 +0100
      [PATCH 2/2] arm64: factor work_pending state machine to C Mark Rutland <mark.rutland@arm.com> - 2016-01-05 18:40 +0100
        Re: [PATCH 2/2] arm64: factor work_pending state machine to C Chris Metcalf <cmetcalf@ezchip.com> - 2016-01-05 20:00 +0100
        Re: [PATCH 2/2] arm64: factor work_pending state machine to C Catalin Marinas <catalin.marinas@arm.com> - 2016-01-06 13:40 +0100
          Re: [PATCH 2/2] arm64: factor work_pending state machine to C Mark Rutland <mark.rutland@arm.com> - 2016-01-06 13:50 +0100
        Re: [PATCH 2/2] arm64: factor work_pending state machine to C Mark Rutland <mark.rutland@arm.com> - 2016-01-06 14:50 +0100
          Re: [PATCH 2/2] arm64: factor work_pending state machine to C Catalin Marinas <catalin.marinas@arm.com> - 2016-01-06 15:20 +0100
      [PATCH 1/2] arm64: entry: remove pointless SPSR mode check Mark Rutland <mark.rutland@arm.com> - 2016-01-05 18:40 +0100
        Re: [PATCH 1/2] arm64: entry: remove pointless SPSR mode check Catalin Marinas <catalin.marinas@arm.com> - 2016-01-06 13:20 +0100
  Re: [PATCH v9 08/13] arch/arm64: adopt prepare_exit_to_usermode()  model from x86 Andy Lutomirski <luto@amacapital.net> - 2016-01-04 23:40 +0100
    Re: [PATCH v9 08/13] arch/arm64: adopt prepare_exit_to_usermode()  model from x86 Mark Rutland <mark.rutland@arm.com> - 2016-01-05 19:10 +0100

csiph-web