All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/5] riscv: improving uaccess with logs from network bench
@ 2021-06-19 11:21 ` Akira Tsukamoto
  0 siblings, 0 replies; 32+ messages in thread
From: Akira Tsukamoto @ 2021-06-19 11:21 UTC (permalink / raw)
  To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Akira Tsukamoto,
	linux-kernel, linux-riscv

Optimizing copy_to_user and copy_from_user.

I rewrote the functions in v2, heavily influenced by Garry's memcpy
function [1].
The functions must be written in assembler to handle page faults manually
inside the function.

With the changes, improves in the percentage usage and some performance
of network speed in UDP packets.
Only patching copy_user. Using the original memcpy.

All results are from the same base kernel, same rootfs and same
BeagleV beta board.

Comparison by "perf top -Ue task-clock" while running iperf3.

--- TCP recv ---
  * Before
   40.40%  [kernel]  [k] memcpy
   33.09%  [kernel]  [k] __asm_copy_to_user
  * After
   50.35%  [kernel]  [k] memcpy
   13.76%  [kernel]  [k] __asm_copy_to_user

--- TCP send ---
  * Before
   19.96%  [kernel]  [k] memcpy
    9.84%  [kernel]  [k] __asm_copy_to_user
  * After
   14.27%  [kernel]  [k] memcpy
    7.37%  [kernel]  [k] __asm_copy_to_user

--- UDP send ---
  * Before
   25.18%  [kernel]  [k] memcpy
   22.50%  [kernel]  [k] __asm_copy_to_user
  * After
   28.90%  [kernel]  [k] memcpy
    9.49%  [kernel]  [k] __asm_copy_to_user

--- UDP recv ---
  * Before
   44.45%  [kernel]  [k] memcpy
   31.04%  [kernel]  [k] __asm_copy_to_user
  * After
   55.62%  [kernel]  [k] memcpy
   11.22%  [kernel]  [k] __asm_copy_to_user

Processing network packets require a lot of unaligned access for the packet
header, which is not able to change the design of the header format to be
aligned.
And user applications call system calls with a large buffer for send/recf()
and sendto/recvfrom() to repeat less function calls for the optimization.

v1 -> v2:
- Added shift copy
- Separated patches for readability of changes in assembler
- Using perf results

[1] https://lkml.org/lkml/2021/2/16/778

Akira Tsukamoto (5):
   riscv: __asm_to/copy_from_user: delete existing code
   riscv: __asm_to/copy_from_user: Adding byte copy first
   riscv: __asm_to/copy_from_user: Copy until dst is aligned address
   riscv: __asm_to/copy_from_user: Bulk copy while shifting misaligned
     data
   riscv: __asm_to/copy_from_user: Bulk copy when both src dst are
     aligned

  arch/riscv/lib/uaccess.S | 181 +++++++++++++++++++++++++++++++--------
  1 file changed, 146 insertions(+), 35 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2021-07-12 21:25 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-19 11:21 [PATCH v2 0/5] riscv: improving uaccess with logs from network bench Akira Tsukamoto
2021-06-19 11:21 ` Akira Tsukamoto
2021-06-19 11:34 ` [PATCH 1/5] riscv: __asm_to/copy_from_user: delete existing code Akira Tsukamoto
2021-06-19 11:34   ` Akira Tsukamoto
2021-06-21 11:45   ` David Laight
2021-06-21 11:45     ` David Laight
2021-06-21 13:55     ` Akira Tsukamoto
2021-06-21 13:55       ` Akira Tsukamoto
2021-06-19 11:35 ` [PATCH 2/5] riscv: __asm_to/copy_from_user: Adding byte copy first Akira Tsukamoto
2021-06-19 11:35   ` Akira Tsukamoto
2021-06-19 11:36 ` [PATCH 3/5] riscv: __asm_to/copy_from_user: Copy until dst is aligned Akira Tsukamoto
2021-06-19 11:36   ` Akira Tsukamoto
2021-06-19 11:37 ` [PATCH 4/5] riscv: __asm_to/copy_from_user: Bulk copy while shifting Akira Tsukamoto
2021-06-19 11:37   ` Akira Tsukamoto
2021-06-19 11:43 ` [PATCH 5/5] riscv: __asm_to/copy_from_user: Bulk copy when both src, dst are aligned Akira Tsukamoto
2021-06-19 11:43   ` Akira Tsukamoto
2021-06-21 11:55   ` David Laight
2021-06-21 11:55     ` David Laight
2021-06-21 14:13     ` Akira Tsukamoto
2021-06-21 14:13       ` Akira Tsukamoto
2021-06-20 10:02 ` [PATCH v2 0/5] riscv: improving uaccess with logs from network bench Ben Dooks
2021-06-20 10:02   ` Ben Dooks
2021-06-20 16:36   ` Akira Tsukamoto
2021-06-20 16:36     ` Akira Tsukamoto
2021-06-22  8:30 ` Ben Dooks
2021-06-22  8:30   ` Ben Dooks
2021-06-22 12:05   ` Akira Tsukamoto
2021-06-22 12:05     ` Akira Tsukamoto
2021-06-22 17:45     ` Ben Dooks
2021-06-22 17:45       ` Ben Dooks
2021-07-12 21:24 ` Ben Dooks
2021-07-12 21:24   ` Ben Dooks

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.