diff options
author | Alexey Brodkin <Alexey.Brodkin@synopsys.com> | 2016-07-29 12:17:19 +0300 |
---|---|---|
committer | Waldemar Brodkorb <wbx@uclibc-ng.org> | 2016-07-31 12:50:54 +0200 |
commit | b2c2bbcc8ccd0d0b281db653d22e568b8871ad46 (patch) | |
tree | 24a23d43d39ad86b6d058ae39c6d57f04859a7ad /libc | |
parent | 25f4ae1de711b2001b4958d65e77b6dba222e7b5 (diff) |
arc: clone: Fix CLONE_THREAD detection
For thread group case (CLONE_THREAD), the cached PID of new process/thread
need not be reset. The old logic to decide that was flawed as it would be
true only for exact combination of CLONE_THREAD + _VM, but would fail for
CLONE_THREAD + _VM + _xyz.
More detailed tear-down of current and new code below.
Current implementation is:
--------------------->8--------------------
; r12 contains clone flags
mov_s r2, CLONE_THREAD_N_VM; r2 contains bit mask
and_s r2, r2, r12 ; r2 contains bit mask AND clone flags
; but r12 still contains the same flags
brne r2, r12, .Lgo_thread ; here we compare modified mask with
; flags as they were and skip pthread TID/PID
; setup if r2 != r12 which happens all
; the time except clone flags were
; exactly CLONE_THREAD | CLONE_VM
--------------------->8--------------------
New implementation is:
--------------------->8--------------------
; r12 contains clone flags
mov_s r2, CLONE_THREAD_N_VM; r2 contains bit mask
and_s r12, r12, r2 ; r12 contains clone flags AND bit mask
; i.e. we did mask all flags except
; CLONE_THREAD and CLONE_VM
breq r2, r12, .Lgo_thread ; here we compare masked flags with
; target mask and if they match we skip
; pthread TID/PID setup
--------------------->8--------------------
Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
Acked-by: Vineet Gupta <vgupta@synopsys.com>
Diffstat (limited to 'libc')
-rw-r--r-- | libc/sysdeps/linux/arc/clone.S | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libc/sysdeps/linux/arc/clone.S b/libc/sysdeps/linux/arc/clone.S index dbb3fa756..fc8dfcf2a 100644 --- a/libc/sysdeps/linux/arc/clone.S +++ b/libc/sysdeps/linux/arc/clone.S @@ -69,8 +69,8 @@ ENTRY(clone) .Lnext_clone_quirk: #ifdef RESET_PID mov_s r2, CLONE_THREAD_N_VM - and_s r2, r2, r12 - brne r2, r12, .Lgo_thread + and_s r12, r12, r2 + breq r2, r12, .Lgo_thread mov r8, __NR_getpid ARC_TRAP_INSN ; r0 has PID |