From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by sourceware.org (Postfix) with ESMTPS id EA0B938708C9 for ; Tue, 24 Nov 2020 18:20:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org EA0B938708C9 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=lukma@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4CgXPF0CnVz1qs3D; Tue, 24 Nov 2020 19:20:01 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CgXPD73MSz1tD98; Tue, 24 Nov 2020 19:20:00 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id cyPaDi7YBJ_q; Tue, 24 Nov 2020 19:19:59 +0100 (CET) X-Auth-Info: bohw7dBCnBc2y1XKNwhLdAzHNm6rUAXz/dZObazsFyQ= Received: from jawa (89-64-5-98.dynamic.chello.pl [89.64.5.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Tue, 24 Nov 2020 19:19:59 +0100 (CET) Date: Tue, 24 Nov 2020 19:19:09 +0100 From: Lukasz Majewski To: Adhemerval Zanella via Libc-alpha Cc: Adhemerval Zanella , Michael Kerrisk Subject: Re: [PATCH 05/13] linux: nptl: Consolidate __futex_abstimed_wait_{cancelable}64 Message-ID: <20201124191909.20913ef4@jawa> In-Reply-To: <20201123195256.3336217-5-adhemerval.zanella@linaro.org> References: <20201123195256.3336217-1-adhemerval.zanella@linaro.org> <20201123195256.3336217-5-adhemerval.zanella@linaro.org> Organization: denx.de X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; boundary="Sig_/VtjaticJy5gexk+8_iK3e4L"; protocol="application/pgp-signature" X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_NUMSUBJECT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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: Tue, 24 Nov 2020 18:20:03 -0000 --Sig_/VtjaticJy5gexk+8_iK3e4L Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hi Adhemerval, > The only different is how to issue the syscall. >=20 > Checked on x86_64-linux-gnu and i686-linux-gnu. > --- > sysdeps/nptl/futex-internal.c | 111 > +++++++++++----------------------- 1 file changed, 35 insertions(+), > 76 deletions(-) >=20 > diff --git a/sysdeps/nptl/futex-internal.c > b/sysdeps/nptl/futex-internal.c index e4a14b477c..f9a2e28ee6 100644 > --- a/sysdeps/nptl/futex-internal.c > +++ b/sysdeps/nptl/futex-internal.c > @@ -24,10 +24,10 @@ > =20 > #ifndef __ASSUME_TIME64_SYSCALLS > static int > -__futex_abstimed_wait_cancelable32 (unsigned int* futex_word, > - unsigned int expected, int op, > - const struct __timespec64* > abstime, > - int private) > +__futex_abstimed_wait_common32 (unsigned int* futex_word, > + unsigned int expected, int op, > + const struct __timespec64* abstime, > + int private, bool cancel) > { > struct timespec ts32, *pts32 =3D NULL; > if (abstime !=3D NULL) > @@ -39,34 +39,16 @@ __futex_abstimed_wait_cancelable32 (unsigned int* > futex_word, pts32 =3D &ts32; > } > =20 > - return INTERNAL_SYSCALL_CANCEL (futex, futex_word, op, expected, > + if (cancel) > + return INTERNAL_SYSCALL_CANCEL (futex, futex_word, op, expected, > + pts32, NULL /* Unused. */, > + FUTEX_BITSET_MATCH_ANY); > + else > + return INTERNAL_SYSCALL_CALL (futex, futex_word, op, expected, > pts32, NULL /* Unused. */, > FUTEX_BITSET_MATCH_ANY); > } > =20 > -static int > -__futex_abstimed_wait32 (unsigned int* futex_word, > - unsigned int expected, clockid_t clockid, > - const struct __timespec64* abstime, > - int private) > -{ > - struct timespec ts32; > - > - if (abstime !=3D NULL && ! in_time_t_range (abstime->tv_sec)) > - return -EOVERFLOW; > - > - unsigned int clockbit =3D (clockid =3D=3D CLOCK_REALTIME) ? > - FUTEX_CLOCK_REALTIME : 0; > - int op =3D __lll_private_flag (FUTEX_WAIT_BITSET | clockbit, > private); - > - if (abstime !=3D NULL) > - ts32 =3D valid_timespec64_to_timespec (*abstime); > - > - return INTERNAL_SYSCALL_CALL (futex, futex_word, op, expected, > - abstime !=3D NULL ? &ts32 : NULL, > - NULL /* Unused. */, > FUTEX_BITSET_MATCH_ANY); -} > - > static int > __futex_clock_wait_bitset32 (int *futexp, int val, clockid_t clockid, > const struct __timespec64 *abstime, int > private) @@ -89,11 +71,11 @@ __futex_clock_wait_bitset32 (int > *futexp, int val, clockid_t clockid, } > #endif /* ! __ASSUME_TIME64_SYSCALLS */ > =20 > -int > -__futex_abstimed_wait_cancelable64 (unsigned int* futex_word, > - unsigned int expected, clockid_t > clockid, > - const struct __timespec64* > abstime, > - int private) > +static int > +__futex_abstimed_wait_common64 (unsigned int* futex_word, > + unsigned int expected, clockid_t > clockid, > + const struct __timespec64* abstime, > + int private, bool cancel) > { > unsigned int clockbit; > int err; > @@ -109,13 +91,18 @@ __futex_abstimed_wait_cancelable64 (unsigned > int* futex_word, clockbit =3D (clockid =3D=3D CLOCK_REALTIME) ? > FUTEX_CLOCK_REALTIME : 0; int op =3D __lll_private_flag > (FUTEX_WAIT_BITSET | clockbit, private);=20 > - err =3D INTERNAL_SYSCALL_CANCEL (futex_time64, futex_word, op, > expected, > - abstime, NULL /* Unused. */, > + if (cancel) > + err =3D INTERNAL_SYSCALL_CANCEL (futex_time64, futex_word, op, > expected, > + abstime, NULL /* Unused. */, > + FUTEX_BITSET_MATCH_ANY); > + else > + err =3D INTERNAL_SYSCALL_CALL (futex_time64, futex_word, op, > expected, > + abstime, NULL /* Ununsed. */, > FUTEX_BITSET_MATCH_ANY); > #ifndef __ASSUME_TIME64_SYSCALLS > if (err =3D=3D -ENOSYS) > - err =3D __futex_abstimed_wait_cancelable32 (futex_word, expected, > - op, abstime, private); > + err =3D __futex_abstimed_wait_common32 (futex_word, expected, op, > abstime, > + private, cancel); > #endif > =20 > switch (err) > @@ -145,46 +132,18 @@ __futex_abstimed_wait64 (unsigned int* > futex_word, unsigned int expected, clockid_t clockid, > const struct __timespec64* abstime, int > private) { > - unsigned int clockbit; > - int err; > - > - /* Work around the fact that the kernel rejects negative timeout > values > - despite them being valid. */ > - if (__glibc_unlikely ((abstime !=3D NULL) && (abstime->tv_sec < 0))) > - return ETIMEDOUT; > - > - if (! lll_futex_supported_clockid (clockid)) > - return EINVAL; > - > - clockbit =3D (clockid =3D=3D CLOCK_REALTIME) ? FUTEX_CLOCK_REALTIME : = 0; > - int op =3D __lll_private_flag (FUTEX_WAIT_BITSET | clockbit, > private); - > - err =3D INTERNAL_SYSCALL_CALL (futex_time64, futex_word, op, > expected, > - abstime, NULL /* Unused. */, > - FUTEX_BITSET_MATCH_ANY); > -#ifndef __ASSUME_TIME64_SYSCALLS > - if (err =3D=3D -ENOSYS) > - err =3D __futex_abstimed_wait32 (futex_word, expected, > - clockid, abstime, private); > -#endif > - switch (err) > - { > - case 0: > - case -EAGAIN: > - case -EINTR: > - case -ETIMEDOUT: > - return -err; > + return __futex_abstimed_wait_common64 (futex_word, expected, > clockid, > + abstime, private, false); > +} > =20 > - case -EFAULT: /* Must have been caused by a glibc or application > bug. */ > - case -EINVAL: /* Either due to wrong alignment, unsupported > - clockid or due to the timeout not being > - normalized. Must have been caused by a glibc or > - application bug. */ > - case -ENOSYS: /* Must have been caused by a glibc bug. */ > - /* No other errors are documented at this time. */ > - default: > - futex_fatal_error (); > - } > +int > +__futex_abstimed_wait_cancelable64 (unsigned int* futex_word, > + unsigned int expected, clockid_t > clockid, > + const struct __timespec64* > abstime, > + int private) > +{ > + return __futex_abstimed_wait_common64 (futex_word, expected, > clockid, > + abstime, private, true); > } > =20 > int Thanks for making this consolidation. Indeed there is now only difference in issuing the syscall. 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_/VtjaticJy5gexk+8_iK3e4L Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEgAyFJ+N6uu6+XupJAR8vZIA0zr0FAl+9Tp0ACgkQAR8vZIA0 zr3qWgf5AeFC7qzJgsm4WIbtHHBDjcghjKUzz9G2A2vA7AB5laYivUIei6e+7jNq 0KQEnRTuJHGUOoOmIvVkg36aWJh4Q2Hp75Ev9F1moRfH5x6voBh888NKGBuDuY8D 28ftUaxFtIxwj2k7v5ALxnczj3wMmYAN1nzPYdf09gpxzhqBRDAQwT+1nJUi2O3r 5yI5B1K031i5YFLlTi0ClVbhsw6Ro97W5eRPrsgdBkHZQ4vSeM2vQUrONZhPl9MX v8IUPfAp+bIZJwp9gekcCWYBEwBfOkrmKTkFXjsHnd/5BVjmJbALR8U7u6Eetiuj mZY56kfoQL4+r6jtrqpmK1wB1rElyw== =nNfv -----END PGP SIGNATURE----- --Sig_/VtjaticJy5gexk+8_iK3e4L--