From patchwork Mon Mar 21 20:41:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 600310 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qTSRd4fntz9s3T for ; Tue, 22 Mar 2016 07:41:49 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=N2aWuo04; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=DC0jNPNJQ2dv1QUwF8C13fK+AAOTwOx 9QxxBDrBWrldHzAq8KvJIlgjcUEhx/a04T9epbocB2ISs7kAyJCCNcZDbSMcsSNL 07qj4Lufc2EKtwm9vELOlF0KZWAKPG7SAIz3XZowplCWgOJ5pJ/yTDiwXRb1dGeK BKrkSg4P845c= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=cWTzaBShQyGL0Rso+ia60D8Z5mE=; b=N2aWu o04Hqxw3hx+9cEv7j9e/0jVX9BxIhK+4QmpVuTKo2qC7/wB9Kk+rIhIvhPvzI1FF sp6fRJD08bjnVqIe6bSTOFASqyUp+PzRkKgYO8x31U665EyYrEKliLt/MKKmpZwS VoQ7I4ypjfU5Ogi+a9BUsWiOOm+4cRVRjPfY7Y= Received: (qmail 130743 invoked by alias); 21 Mar 2016 20:41:28 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 130673 invoked by uid 89); 21 Mar 2016 20:41:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=1626, libc_hidden_def, 859, 2628 X-HELO: mail-yw0-f171.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=zofWOXU4EfcRpvBzAiiKx07tjgcOY+UaG/WUMx+3zbM=; b=Tudc+7ryfIXdIcPr3V/XKqeqHVRV38PKISSgCmKZY8ykLJXw+ux6QPs827E1Bmpj6p qVrWBCWeOkmXDNPgW9DUw5SGGTAcMri050+YtRXmcVoKiBrkdNy5oIcbRUNvXWJTp7po +uIHFwCovvdDajJ8vSip0SRjSU6SptCDAfK3Lq5wo6KpvruNSrHvksug+954vvziVaPS 7WDvDrXZ7iL9zycUcHUN7cehvs8sJL3h+MmofeXoi7ImW5ypUJKL8LbdyUZBuqyHiRuZ 3DLPQ2ShWkoa2v7pS++eCpPV8KSC4KteEnT+wfpZ0+83OzmxmTmL5L+IkDJVAA5I0Wvn X9VA== X-Gm-Message-State: AD7BkJLT8MX3F5P6P7mk7VBo1rUZFMz2Wf0iS+DDV89oikBtxRIlY/JOQXUnlm1cI4X+fNqL X-Received: by 10.129.50.79 with SMTP id y76mr14443444ywy.290.1458592878776; Mon, 21 Mar 2016 13:41:18 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 2/4] Adjust kernel-features.h for sendmmsg/recvmmsg Date: Mon, 21 Mar 2016 17:41:05 -0300 Message-Id: <1458592867-3057-3-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1458592867-3057-1-git-send-email-adhemerval.zanella@linaro.org> References: <1458592867-3057-1-git-send-email-adhemerval.zanella@linaro.org> This patch cleanups the __ASSUME_RECVMMSG_* and __ASSUME_SENDMMSG_* usage in linux recvmmsg and sendmmsg implementation. It also fixes a bug on i686/x86_64 when building with 2.6.32 kernel support. The changes in this patches are the following: * Remove the __ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL for ports that for current minimum supported kernel already have direct recvmmsg syscall support (microblaze, powerpc, and spart). * Add __ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL define for ports that still uses socketcall interface (i386, m68k, s390). * Remove the __ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL for ports that for current minimum supported kernel alread have direct sendmmsg syscall support (powerpc, sparc). * Add __ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL define for ports that still uses socketcall interface (i386, m68k, microblaze, and s390) Along with the define changes, the linux recvmmsg and sendmmsg implementation now uses a different strategy to use direct syscall, socketcall, runtime socketcall (which issues a socketcall and update have_*), and stub function: 1. If the architecture defines __ASSUME_{RECVMMSG,SENDMMSG}_SYSCALL the direct syscall is used instead. This is the default behavior for most ports that do not support socketcall. 2. Otherwise, if the architecture defines __ASSUME_{RECVMMSG,SENDMMSG}_SYSCALL_WITH_SOCKETCALL the socketcall interface will be used instead. Different than the default __ASSUME_{RECVMMSG,SENDMMSG}_SOCKETCALL, this define is set per architecture. 3. Otherwise, if the architecure define __ASSUME_SOCKETCALL the runtime socketcall call will be used which will test if the kernel supports {sendmmsg,recvmmsg} and set have_{recvmmsg,sendmmsg} accordingly. 4. Otherwise the stub warning implementation will be use. This approach also fixes the following i386/x86_64 issue: * For i686 with kernel 3.2.0 but with --enable-kernel=2.6.32 (minimum supported kernel) will use direct syscall where it should use runtime socketcall * For x86_64 with kernel 3.2.0 but with --enable-kernel=2.6.32 (minimum kernel) will use syscall where it should use stub. Tested on i686, x86_64, aarch64, armhf, and powerpc64le. * sysdeps/unix/sysv/linux/i386/kernel-features.h (__ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL): Remove define. [__LINUX_KERNEL_VERSION > 0x030000] (__ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL): Add define. * sysdeps/unix/sysv/linux/m68k/kernel-features.h (__ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL): Likewise. (__ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL): Likewise. * sysdeps/unix/sysv/linux/microblaze/kernel-features.h (__ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL): Likewise. (__ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL): Remove define. * sysdeps/unix/sysv/linux/powerpc/kernel-features.h (__ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL): Likewise. * sysdeps/unix/sysv/linux/s390/kernel-features.h (__ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL): Add define. (__ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL): Likewise. * sysdeps/unix/sysv/linux/sh/kernel-features.h (__ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL): Remove define. * sysdeps/unix/sysv/linux/sparc/kernel-features.h (__ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL): Likewise. (__ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL): Likewise. * sysdeps/unix/sysv/linux/mips/mips32/recvmmsg.c: Remove file. * sysdeps/unix/sysv/linux/mips/mips32/sendmmsg.c: Likewise. * sysdeps/unix/sysv/linux/recvmmsg.c (recvmmsg): Refactor __ASSUME macro usage. * sysdeps/unix/sysv/linux/sendmmsg.c (__sendmmsg): Likewise. --- ChangeLog | 26 +++++++++++++++++++ sysdeps/unix/sysv/linux/i386/kernel-features.h | 8 ++++-- sysdeps/unix/sysv/linux/m68k/kernel-features.h | 2 ++ .../unix/sysv/linux/microblaze/kernel-features.h | 4 +-- sysdeps/unix/sysv/linux/mips/mips32/recvmmsg.c | 29 ---------------------- sysdeps/unix/sysv/linux/mips/mips32/sendmmsg.c | 29 ---------------------- sysdeps/unix/sysv/linux/powerpc/kernel-features.h | 3 --- sysdeps/unix/sysv/linux/recvmmsg.c | 26 +++++-------------- sysdeps/unix/sysv/linux/s390/kernel-features.h | 2 ++ sysdeps/unix/sysv/linux/sendmmsg.c | 27 ++++++-------------- sysdeps/unix/sysv/linux/sparc/kernel-features.h | 6 ----- 11 files changed, 50 insertions(+), 112 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/mips/mips32/recvmmsg.c delete mode 100644 sysdeps/unix/sysv/linux/mips/mips32/sendmmsg.c diff --git a/sysdeps/unix/sysv/linux/i386/kernel-features.h b/sysdeps/unix/sysv/linux/i386/kernel-features.h index 148963c..3e25476 100644 --- a/sysdeps/unix/sysv/linux/i386/kernel-features.h +++ b/sysdeps/unix/sysv/linux/i386/kernel-features.h @@ -21,10 +21,14 @@ #define __ASSUME_SOCKETCALL 1 /* The recvmmsg syscall was added for i386 in 2.6.33. */ -#define __ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL 1 +#if __LINUX_KERNEL_VERSION >= 0x020621 +# define __ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL 1 +#endif /* The sendmmsg syscall was added for i386 in 3.0. */ -#define __ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL 1 +#if __LINUX_KERNEL_VERSION >= 0x030000 +# define __ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL 1 +#endif /* Direct socketcalls available with kernel 4.3. */ #if __LINUX_KERNEL_VERSION >= 0x040300 diff --git a/sysdeps/unix/sysv/linux/m68k/kernel-features.h b/sysdeps/unix/sysv/linux/m68k/kernel-features.h index dec04f0..0945779 100644 --- a/sysdeps/unix/sysv/linux/m68k/kernel-features.h +++ b/sysdeps/unix/sysv/linux/m68k/kernel-features.h @@ -19,6 +19,8 @@ /* m68k uses socketcall. */ #define __ASSUME_SOCKETCALL 1 +#define __ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL 1 +#define __ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL 1 /* Direct socketcalls available with kernel 4.3. */ #if __LINUX_KERNEL_VERSION >= 0x040300 diff --git a/sysdeps/unix/sysv/linux/microblaze/kernel-features.h b/sysdeps/unix/sysv/linux/microblaze/kernel-features.h index db471ef..e25b6ed 100644 --- a/sysdeps/unix/sysv/linux/microblaze/kernel-features.h +++ b/sysdeps/unix/sysv/linux/microblaze/kernel-features.h @@ -18,6 +18,7 @@ /* MicroBlaze uses socketcall. */ #define __ASSUME_SOCKETCALL 1 +#define __ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL 1 /* All supported kernel versions for MicroBlaze have these syscalls. */ #define __ASSUME_SOCKET_SYSCALL 1 @@ -36,9 +37,6 @@ #define __ASSUME_GETSOCKOPT_SYSCALL 1 #define __ASSUME_SETSOCKOPT_SYSCALL 1 -/* Support for the accept4 and recvmmsg syscalls was added in 2.6.33. */ -#define __ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL 1 - /* Support for the futimesat syscall was added in 2.6.33. */ #define __ASSUME_FUTIMESAT 1 diff --git a/sysdeps/unix/sysv/linux/mips/mips32/recvmmsg.c b/sysdeps/unix/sysv/linux/mips/mips32/recvmmsg.c deleted file mode 100644 index c2a3440..0000000 --- a/sysdeps/unix/sysv/linux/mips/mips32/recvmmsg.c +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (C) 2010-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -/* Avoid recvmmsg.c trying to use a definition based on the socketcall - syscall and internal_recvmmsg.S. */ - -#include -#include - -#include -#include - -#undef __NR_socketcall - -#include diff --git a/sysdeps/unix/sysv/linux/mips/mips32/sendmmsg.c b/sysdeps/unix/sysv/linux/mips/mips32/sendmmsg.c deleted file mode 100644 index 7cd4e15..0000000 --- a/sysdeps/unix/sysv/linux/mips/mips32/sendmmsg.c +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (C) 2011-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -/* Avoid sendmmsg.c trying to use a definition based on the socketcall - syscall and internal_sendmmsg.S. */ - -#include -#include - -#include -#include - -#undef __NR_socketcall - -#include diff --git a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h index 5449f18..825c0f0 100644 --- a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h +++ b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h @@ -37,7 +37,4 @@ #define __ASSUME_GETSOCKOPT_SYSCALL 1 #define __ASSUME_SETSOCKOPT_SYSCALL 1 -/* The sendmmsg syscall was added for PowerPC in 3.0. */ -#define __ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL 1 - #include_next diff --git a/sysdeps/unix/sysv/linux/recvmmsg.c b/sysdeps/unix/sysv/linux/recvmmsg.c index bf18260..fb3f325 100644 --- a/sysdeps/unix/sysv/linux/recvmmsg.c +++ b/sysdeps/unix/sysv/linux/recvmmsg.c @@ -16,39 +16,26 @@ License along with the GNU C Library; if not, see . */ -#include #include - #include -#include -#include - -/* Do not use the recvmmsg syscall on socketcall architectures unless - it was added at the same time as the socketcall support or can be - assumed to be present. */ -#if defined __ASSUME_SOCKETCALL \ - && !defined __ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL \ - && !defined __ASSUME_RECVMMSG_SYSCALL -# undef __NR_recvmmsg -#endif +#include +#include -#ifdef __NR_recvmmsg +#ifdef __ASSUME_RECVMMSG_SYSCALL int recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags, struct timespec *tmo) { return SYSCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, tmo); } -#elif defined __NR_socketcall -# include -# ifdef __ASSUME_RECVMMSG_SOCKETCALL +#elif defined __ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL int recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags, struct timespec *tmo) { return SOCKETCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, tmo); } -# else +#elif defined __ASSUME_SOCKETCALL static int have_recvmmsg; int @@ -87,7 +74,6 @@ recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags, __set_errno (ENOSYS); return -1; } -# endif /* __ASSUME_RECVMMSG_SOCKETCALL */ -#else +#else /* __ASSUME_RECVMMSG_SOCKETCALL */ # include #endif diff --git a/sysdeps/unix/sysv/linux/s390/kernel-features.h b/sysdeps/unix/sysv/linux/s390/kernel-features.h index b3edee4..4656c4a 100644 --- a/sysdeps/unix/sysv/linux/s390/kernel-features.h +++ b/sysdeps/unix/sysv/linux/s390/kernel-features.h @@ -19,6 +19,8 @@ /* S/390 uses socketcall. */ #define __ASSUME_SOCKETCALL 1 +#define __ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL 1 +#define __ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL 1 /* Direct socketcalls available with kernel 4.3. */ #if __LINUX_KERNEL_VERSION >= 0x040300 diff --git a/sysdeps/unix/sysv/linux/sendmmsg.c b/sysdeps/unix/sysv/linux/sendmmsg.c index 6e0d46b..37f0ec9 100644 --- a/sysdeps/unix/sysv/linux/sendmmsg.c +++ b/sysdeps/unix/sysv/linux/sendmmsg.c @@ -16,23 +16,11 @@ License along with the GNU C Library; if not, see . */ -#include #include - #include -#include -#include - -/* Do not use the sendmmsg syscall on socketcall architectures unless - it was added at the same time as the socketcall support or can be - assumed to be present. */ -#if defined __ASSUME_SOCKETCALL \ - && !defined __ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL \ - && !defined __ASSUME_SENDMMSG_SYSCALL -# undef __NR_sendmmsg -#endif +#include -#ifdef __NR_sendmmsg +#ifdef __ASSUME_SENDMMSG_SYSCALL int __sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags) { @@ -40,15 +28,15 @@ __sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags) } libc_hidden_def (__sendmmsg) weak_alias (__sendmmsg, sendmmsg) -#elif defined __NR_socketcall -# include -# ifdef __ASSUME_SENDMMSG_SOCKETCALL +#elif defined __ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL int __sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags) { return SOCKETCALL_CANCEL (sendmmsg, fd, vmessages, vlen, flags); } -# else +libc_hidden_def (__sendmmsg) +weak_alias (__sendmmsg, sendmmsg) +#elif defined __ASSUME_SOCKETCALL static int have_sendmmsg; int @@ -85,9 +73,8 @@ __sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags) __set_errno (ENOSYS); return -1; } -# endif /* __ASSUME_SENDMMSG_SOCKETCALL */ libc_hidden_def (__sendmmsg) weak_alias (__sendmmsg, sendmmsg) -#else +#else /* __ASSUME_SENDMMSG_SOCKETCALL */ # include #endif diff --git a/sysdeps/unix/sysv/linux/sparc/kernel-features.h b/sysdeps/unix/sysv/linux/sparc/kernel-features.h index 386f230..486036d 100644 --- a/sysdeps/unix/sysv/linux/sparc/kernel-features.h +++ b/sysdeps/unix/sysv/linux/sparc/kernel-features.h @@ -23,12 +23,6 @@ /* The accept4 syscall was added for SPARC in 2.6.28. */ #define __ASSUME_ACCEPT4_SYSCALL_WITH_SOCKETCALL 1 -/* The recvmmsg syscall was added for SPARC in 2.6.33. */ -#define __ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL 1 - -/* The sendmmsg syscall was added for SPARC in 3.0. */ -#define __ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL 1 - #include_next /* 32-bit SPARC kernels do not support