From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from xry111.site (xry111.site [89.208.246.23]) by sourceware.org (Postfix) with ESMTPS id 160893870887 for ; Thu, 23 Mar 2023 13:12:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 160893870887 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=xry111.site Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=xry111.site DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1679577161; bh=Ybji5WdIuuR31yYEilwQjUdAgNGWSW9fHteCeXd/RbM=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=KL7pr9BEnVRWQhAWjQmCMIEJ3OML+VgcYMzgPjgWz/73Wjfi75oCcWiOJfnjm0Z0x NKtRVVbcjodH1TgiCbIo5NSAEZvEcLj0NuLnz5k/RyeEVbOUOWuFXsDVZRyJHrRPbK KJ5G3HQzmBnET1FBq+sf307dJVvLxbPCl0veVF/U= Received: from localhost.localdomain (xry111.site [IPv6:2001:470:683e::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 97F5B6616E; Thu, 23 Mar 2023 09:12:40 -0400 (EDT) Message-ID: <7fec684ef1f47ac0072338e2757ec0c245407de5.camel@xry111.site> Subject: Re: [PATCH] LoongArch: Add Syscall Assembly Implementation From: Xi Ruoyao To: caiyinyu , libc-alpha@sourceware.org Cc: adhemerval.zanella@linaro.org Date: Thu, 23 Mar 2023 21:12:39 +0800 In-Reply-To: <8a4e2e72-9daf-d264-f49d-719daa2407b5@loongson.cn> References: <20230323084013.1100656-1-caiyinyu@loongson.cn> <8a4e2e72-9daf-d264-f49d-719daa2407b5@loongson.cn> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.0 MIME-Version: 1.0 X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,LIKELY_SPAM_FROM,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, 2023-03-23 at 20:01 +0800, caiyinyu wrote: > Without this patch(objdump -d libc.so...): >=20 > 00000000000dd45c : > =C2=A0=C2=A0=C2=A0 dd45c:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 02fec063=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 addi.d=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 $sp, $sp, -80(0xfb0) > =C2=A0=C2=A0=C2=A0 dd460:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 02c0606c=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 addi.d=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 $t0, $sp, 24(0x18) /* snip */ Yes, I know this will save some cycles. The problem is during a syscall, the context switch etc. uses much more time than the instruction sequence in syscall() function itself. I wrote a program which calls syscall(SYS_getpid) 1000000 times.=20 Without the (unpatched) Glibc syscall(), the time consumed is 1.376s; with a syscall() in asm (similar to the one in the patch but I changed the __syscall_error tail call to a "break 0"), the time consumed is 1.203s (0.173s faster). So we can say it saves 17.3us (about 430 cycles) per syscall. I doubt if the improvement is really worthy for real life applications: is there any application invoking syscalls so intensively that the 17.3us will accumulate into something we can feel? --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University