mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Akira Tsukamoto' <akira.tsukamoto@gmail.com>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>, Gary Guo <gary@garyguo.net>,
	Nick Hu <nickhu@andestech.com>, Nylon Chen <nylon7@andestech.com>,
	"linux-riscv@lists.infradead.org"
	<linux-riscv@lists.infradead.org>,
	"Linux kernel mailing list" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH 1/1] riscv: prevent pipeline stall in __asm_to/copy_from_user
Date: Tue, 8 Jun 2021 11:31:40 +0000	[thread overview]
Message-ID: <67dab8dc517f4add8b0c29074a6b3f06@AcuMS.aculab.com> (raw)
In-Reply-To: <CACuRN0Pd8VFTz55qzXvJeqOEt2ZGi--j1wDyqnAt=q_42ES++w@mail.gmail.com>

From: Akira Tsukamoto
> Sent: 04 June 2021 10:57
> 
> Reducing pipeline stall of read after write (RAW).
> 
> These are the results from combination of the speedup with
> Gary's misalign fix. Speeds up from 680Mbps to 900Mbps.
> 
> Before applying these two patches.

I think the changes should be in separate patches.
Otherwise it is difficult to see what is relevant.
It also looks as if there is a register rename.
Maybe that should be a precursor patch?
...

I think this is the old main copy loop:
>  1:
> -    fixup REG_L, t2, (a1), 10f
> -    fixup REG_S, t2, (a0), 10f
> -    addi a1, a1, SZREG
> -    addi a0, a0, SZREG
> -    bltu a1, t1, 1b
and this is the new one:
>  3:
> +    fixup REG_L a4,       0(a1), 10f
> +    fixup REG_L a5,   SZREG(a1), 10f
> +    fixup REG_L a6, 2*SZREG(a1), 10f
> +    fixup REG_L a7, 3*SZREG(a1), 10f
> +    fixup REG_L t0, 4*SZREG(a1), 10f
> +    fixup REG_L t1, 5*SZREG(a1), 10f
> +    fixup REG_L t2, 6*SZREG(a1), 10f
> +    fixup REG_L t3, 7*SZREG(a1), 10f
> +    fixup REG_S a4,       0(t5), 10f
> +    fixup REG_S a5,   SZREG(t5), 10f
> +    fixup REG_S a6, 2*SZREG(t5), 10f
> +    fixup REG_S a7, 3*SZREG(t5), 10f
> +    fixup REG_S t0, 4*SZREG(t5), 10f
> +    fixup REG_S t1, 5*SZREG(t5), 10f
> +    fixup REG_S t2, 6*SZREG(t5), 10f
> +    fixup REG_S t3, 7*SZREG(t5), 10f
> +    addi a1, a1, 8*SZREG
> +    addi t5, t5, 8*SZREG
> +    bltu a1, a3, 3b

I don't know the architecture, but unless there is a stunning
pipeline delay for memory reads a simple interleaved copy
may be fast enough.
So something like:
	a = src[0];
	do {
		b = src[1];
		src += 2;
		dst[0] = a;
		dst += 2;
		a = src[0];
		dst[-1] = b;
	} while (src != src_end);
	dst[0] = a;

It is probably worth doing benchmarks of the copy loop
in userspace.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

  reply	other threads:[~2021-06-08 11:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-04  9:53 [PATCH 0/1] riscv: better network performance with memcpy, uaccess Akira Tsukamoto
2021-06-04  9:56 ` [PATCH 1/1] riscv: prevent pipeline stall in __asm_to/copy_from_user Akira Tsukamoto
2021-06-08 11:31   ` David Laight [this message]
2021-06-12  4:05     ` Palmer Dabbelt
2021-06-12 12:17       ` David Laight
2021-06-16 10:24         ` Akira Tsukamoto
2021-06-16 10:08       ` Akira Tsukamoto
2021-06-04 16:19 ` [PATCH 0/1] riscv: better network performance with memcpy, uaccess Palmer Dabbelt
2021-06-05  8:02   ` Akira Tsukamoto

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=67dab8dc517f4add8b0c29074a6b3f06@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=akira.tsukamoto@gmail.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=gary@garyguo.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=nickhu@andestech.com \
    --cc=nylon7@andestech.com \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    /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

all inboxes | Powered by JetHome®