public inbox for [email protected]
 help / color / mirror / Atom feed
From: Alviro Iskandar Setiawan <[email protected]>
To: Ammar Faizi <[email protected]>
Cc: Jens Axboe <[email protected]>,
	Pavel Begunkov <[email protected]>,
	Gilang Fachrezy <[email protected]>,
	VNLX Kernel Department <[email protected]>,
	"GNU/Weeb Mailing List" <[email protected]>,
	io-uring Mailing List <[email protected]>
Subject: Re: [PATCH liburing v1 2/2] register: Simplify `io_uring_register_file_alloc_range()` function
Date: Fri, 6 Jan 2023 22:59:58 +0700	[thread overview]
Message-ID: <CAOG64qOJTRQbEEUMPZoPYzMrPAxN=9=jD+E25KuH7o0yVFa1Jw@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>

On Fri, Jan 6, 2023 at 10:43 PM Ammar Faizi wrote:
> Use a struct initializer instead of memset(). It simplifies the C code
> plus effectively reduces the code size.
>
> Extra bonus on x86-64. It reduces the stack allocation because it
> doesn't need to allocate stack for the local variable @range. It can
> just use 128 bytes of redzone below the `%rsp` (redzone is only
> available in a leaf function).
>
> Before this patch:
>
> ```
>   0000000000003910 <io_uring_register_file_alloc_range>:
>     3910:  push   %rbp
>     3911:  push   %r15
>     3913:  push   %r14
>     3915:  push   %rbx
>     3916:  sub    $0x18,%rsp
>     391a:  mov    %edx,%r14d
>     391d:  mov    %esi,%ebp
>     391f:  mov    %rdi,%rbx
>     3922:  lea    0x8(%rsp),%r15
>     3927:  mov    $0x10,%edx
>     392c:  mov    %r15,%rdi
>     392f:  xor    %esi,%esi
>     3931:  call   3a00 <__uring_memset>
>     3936:  mov    %ebp,0x8(%rsp)
>     393a:  mov    %r14d,0xc(%rsp)
>     393f:  mov    0xc4(%rbx),%edi
>     3945:  mov    $0x1ab,%eax
>     394a:  mov    $0x19,%esi
>     394f:  mov    %r15,%rdx
>     3952:  xor    %r10d,%r10d
>     3955:  syscall
>     3957:  add    $0x18,%rsp
>     395b:  pop    %rbx
>     395c:  pop    %r14
>     395e:  pop    %r15
>     3960:  pop    %rbp
>     3961:  ret
>     3962:  cs nopw 0x0(%rax,%rax,1)
>     396c:  nopl   0x0(%rax)
> ```
>
> After this patch:
>
> ```
>   0000000000003910 <io_uring_register_file_alloc_range>:
>     3910:  mov    %esi,-0x10(%rsp) # set range.off
>     3914:  mov    %edx,-0xc(%rsp)  # set range.len
>     3918:  movq   $0x0,-0x8(%rsp)  # zero the resv
>     3921:  mov    0xc4(%rdi),%edi
>     3927:  lea    -0x10(%rsp),%rdx
>     392c:  mov    $0x1ab,%eax
>     3931:  mov    $0x19,%esi
>     3936:  xor    %r10d,%r10d
>     3939:  syscall
>     393b:  ret
> ```
>
> Signed-off-by: Ammar Faizi <[email protected]>

Reviewed-by: Alviro Iskandar Setiawan <[email protected]>

  reply	other threads:[~2023-01-06 16:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-06 15:42 [PATCH liburing v1 0/2] liburing micro-optimzation Ammar Faizi
2023-01-06 15:42 ` [PATCH liburing v1 1/2] nolibc: Fix bloated memset due to unexpected vectorization Ammar Faizi
2023-01-06 15:56   ` Alviro Iskandar Setiawan
2023-01-06 15:42 ` [PATCH liburing v1 2/2] register: Simplify `io_uring_register_file_alloc_range()` function Ammar Faizi
2023-01-06 15:59   ` Alviro Iskandar Setiawan [this message]
2023-01-06 17:08 ` [PATCH liburing v1 0/2] liburing micro-optimzation Jens Axboe

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='CAOG64qOJTRQbEEUMPZoPYzMrPAxN=9=jD+E25KuH7o0yVFa1Jw@mail.gmail.com' \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /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