From: caiyinyu <caiyinyu@loongson.cn>
To: Xi Ruoyao <xry111@xry111.site>, libc-alpha@sourceware.org
Cc: adhemerval.zanella@linaro.org
Subject: Re: [PATCH] LoongArch: Add Syscall Assembly Implementation
Date: Thu, 23 Mar 2023 20:01:18 +0800 [thread overview]
Message-ID: <8a4e2e72-9daf-d264-f49d-719daa2407b5@loongson.cn> (raw)
In-Reply-To: <c969ecf793e73e79b7723dc8b1b7d71a7e48ec6a.camel@xry111.site>
在 2023/3/23 下午5:25, Xi Ruoyao 写道:
> General question: is there a notable benefit optimizing syscall with
> assembly? AFAIK nobody will put syscall on a hot path, and the cycles
> saved by using the assembly implementation should be negligible
> comparing with all the cost of context switch etc.
Yes.
New patch:
https://sourceware.org/pipermail/libc-alpha/2023-March/146588.html
Without this patch(objdump -d libc.so...):
00000000000dd45c <syscall>:
dd45c: 02fec063 addi.d $sp, $sp, -80(0xfb0)
dd460: 02c0606c addi.d $t0, $sp, 24(0x18)
dd464: 29c06065 st.d $a1, $sp, 24(0x18)
dd468: 29c08066 st.d $a2, $sp, 32(0x20)
dd46c: 29c0a067 st.d $a3, $sp, 40(0x28)
dd470: 29c0c068 st.d $a4, $sp, 48(0x30)
dd474: 29c0e069 st.d $a5, $sp, 56(0x38)
dd478: 29c1206b st.d $a7, $sp, 72(0x48)
dd47c: 29c1006a st.d $a6, $sp, 64(0x40)
dd480: 0015008b move $a7, $a0
dd484: 29c0206c st.d $t0, $sp, 8(0x8)
dd488: 001500a4 move $a0, $a1
dd48c: 001500c5 move $a1, $a2
dd490: 001500e6 move $a2, $a3
dd494: 00150107 move $a3, $a4
dd498: 00150128 move $a4, $a5
dd49c: 00150149 move $a5, $a6
dd4a0: 002b0000 syscall 0x0
dd4a4: 15ffffec lu12i.w $t0, -1(0xfffff)
dd4a8: 68000d84 bltu $t0, $a0, 12(0xc)
# dd4b4 <syscall+0x58>
dd4ac: 02c14063 addi.d $sp, $sp, 80(0x50)
dd4b0: 4c000020 jirl $zero, $ra, 0
dd4b4: 1a00128c pcalau12i $t0, 148(0x94)
dd4b8: 28d9e18c ld.d $t0, $t0, 1656(0x678)
dd4bc: 0011100d sub.w $t1, $zero, $a0
dd4c0: 02bffc04 addi.w $a0, $zero, -1(0xfff)
dd4c4: 3818098d stx.w $t1, $t0, $tp
dd4c8: 02c14063 addi.d $sp, $sp, 80(0x50)
dd4cc: 4c000020 jirl $zero, $ra, 0
>
> On Thu, 2023-03-23 at 16:40 +0800, caiyinyu wrote:
>> + ENTRY (syscall)
>> + move t0, a7
>> + move a7, a0 /* Syscall number -> a0. */
>> + move a0, a1 /* shift arg1 - arg6. */
>> + move a1, a2
>> + move a2, a3
>> + move a3, a4
>> + move a4, a5
>> + move a5, a6
>> + move a6, t0 /* arg7 is saved in t0. */
>> + syscall 0 /* Do the system call. */
>> + lu12i.w t0, -1
> "li.w t0, -4096" will do the same thing, and be more readable.
>
> And this line seems indented with a tab, while other lines are indented
> with 8 spaces.
Fixed
>> + bltu t0, a0, L (error)
>> + ret /* Return to caller. */
> "ret" is not recognized by GNU assembler <= 2.39, it's better to use
> the old-style "jr ra" for backward compatibility.
Fixed.
>
>> +
>> +L (error):
>> + b __syscall_error
next prev parent reply other threads:[~2023-03-23 12:01 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-23 8:40 caiyinyu
2023-03-23 9:25 ` Xi Ruoyao
2023-03-23 12:01 ` caiyinyu [this message]
2023-03-23 13:12 ` Andreas Schwab
2023-03-23 13:34 ` Xi Ruoyao
2023-03-23 13:43 ` Xi Ruoyao
2023-03-23 17:34 ` Xi Ruoyao
2023-03-23 18:26 ` Xi Ruoyao
2023-03-23 18:40 ` Adhemerval Zanella Netto
2023-03-23 19:08 ` Xi Ruoyao
2023-03-23 13:12 ` Xi Ruoyao
2023-03-23 12:00 caiyinyu
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=8a4e2e72-9daf-d264-f49d-719daa2407b5@loongson.cn \
--to=caiyinyu@loongson.cn \
--cc=adhemerval.zanella@linaro.org \
--cc=libc-alpha@sourceware.org \
--cc=xry111@xry111.site \
/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).