From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) by sourceware.org (Postfix) with ESMTPS id AF0B23886C6C for ; Mon, 21 Jun 2021 07:42:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AF0B23886C6C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=denx.de Received: from ktm (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: lukma@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 9BD368291E; Mon, 21 Jun 2021 09:42:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1624261369; bh=zyhs+BJ6c4yQBOayUmeAWymgFw9y69wOYU7yW8k+3A0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=NJv6I7dRciNNbu4aLiUcxkHHIC1uDR6/CONAVsHrPiWhlRr//YDPJ7NYWc6TbIXK4 TBVwkxEv4+2CGZbmkIG5ni1FIl0x0pMe51UnQl8uYUTAq9Gsg9IUwFdhkxVPYENkkx R15Jm1kVDjO3nDmNLUKfnoUSINJ8xGSROT0od3Fjv4JisgtMOdbVhyqeEcLtqgSIZk CAQPUVrmn9xhONHJO45g7AkyD9uPTZULx1zTiOwJkoUf7LhHPdg6t4rRWFNNDTfYVH BWJnWqFNYIwiAXqVCKSsYT4JhapzGpVfryx7JKNOnYYZnxVZkac+FPJ8Oy8Q6DgOvn duN7IL8cNVwOg== Date: Mon, 21 Jun 2021 09:42:48 +0200 From: Lukasz Majewski To: Adhemerval Zanella Cc: libc-alpha@sourceware.org, Carlos O'Donell Subject: Re: [PATCH 04/18] linux: Only use 64-bit syscall if required for ppoll Message-ID: <20210621094248.67e894cd@ktm> In-Reply-To: <20210617115104.1359598-5-adhemerval.zanella@linaro.org> References: <20210617115104.1359598-1-adhemerval.zanella@linaro.org> <20210617115104.1359598-5-adhemerval.zanella@linaro.org> Organization: denx.de X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; boundary="Sig_/tq+Sol.wtiFj1o_DsRghzLr"; protocol="application/pgp-signature" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Jun 2021 07:42:52 -0000 --Sig_/tq+Sol.wtiFj1o_DsRghzLr Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Thu, 17 Jun 2021 08:50:50 -0300 Adhemerval Zanella wrote: > For !__ASSUME_TIME64_SYSCALLS there is no need to issue a 64-bit > syscall if the provided timeout fits in a 32-bit one. The 64-bit > usage should be rare since the timeout is a relative one. This also > avoids the need to use supports_time64() (which breaks the usage case > of live migration like CRIU or similar). >=20 > Checked on i686-linux-gnu on a 4.15 kernel and on a 5.11 kernel > (with and without --enable-kernel=3D5.1) and on x86_64-linux-gnu. > --- > sysdeps/unix/sysv/linux/Makefile | 9 +++++++ > sysdeps/unix/sysv/linux/ppoll.c | 41 > +++++++++++------------------ sysdeps/unix/sysv/linux/tst-ppoll.c | > 15 +++++++++++ 3 files changed, 40 insertions(+), 25 deletions(-) >=20 > diff --git a/sysdeps/unix/sysv/linux/Makefile > b/sysdeps/unix/sysv/linux/Makefile index 294c366e3b..c36ea0e494 100644 > --- a/sysdeps/unix/sysv/linux/Makefile > +++ b/sysdeps/unix/sysv/linux/Makefile > @@ -137,6 +137,15 @@ tests-time64 +=3D \ > =20 > CFLAGS-tst-sigcontext-get_pc.c =3D -fasynchronous-unwind-tables > =20 > +ifeq (yes,$(build-shared)) > +librt =3D $(common-objpfx)rt/librt.so > +else > +librt =3D $(common-objpfx)rt/librt.a > +endif > + > +$(objpfx)tst-ppoll: $(librt) > +$(objpfx)tst-ppoll-time64: $(librt) > + > # Generate the list of SYS_* macros for the system calls (__NR_* > # macros). The file syscall-names.list contains all possible system > # call names, and the generated header file produces SYS_* macros for > diff --git a/sysdeps/unix/sysv/linux/ppoll.c > b/sysdeps/unix/sysv/linux/ppoll.c index 624f14f517..e1ad316e2e 100644 > --- a/sysdeps/unix/sysv/linux/ppoll.c > +++ b/sysdeps/unix/sysv/linux/ppoll.c > @@ -21,9 +21,6 @@ > #include > #include > #include > -#include > -#include > - > =20 > int > __ppoll64 (struct pollfd *fds, nfds_t nfds, const struct > __timespec64 *timeout, @@ -38,40 +35,34 @@ __ppoll64 (struct pollfd > *fds, nfds_t nfds, const struct __timespec64 *timeout, timeout =3D > &tval; } > =20 > - int ret; > - > - if (supports_time64 ()) > - { > #ifndef __NR_ppoll_time64 > # define __NR_ppoll_time64 __NR_ppoll > #endif > + > +#ifdef __ASSUME_TIME64_SYSCALLS > + return SYSCALL_CANCEL (ppoll_time64, fds, nfds, timeout, sigmask, > + __NSIG_BYTES); > +#else > + bool is32bit =3D timeout !=3D NULL > + ? in_time_t_range (timeout->tv_sec) : true; > + int ret; > + if (!is32bit) > + { > ret =3D SYSCALL_CANCEL (ppoll_time64, fds, nfds, timeout, > sigmask, __NSIG_BYTES); > - > if (ret =3D=3D 0 || errno !=3D ENOSYS) > return ret; > - > - mark_time64_unsupported (); > + __set_errno (EOVERFLOW); > + return -1; > } > =20 > -#ifndef __ASSUME_TIME64_SYSCALLS > struct timespec ts32; > - if (timeout) > - { > - if (! in_time_t_range (timeout->tv_sec)) > - { > - __set_errno (EOVERFLOW); > - return -1; > - } > - > - ts32 =3D valid_timespec64_to_timespec (*timeout); > - } > + if (timeout !=3D NULL) > + ts32 =3D valid_timespec64_to_timespec (*timeout); > =20 > - ret =3D SYSCALL_CANCEL (ppoll, fds, nfds, timeout ? &ts32 : NULL, > sigmask, > - __NSIG_BYTES); > + return SYSCALL_CANCEL (ppoll, fds, nfds, timeout ? &ts32 : NULL, > sigmask, > + __NSIG_BYTES); > #endif > - > - return ret; > } > =20 > #if __TIMESIZE !=3D 64 > diff --git a/sysdeps/unix/sysv/linux/tst-ppoll.c > b/sysdeps/unix/sysv/linux/tst-ppoll.c index 9fe6ad07ce..e21e2fcc72 > 100644 --- a/sysdeps/unix/sysv/linux/tst-ppoll.c > +++ b/sysdeps/unix/sysv/linux/tst-ppoll.c > @@ -19,9 +19,11 @@ > #include > #include > #include > +#include > #include > #include > #include > +#include > #include > =20 > static int test_ppoll_timeout (bool zero_tmo) > @@ -41,6 +43,16 @@ static int test_ppoll_timeout (bool zero_tmo) > return 0; > } > =20 > +static void > +test_ppoll_large_timeout (void) > +{ > + support_create_timer (0, 100000000, false, NULL); > + struct timespec ts =3D { TYPE_MAXIMUM (time_t), 0 }; > + struct pollfd fds =3D { -1, 0, 0 }; > + TEST_COMPARE (ppoll (&fds, 1, &ts, 0), -1); > + TEST_VERIFY (errno =3D=3D EINTR || errno =3D=3D EOVERFLOW); > +} > + > static int > do_test (void) > { > @@ -50,6 +62,9 @@ do_test (void) > /* Check if ppoll exits after specified timeout. */ > test_ppoll_timeout (false); > =20 > + /* Check if ppoll with large timeout. */ > + test_ppoll_large_timeout (); > + > return 0; > } > =20 Reviewed-by: Lukasz Majewski Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de --Sig_/tq+Sol.wtiFj1o_DsRghzLr Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEgAyFJ+N6uu6+XupJAR8vZIA0zr0FAmDQQvgACgkQAR8vZIA0 zr2Vowf+ONYCCb3k2pzQL26uCWi3c1vQXfXmaWkaTW6rtZ87XBSZ4o9EQCx3c0G/ RJUFNfzrX5TfY3Npchj+PsbfmudttXm6ivMsc6+8cxHyxChHBRTuwCCWz1GdaAMG hqWPocLs6i88xJDQVu5gWmWETMrPiSHNcVyQCh88YCtESKmHCLAAJSzubEZYq0QZ nGOB/fGohBAiFotXlaR2PXVYE4DCiM0aH/gcrnlGrZSOyBIcGWwRw8I4FfH75haQ bVKMWBCZqVDaCjdMfS0f2Z7Rt8mmw7ftLCb+DYM70EbZfbjasmtBbqm3FVIftTFX SjL3vQHgqF2rCdkiQ+uFKtKFA5LQhw== =Kt+F -----END PGP SIGNATURE----- --Sig_/tq+Sol.wtiFj1o_DsRghzLr--