public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
To: Paul Mackerras <paulus-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
Cc: linuxppc-dev-mnsaURCQ41sdnm+yROfE0A@public.gmane.org,
	mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	linux-arch-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] Add fast little-endian switch system call
Date: Mon, 28 Apr 2008 16:43:32 +0200	[thread overview]
Message-ID: <20080428144332.GA17109@lst.de> (raw)
In-Reply-To: <18453.18943.906693.409245-UYQwCShxghk5kJ7NmlRacFaTQe2KTcn/@public.gmane.org>

Please see Michael Kerrisk on userspace ABI updates.  A nice little
manpage for this gimmick would be helpful, and maybe help other
platforms that want one aswell to implement the same API.

On Mon, Apr 28, 2008 at 01:52:31PM +1000, Paul Mackerras wrote:
> This adds a system call on 64-bit platforms for switching between
> little-endian and big-endian modes that is much faster than doing a
> prctl call.  This system call is handled as a special case right at
> the start of the system call entry code, and because it is a special
> case, it uses a system call number which is out of the range of
> normal system calls, namely 0x1ebe.
> 
> Measurements with lmbench on a 4.2GHz POWER6 showed no measurable
> change in the speed of normal system calls with this patch.
> 
> Switching endianness with this new system call takes around 60ns on a
> 4.2GHz POWER6, compared with around 300ns to switch endian mode with a
> prctl.  This can provide a significant performance advantage for
> emulators for little-endian architectures that want to switch between
> big-endian and little-endian mode frequently, e.g. because they are
> generating instructions sequences on the fly and they want to run
> those sequences in little-endian mode.
> 
> Signed-off-by: Paul Mackerras <paulus-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
> ---
> 
> diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
> index 215973a..2eb49a7 100644
> --- a/arch/powerpc/kernel/head_64.S
> +++ b/arch/powerpc/kernel/head_64.S
> @@ -239,6 +239,10 @@ instruction_access_slb_pSeries:
>  	.globl	system_call_pSeries
>  system_call_pSeries:
>  	HMT_MEDIUM
> +BEGIN_FTR_SECTION
> +	cmpdi	r0,0x1ebe
> +	beq-	1f
> +END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE)

Am I missing something here or does this add a branch for every normal
syscall?

>  	mr	r9,r13
>  	mfmsr	r10
>  	mfspr	r13,SPRN_SPRG3
> @@ -253,6 +257,13 @@ system_call_pSeries:
>  	rfid
>  	b	.	/* prevent speculative execution */
>  
> +/* Fast LE/BE switch system call */
> +1:	mfspr	r12,SPRN_SRR1
> +	xori	r12,r12,MSR_LE
> +	mtspr	SPRN_SRR1,r12
> +	rfid		/* return to userspace */
> +	b	.
> +
>  	STD_EXCEPTION_PSERIES(0xd00, single_step)
>  	STD_EXCEPTION_PSERIES(0xe00, trap_0e)
>  
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev-mnsaURCQ41sdnm+yROfE0A@public.gmane.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev
---end quoted text---

WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de>
To: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@ozlabs.org, mtk.manpages@gmail.com,
	linux-arch@vger.kernel.org
Subject: Re: [PATCH] Add fast little-endian switch system call
Date: Mon, 28 Apr 2008 16:43:32 +0200	[thread overview]
Message-ID: <20080428144332.GA17109@lst.de> (raw)
Message-ID: <20080428144332.bq9agq-LJ4594PA-1ufxW4PUFfG6mhQY3hVcIxBN6yQ@z> (raw)
In-Reply-To: <18453.18943.906693.409245@cargo.ozlabs.ibm.com>

Please see Michael Kerrisk on userspace ABI updates.  A nice little
manpage for this gimmick would be helpful, and maybe help other
platforms that want one aswell to implement the same API.

On Mon, Apr 28, 2008 at 01:52:31PM +1000, Paul Mackerras wrote:
> This adds a system call on 64-bit platforms for switching between
> little-endian and big-endian modes that is much faster than doing a
> prctl call.  This system call is handled as a special case right at
> the start of the system call entry code, and because it is a special
> case, it uses a system call number which is out of the range of
> normal system calls, namely 0x1ebe.
> 
> Measurements with lmbench on a 4.2GHz POWER6 showed no measurable
> change in the speed of normal system calls with this patch.
> 
> Switching endianness with this new system call takes around 60ns on a
> 4.2GHz POWER6, compared with around 300ns to switch endian mode with a
> prctl.  This can provide a significant performance advantage for
> emulators for little-endian architectures that want to switch between
> big-endian and little-endian mode frequently, e.g. because they are
> generating instructions sequences on the fly and they want to run
> those sequences in little-endian mode.
> 
> Signed-off-by: Paul Mackerras <paulus@samba.org>
> ---
> 
> diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
> index 215973a..2eb49a7 100644
> --- a/arch/powerpc/kernel/head_64.S
> +++ b/arch/powerpc/kernel/head_64.S
> @@ -239,6 +239,10 @@ instruction_access_slb_pSeries:
>  	.globl	system_call_pSeries
>  system_call_pSeries:
>  	HMT_MEDIUM
> +BEGIN_FTR_SECTION
> +	cmpdi	r0,0x1ebe
> +	beq-	1f
> +END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE)

Am I missing something here or does this add a branch for every normal
syscall?

>  	mr	r9,r13
>  	mfmsr	r10
>  	mfspr	r13,SPRN_SPRG3
> @@ -253,6 +257,13 @@ system_call_pSeries:
>  	rfid
>  	b	.	/* prevent speculative execution */
>  
> +/* Fast LE/BE switch system call */
> +1:	mfspr	r12,SPRN_SRR1
> +	xori	r12,r12,MSR_LE
> +	mtspr	SPRN_SRR1,r12
> +	rfid		/* return to userspace */
> +	b	.
> +
>  	STD_EXCEPTION_PSERIES(0xd00, single_step)
>  	STD_EXCEPTION_PSERIES(0xe00, trap_0e)
>  
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev
---end quoted text---

       reply	other threads:[~2008-04-28 14:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <18453.18943.906693.409245@cargo.ozlabs.ibm.com>
     [not found] ` <18453.18943.906693.409245-UYQwCShxghk5kJ7NmlRacFaTQe2KTcn/@public.gmane.org>
2008-04-28 14:43   ` Christoph Hellwig [this message]
2008-04-28 14:43     ` [PATCH] Add fast little-endian switch system call Christoph Hellwig
     [not found]     ` <20080428144332.GA17109-jcswGhMUV9g@public.gmane.org>
2008-04-28 15:42       ` Michael Kerrisk
2008-04-28 15:42         ` Michael Kerrisk
2008-04-29  2:46       ` Paul Mackerras
2008-04-29  2:46         ` Paul Mackerras
     [not found]         ` <18454.35824.527711.355488-UYQwCShxghk5kJ7NmlRacFaTQe2KTcn/@public.gmane.org>
2008-04-29 18:40           ` Wolfgang Denk
2008-04-29 18:40             ` Wolfgang Denk
     [not found]             ` <20080429184047.47CB7247B4-C2Gvrrd9BC/j/ljBK/0BTg@public.gmane.org>
2008-04-29 18:46               ` Christoph Hellwig
2008-04-29 18:46                 ` Christoph Hellwig
2008-04-29 21:16               ` Paul Mackerras
2008-04-29 21:16                 ` Paul Mackerras

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=20080428144332.GA17109@lst.de \
    --to=hch-jcswghmuv9g@public.gmane.org \
    --cc=linux-arch-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linuxppc-dev-mnsaURCQ41sdnm+yROfE0A@public.gmane.org \
    --cc=mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=paulus-eUNUBHrolfbYtjvyW6yDsg@public.gmane.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