[uclibc-ng-devel] [PATCH] remove PID caching - preview

Vineet Gupta Vineet.Gupta1 at synopsys.com
Wed Jan 25 19:33:53 CET 2017


On 01/24/2017 10:03 PM, Waldemar Brodkorb wrote:
> Hi,
>
> I would like to suggest following changeset, any opinions?
>
> Follow GNU C Library from c579f48edba88380635ab98cb612030e3ed8691e
> and remove the PID caching. These simplifies the architecture specific
> assembly code.
> The run of the test suite found no regressions, it even solves
> some of the test failures for x86/x86_64/sparc.
>
> Signed-off-by: Waldemar Brodkorb <wbx at openadk.org>
> ---
>  libc/sysdeps/linux/arc/clone.S                     | 15 ++---
>  libc/sysdeps/linux/arc/vfork.S                     | 13 ----
>  libc/sysdeps/linux/arm/clone.S                     | 18 ------
>  libc/sysdeps/linux/arm/vfork.S                     | 13 ----
>  libc/sysdeps/linux/common/bits/kernel-features.h   |  7 ---
>  libc/sysdeps/linux/i386/Makefile.arch              |  7 +--
>  libc/sysdeps/linux/i386/clone.S                    |  8 ---
>  libc/sysdeps/linux/i386/vfork.S                    |  8 ---
>  libc/sysdeps/linux/ia64/clone2.S                   | 19 ------
>  libc/sysdeps/linux/metag/clone.S                   | 21 -------
>  libc/sysdeps/linux/metag/vfork.S                   | 12 ----
>  libc/sysdeps/linux/mips/Makefile.arch              |  4 +-
>  libc/sysdeps/linux/mips/clone.S                    | 28 ---------
>  libc/sysdeps/linux/mips/vfork.S                    | 12 ----
>  libc/sysdeps/linux/nds32/clone.S                   | 24 --------
>  libc/sysdeps/linux/nds32/vfork.S                   | 14 -----
>  libc/sysdeps/linux/nios2/clone.S                   |  8 ---
>  libc/sysdeps/linux/nios2/vfork.S                   | 17 ------
>  libc/sysdeps/linux/powerpc/Makefile.arch           |  4 +-
>  libc/sysdeps/linux/powerpc/clone.S                 | 30 ++--------
>  libc/sysdeps/linux/sh/Makefile.arch                |  7 +--
>  libc/sysdeps/linux/sh/clone.S                      | 36 +----------
>  libc/sysdeps/linux/sparc/Makefile.arch             |  8 +--
>  libc/sysdeps/linux/sparc/clone.S                   | 17 ------
>  libc/sysdeps/linux/sparc/vfork.S                   |  2 -
>  libc/sysdeps/linux/x86_64/Makefile.arch            |  6 +-
>  libc/sysdeps/linux/x86_64/clone.S                  | 13 ----
>  libc/sysdeps/linux/x86_64/vfork.S                  |  8 ---
>  libc/sysdeps/linux/xtensa/Makefile.arch            |  4 +-
>  libc/sysdeps/linux/xtensa/clone.S                  | 19 ------
>  libc/sysdeps/linux/xtensa/vfork.S                  | 25 --------
>  libpthread/nptl/allocatestack.c                    | 20 +------
>  libpthread/nptl/descr.h                            |  2 +-
>  libpthread/nptl/init.c                             | 28 +--------
>  libpthread/nptl/pthread_cancel.c                   |  6 +-
>  libpthread/nptl/sysdeps/alpha/tcb-offsets.sym      |  1 -
>  libpthread/nptl/sysdeps/arc/tcb-offsets.sym        |  1 -
>  libpthread/nptl/sysdeps/arm/tcb-offsets.sym        |  1 -
>  libpthread/nptl/sysdeps/i386/tcb-offsets.sym       |  1 -
>  libpthread/nptl/sysdeps/metag/tcb-offsets.sym      |  1 -
>  libpthread/nptl/sysdeps/microblaze/tcb-offsets.sym |  1 -
>  libpthread/nptl/sysdeps/mips/tcb-offsets.sym       |  1 -
>  libpthread/nptl/sysdeps/nds32/tcb-offsets.sym      |  1 -
>  libpthread/nptl/sysdeps/nios2/tcb-offsets.sym      |  1 -
>  libpthread/nptl/sysdeps/powerpc/tcb-offsets.sym    |  1 -
>  libpthread/nptl/sysdeps/pthread/createthread.c     |  5 +-
>  libpthread/nptl/sysdeps/sh/tcb-offsets.sym         |  1 -
>  libpthread/nptl/sysdeps/sparc/tcb-offsets.sym      |  1 -
>  .../nptl/sysdeps/unix/sysv/linux/alpha/clone.S     |  2 -
>  .../nptl/sysdeps/unix/sysv/linux/alpha/vfork.S     | 45 --------------
>  .../nptl/sysdeps/unix/sysv/linux/arc/Makefile.arch |  3 -
>  .../nptl/sysdeps/unix/sysv/linux/arc/clone.S       | 10 ----
>  .../nptl/sysdeps/unix/sysv/linux/arc/vfork.S       | 11 ----
>  .../nptl/sysdeps/unix/sysv/linux/arm/Makefile.arch |  8 ---
>  .../nptl/sysdeps/unix/sysv/linux/arm/clone.S       |  3 -
>  .../nptl/sysdeps/unix/sysv/linux/arm/vfork.S       | 38 ------------
>  libpthread/nptl/sysdeps/unix/sysv/linux/fork.c     | 12 ----
>  libpthread/nptl/sysdeps/unix/sysv/linux/getpid.c   | 30 ----------
>  .../sysdeps/unix/sysv/linux/i386/Makefile.arch     |  4 +-
>  .../nptl/sysdeps/unix/sysv/linux/i386/clone.S      |  2 -
>  .../nptl/sysdeps/unix/sysv/linux/i386/vfork.S      | 37 ------------
>  .../sysdeps/unix/sysv/linux/metag/Makefile.arch    |  3 -
>  .../nptl/sysdeps/unix/sysv/linux/metag/clone.S     |  9 ---
>  .../nptl/sysdeps/unix/sysv/linux/metag/vfork.S     | 55 -----------------
>  .../unix/sysv/linux/microblaze/Makefile.arch       |  1 -
>  .../sysdeps/unix/sysv/linux/microblaze/clone.S     |  4 --
>  .../sysdeps/unix/sysv/linux/microblaze/vfork.S     |  5 --
>  .../sysdeps/unix/sysv/linux/mips/Makefile.arch     |  7 +--
>  .../nptl/sysdeps/unix/sysv/linux/mips/clone.S      |  2 -
>  .../nptl/sysdeps/unix/sysv/linux/mips/pt-clone.S   |  2 -
>  .../nptl/sysdeps/unix/sysv/linux/mips/vfork.S      | 42 -------------
>  .../sysdeps/unix/sysv/linux/nds32/Makefile.arch    |  3 -
>  .../nptl/sysdeps/unix/sysv/linux/nds32/clone.S     |  4 --
>  .../nptl/sysdeps/unix/sysv/linux/nds32/vfork.S     | 43 -------------
>  .../sysdeps/unix/sysv/linux/nios2/Makefile.arch    |  2 -
>  .../nptl/sysdeps/unix/sysv/linux/nios2/clone.S     |  3 -
>  .../nptl/sysdeps/unix/sysv/linux/nios2/vfork.S     | 38 ------------
>  .../sysdeps/unix/sysv/linux/powerpc/Makefile.arch  |  2 -
>  .../nptl/sysdeps/unix/sysv/linux/powerpc/clone.S   |  9 ---
>  .../nptl/sysdeps/unix/sysv/linux/powerpc/vfork.S   | 57 ------------------
>  .../nptl/sysdeps/unix/sysv/linux/pthread_kill.c    |  5 +-
>  .../sysdeps/unix/sysv/linux/pthread_sigqueue.c     | 12 ++--
>  libpthread/nptl/sysdeps/unix/sysv/linux/raise.c    | 48 +++++++--------
>  .../nptl/sysdeps/unix/sysv/linux/sh/Makefile.arch  |  2 -
>  libpthread/nptl/sysdeps/unix/sysv/linux/sh/clone.S |  2 -
>  libpthread/nptl/sysdeps/unix/sysv/linux/sh/vfork.S | 70 ----------------------
>  .../sysdeps/unix/sysv/linux/sparc/Makefile.arch    |  3 -
>  .../nptl/sysdeps/unix/sysv/linux/sparc/clone.S     |  2 -
>  .../nptl/sysdeps/unix/sysv/linux/sparc/vfork.S     | 48 ---------------
>  .../sysdeps/unix/sysv/linux/x86_64/Makefile.arch   |  6 +-
>  .../nptl/sysdeps/unix/sysv/linux/x86_64/clone.S    |  3 -
>  .../nptl/sysdeps/unix/sysv/linux/x86_64/vfork.S    | 42 -------------
>  .../sysdeps/unix/sysv/linux/xtensa/Makefile.arch   |  3 -
>  .../nptl/sysdeps/unix/sysv/linux/xtensa/clone.S    |  3 -
>  .../nptl/sysdeps/unix/sysv/linux/xtensa/vfork.S    | 59 ------------------
>  libpthread/nptl/sysdeps/x86_64/tcb-offsets.sym     |  1 -
>  libpthread/nptl/sysdeps/xtensa/tcb-offsets.sym     |  1 -
>  97 files changed, 67 insertions(+), 1239 deletions(-)
>  delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/alpha/clone.S
>  delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/alpha/vfork.S
>  delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/arc/clone.S
>  delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/arc/vfork.S
>  delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/arm/clone.S
>  delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/arm/vfork.S
>  delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/i386/clone.S
>  delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/i386/vfork.S
>  delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/metag/clone.S
>  delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/metag/vfork.S
>  delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/clone.S
>  delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/vfork.S
>  delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/mips/clone.S
>  delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/mips/pt-clone.S
>  delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/mips/vfork.S
>  delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/nds32/clone.S
>  delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/nds32/vfork.S
>  delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/nios2/clone.S
>  delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/nios2/vfork.S
>  delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/clone.S
>  delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/vfork.S
>  delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/sh/clone.S
>  delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/sh/vfork.S
>  delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/sparc/clone.S
>  delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/sparc/vfork.S
>  delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/clone.S
>  delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/vfork.S
>  delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/clone.S
>  delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/vfork.S
>
> diff --git a/libc/sysdeps/linux/arc/clone.S b/libc/sysdeps/linux/arc/clone.S
> index 3942b88..4467221 100644
> --- a/libc/sysdeps/linux/arc/clone.S
> +++ b/libc/sysdeps/linux/arc/clone.S
> @@ -29,6 +29,10 @@
>  
>  #define CLONE_SETTLS		0x00080000
>  
> +.macro SET_TP  tcb
> +        mov    r25, \tcb
> +.endm
> +

Why even bother - just open code it

>  ENTRY(clone)
>  	cmp	r0, 0		; @fn can't be NULL
>  	cmp.ne	r1, 0		; @child_stack can't be NULL
> @@ -64,17 +68,6 @@ ENTRY(clone)
>  	SET_TP	r9
>  
>  .Lnext_clone_quirk:
> -#ifdef RESET_PID
> -	bbit1	r12, 16, .Lgo_thread	; CLONE_THREAD = (1 << 16)
> -
> -	mov	r8, __NR_getpid
> -	ARC_TRAP_INSN		; r0 has PID
> -	THREAD_SELF r1		; Get to struct pthread (just before TCB)
> -	st	r0, [r1, PTHREAD_PID]
> -	st	r0, [r1, PTHREAD_TID]
> -
> -.Lgo_thread:
> -#endif
>  #endif
>  	; child jumps off to @fn with @arg as argument, and returns here
>  	jl.d	[r10]
> diff --git a/libc/sysdeps/linux/arc/vfork.S b/libc/sysdeps/linux/arc/vfork.S
> index 573a29f..11959b6 100644
> --- a/libc/sysdeps/linux/arc/vfork.S
> +++ b/libc/sysdeps/linux/arc/vfork.S
> @@ -16,25 +16,12 @@
>  #define CLONE_FLAGS_FOR_VFORK	(CLONE_VM|CLONE_VFORK|SIGCHLD)
>  
>  ENTRY(__vfork)
> -#ifdef SAVE_PID
> -	THREAD_SELF r1		; Get to struct pthread (just before TCB)
> -	ld	r2, [r1, PTHREAD_PID]
> -	neg.f	r3, r2
> -	bset.z	r3, r3, 31
> -	st	r3, [r1, PTHREAD_PID]
> -#endif
>  	mov	r0, CLONE_FLAGS_FOR_VFORK
>  	mov_s	r1, sp
>  	mov	r8, __NR_clone
>  	ARC_TRAP_INSN
>  
>  	cmp	r0, 0
> -#ifdef RESTORE_PID
> -	bz	1f	; child continues
> -	THREAD_SELF r1		; Get to struct pthread (just before TCB)
> -	st	r2, [r1, PTHREAD_PID]
> -1:
> -#endif
>  	jge	[blink]	; pid >=0 return, else detour via tailcall to errno
>  
>  	b   __syscall_error
>

Rest LGTM !

Thx,
-Vineet


More information about the devel mailing list