From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from xry111.site (xry111.site [IPv6:2001:470:683e::1]) by sourceware.org (Postfix) with ESMTPS id 2454F3858D20 for ; Sat, 25 Mar 2023 14:08:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2454F3858D20 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=1679753313; bh=BTOEXKlZW4XCFfmsuI4kwOZXaCm4PxrVoLSx5Kpa7sg=; h=From:To:Cc:Subject:Date:From; b=L7WiyQiD8lO53DDVQK4xgryFQwvtl8Suy8UsGEWVvaS19qYNXsYVi5gBNIeD9dPTl xjLKFnfJreo2yRve50QIf7qAAcGQ8+gzcbzXLYAMQDD7EH2bOiZLU6p7tD4YCOF0zw 5t30wfAP8kfcZJpW6Ah9IeNJNwozR7K0hSyZw9iM= Received: from stargazer.. (unknown [IPv6:240e:358:1172:ca00:dc73:854d:832e:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 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 5CC1666479; Sat, 25 Mar 2023 10:08:25 -0400 (EDT) From: Xi Ruoyao To: libc-alpha@sourceware.org Cc: caiyinyu , Wang Xuerui , Adhemerval Zanella Netto , Andreas Schwab , Florian Weimer , Xi Ruoyao Subject: [PATCH v2 0/5] linux: Avoid va_list for generic syscall wrappers if possible Date: Sat, 25 Mar 2023 22:08:10 +0800 Message-Id: <20230325140815.4170296-1-xry111@xry111.site> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,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: Currently GCC generates highly sub-optimal code on architectures where the calling convention prefers registers for arugment passing. This is GCC PR100955. While it's technically a missed-optimization in GCC, it seems not trivial to fix (I've not seen any compiler which can optimize this properly yet). As the generic Linux syscall wrappers often uses a fixed number of arguments, and "overreading" the variable arguments is usually safe (fcntl etc. is already doing this), we can pretend these wrappers were declared with named arguments and make the compiler do right thing. Add a macro __ASSUME_SYSCALL_NAMED_WORKS to control this, which should be defined if we can safely replace "..." with several named arguments. Use an internal function prototype with named arguments if it's defined, for fcntl64, fcntl_nocancel, ioctl, mremap, open64, open64_nocancel, openat64, openat64_nocancel, prctl, ptrace, and generic syscall() wrapper. I've not changed open* without "64" because I don't have a test platform. shm_ctl is also not changed because it contains aggregate variable arugment which is more tricky than integers or pointers. Define this macro for LoongArch, x86-64, and AArch64. This should be also suitable for some other architectures (I think it will be fine on RISC-V) but again I don't have a test platform. This is the first time I make such a large change in Glibc so it's likely I've done something wrong. Please correct me :). Xi Ruoyao (5): linux: Add __ASSUME_SYSCALL_NAMED_WORKS to allow avoiding va_list for generic syscall linux: [__ASSUME_SYSCALL_NAMED_WORKS] Avoid using va_list for various syscall wrappers LoongArch: Define __ASSUME_SYSCALL_NAMED_WORKS for Linux x86_64: Define __ASSUME_SYSCALL_NAMED_WORKS for Linux aarch64: Define __ASSUME_SYSCALL_NAMED_WORKS for Linux include/fcntl.h | 32 ++++++++----- .../unix/sysv/linux/aarch64/kernel-features.h | 9 ++++ sysdeps/unix/sysv/linux/fcntl64.c | 40 +++++++++++++---- sysdeps/unix/sysv/linux/fcntl_nocancel.c | 30 ++++++++++--- sysdeps/unix/sysv/linux/ioctl.c | 38 ++++++++++++---- .../sysv/linux/loongarch/kernel-features.h | 29 ++++++++++++ sysdeps/unix/sysv/linux/mremap.c | 36 +++++++++++++-- sysdeps/unix/sysv/linux/not-cancel.h | 8 ++-- sysdeps/unix/sysv/linux/open64.c | 35 ++++++++++++--- sysdeps/unix/sysv/linux/open64_nocancel.c | 29 ++++++++++-- sysdeps/unix/sysv/linux/openat64.c | 30 +++++++++++-- sysdeps/unix/sysv/linux/openat64_nocancel.c | 29 ++++++++++-- sysdeps/unix/sysv/linux/prctl.c | 23 +++++++++- sysdeps/unix/sysv/linux/ptrace.c | 45 ++++++++++++++----- sysdeps/unix/sysv/linux/syscall.c | 35 +++++++++++---- .../unix/sysv/linux/x86_64/kernel-features.h | 9 ++++ 16 files changed, 382 insertions(+), 75 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/loongarch/kernel-features.h -- 2.40.0