From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id CBA93385B834 for ; Tue, 24 Mar 2020 19:42:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CBA93385B834 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02OJXqFm180010 for ; Tue, 24 Mar 2020 15:42:49 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ywe7trp47-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 24 Mar 2020 15:42:48 -0400 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 02OJdmqJ109101 for ; Tue, 24 Mar 2020 15:42:48 -0400 Received: from ppma03wdc.us.ibm.com (ba.79.3fa9.ip4.static.sl-reverse.com [169.63.121.186]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ywe7trp3h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 24 Mar 2020 15:42:48 -0400 Received: from pps.filterd (ppma03wdc.us.ibm.com [127.0.0.1]) by ppma03wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 02OJeKHq025277; Tue, 24 Mar 2020 19:42:47 GMT Received: from b01cxnp23033.gho.pok.ibm.com (b01cxnp23033.gho.pok.ibm.com [9.57.198.28]) by ppma03wdc.us.ibm.com with ESMTP id 2ywaw9uq2v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 24 Mar 2020 19:42:47 +0000 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 02OJgkZ150069960 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 24 Mar 2020 19:42:46 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 90DCEAE060; Tue, 24 Mar 2020 19:42:46 +0000 (GMT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 01898AE05C; Tue, 24 Mar 2020 19:42:45 +0000 (GMT) Received: from localhost (unknown [9.80.203.159]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 24 Mar 2020 19:42:45 +0000 (GMT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: References: <20200310162001.11737-1-lamm@linux.ibm.com> <20200323172008.11370-1-lamm@linux.ibm.com> Subject: Re: [PATCH v5] Fix time/tst-cpuclock1 intermitent failures From: "Lucas A. M. Magalhaes" To: "Carlos O'Donell" , libc-alpha@sourceware.org Date: Tue, 24 Mar 2020 16:42:44 -0300 Message-ID: <158507896433.27552.16691153932207550062@localhost.localdomain> User-Agent: alot/0.9 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.645 definitions=2020-03-24_07:2020-03-23, 2020-03-24 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 impostorscore=0 bulkscore=0 phishscore=0 spamscore=0 adultscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=0 malwarescore=0 priorityscore=1501 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003240093 X-Spam-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, 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: Tue, 24 Mar 2020 19:42:51 -0000 Hi Carlos, Thanks for the review. Quoting Carlos O'Donell (2020-03-23 18:06:34) > On 3/23/20 1:20 PM, Lucas A. M. Magalhaes via Libc-alpha wrote: > > + > > +/* Returns TRUE if the observed time is within the given percentage bo= unds of > > +the expected time, and FALSE otherwise. > > +For example the call > > + > > +support_timespec_check_in_range(expected, observed, .5, 1.2); > > + > > +will check if > > + > > +.5 <=3D observed/expected <=3D 1.2 > > + > > +In other words it will check if observed time is within 50% to 120% of > > +the expected time. */ > > +int > > +support_timespec_check_in_range (struct timespec expected, struct time= spec observed, > > + double lower_bound, double upper_bound) > > +{ > > + assert (upper_bound >=3D lower_bound); > > + long expected_norm =3D expected.tv_sec * TIMESPEC_HZ + expected.tv_n= sec; >=20 > This can cause overflow/underflow. >=20 > Please review timespec_add. >=20 > We should set this to a extreme value just like timepsec_add for both ove= rflow/underflow. >=20 > > + assert(expected_norm !=3D 0); >=20 > Why can't expected_norm be zero? >=20 It can't be zero because of the division below. Do you have any suggestion= s on this matter? > If you have an abstract timespec you may want to check against that. >=20 > I would assert that all values are *positive* and write that into the com= ments > above. >=20 > > + long observed_norm =3D observed.tv_sec * TIMESPEC_HZ + observed.tv_n= sec; > > + double ratio =3D (double)observed_norm / expected_norm; > > + return (lower_bound <=3D ratio && ratio <=3D upper_bound); > > +} [...] > > + > > +#include > > diff --git a/time/tst-cpuclock1.c b/time/tst-cpuclock1.c > > index 0120906f23..fe9bb0a31e 100644 > > --- a/time/tst-cpuclock1.c > > +++ b/time/tst-cpuclock1.c > > @@ -26,6 +26,7 @@ > > #include > > #include > > #include > > +#include > > =20 > > /* This function is intended to rack up both user and system time. */ > > static void > > @@ -155,16 +156,11 @@ do_test (void) > > printf ("live PID %d after sleep =3D> %ju.%.9ju\n", > > child, (uintmax_t) after.tv_sec, (uintmax_t) after.tv_nsec); > > =20 > > - struct timespec diff =3D { .tv_sec =3D after.tv_sec - before.tv_sec, > > - .tv_nsec =3D after.tv_nsec - before.tv_nsec }; > > - if (diff.tv_nsec < 0) > > - { > > - --diff.tv_sec; > > - diff.tv_nsec +=3D 1000000000; > > - } > > - if (diff.tv_sec !=3D 0 > > - || diff.tv_nsec > 600000000 > > - || diff.tv_nsec < 100000000) > > + /* The bound values are empirically defined by testing this code ove= r high cpu > > + usage and different nice values. */ > > + struct timespec diff =3D timespec_sub (support_timespec_normalize (a= fter), > > + support_timespec_normalize (before= )); > > + if (!support_timespec_check_in_range (sleeptime, diff, .0025, 1.3)) >=20 > The value of 0.0025 doesn't seem correct, can you please confirm that? >=20 I got values as low as 0,0008s for this. But I can be more restrict. The values lower than 0.1 are less than < 1% of my sample. But these are the o= nes bothering during cpu stress. > This is supposed to be a 0.5s wait, and wait of 1ms doesn't seem correct. >=20 --- Lucas A. M. Magalh=C3=A3es