public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Chris Metcalf <cmetcalf@mellanox.com>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>,
	<libc-alpha@sourceware.org>
Subject: Re: [PATCH v4] Fix clone (CLONE_VM) pid/tid reset (BZ#19957)
Date: Thu, 28 Apr 2016 20:07:00 -0000	[thread overview]
Message-ID: <19330067-0379-c612-330c-e1d569097b3b@mellanox.com> (raw)
In-Reply-To: <1461685391-5669-1-git-send-email-adhemerval.zanella@linaro.org>

On 4/26/2016 11:43 AM, Adhemerval Zanella wrote:
> --- a/sysdeps/unix/sysv/linux/tile/clone.S
> +++ b/sysdeps/unix/sysv/linux/tile/clone.S
> @@ -164,43 +164,31 @@ ENTRY (__clone)
>   	cfi_def_cfa_offset (FRAME_SIZE)
>   	cfi_undefined (lr)
>   	/* Check and see if we need to reset the PID, which we do if
> -	   CLONE_THREAD isn't set, i.e. we're not staying in the thread group.
> -	   If CLONE_VM is set, we're doing some kind of thread-like clone,
> -	   so we set the tid/pid to -1 to disable using the cached values
> -	   in getpid().  Otherwise (if CLONE_VM isn't set), it's a
> +	   CLONE_VM isn't set, i.e. we're do not share the same pthread_t
> +	   with parent.   Otherwise (if CLONE_VM isn't set), it's a
>   	   fork-like clone, and we go ahead and write the cached values
>   	   from the true system pid (retrieved via __NR_getpid syscall).  */

I'd change this to:

  	/* Check and see if we need to reset the PID, which we do if
	   CLONE_VM isn't set, i.e. it's a fork-like clone with a new
	   address space.  In that case we update the cached values
  	   from the true system pid (retrieved via __NR_getpid syscall).  */


>   #ifdef __tilegx__
>   	{
>   	 moveli r0, hw1_last(CLONE_VM)
> -	 moveli r1, hw1_last(CLONE_THREAD)
>   	}
>   	{
>   	 shl16insli r0, r0, hw0(CLONE_VM)
> -	 shl16insli r1, r1, hw0(CLONE_THREAD)
>   	}
>   #else
>   	{
>   	 moveli r0, lo16(CLONE_VM)
> -	 moveli r1, lo16(CLONE_THREAD)
>   	}
>   	{
>   	 auli r0, r0, ha16(CLONE_VM)
> -	 auli r1, r1, ha16(CLONE_THREAD)
>   	}
>   #endif
>   	{
>   	 and r0, r30, r0
> -	 and r1, r30, r1
> -	}
> -	BNEZ r1, .Lno_reset_pid   /* CLONE_THREAD is set */
> -	{
> -	 movei r0, -1
> -	 BNEZ r0, .Lgotpid         /* CLONE_VM is set */
>   	}

Here you have left the "{ }" around some single instructions. Stylistically,
we typically don't do that.  Also, we only used the two-instruction format
for loading up r0/r1 because CLONE_THREAD needed it; CLONE_VM doesn't,
so we can collapse all the quoted code above down to just:

	moveli r0, CLONE_VM
	and r0, r30, r0


We could do this in one instruction if we had the bit position (i.e. log-2) of
CLONE_VM, but the obfuscation is not worth it on this not very hot path.

> +	BNEZ r0, .Lno_reset_pid   /* CLONE_VM is set */
>   	moveli TREG_SYSCALL_NR_NAME, __NR_getpid
>   	swint1
> -.Lgotpid:
>   	ADDLI_PTR r2, tp, PID_OFFSET
>   	{
>   	 ST4 r2, r0

With those changes, looks good to me.

-- 
Chris Metcalf, Mellanox Technologies
http://www.mellanox.com

  reply	other threads:[~2016-04-28 20:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-26 15:43 Adhemerval Zanella
2016-04-28 20:07 ` Chris Metcalf [this message]
2016-04-28 21:00   ` Adhemerval Zanella
2016-04-28 20:19 ` Carlos O'Donell
2016-04-28 21:04   ` Adhemerval Zanella
2016-04-29 14:06     ` Carlos O'Donell

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=19330067-0379-c612-330c-e1d569097b3b@mellanox.com \
    --to=cmetcalf@mellanox.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).