From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 47A0BC433FE for ; Fri, 14 Oct 2022 14:37:23 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4MpprK4vNzz3fgR for ; Sat, 15 Oct 2022 01:37:21 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.helo=relay.hostedemail.com (client-ip=216.40.44.14; helo=relay.hostedemail.com; envelope-from=joe@perches.com; receiver=) Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4MppLv5Mskz3ffy for ; Sat, 15 Oct 2022 01:15:17 +1100 (AEDT) Received: from omf15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id B3E9D4099E; Fri, 14 Oct 2022 14:15:12 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf15.hostedemail.com (Postfix) with ESMTPA id 06F541C; Fri, 14 Oct 2022 14:14:56 +0000 (UTC) Message-ID: <043b9474f83b2da34bce5ff94b9aa3b735b70d4f.camel@perches.com> Subject: Re: [PATCH AUTOSEL 4.9 1/3] powerpc/selftests: Use timersub() for gettimeofday() From: Joe Perches To: Sasha Levin , linux-kernel@vger.kernel.org, stable@vger.kernel.org Date: Fri, 14 Oct 2022 07:15:08 -0700 In-Reply-To: <20221014135502.2110218-1-sashal@kernel.org> References: <20221014135502.2110218-1-sashal@kernel.org> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4 (3.44.4-2.fc36) MIME-Version: 1.0 X-Stat-Signature: 3zgjaw88zojn6q9khoy8omazrsq4orrh X-Rspamd-Server: rspamout05 X-Rspamd-Queue-Id: 06F541C X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX190Yuwm6bfJNyNHFDdGFIA6O0pYyJESv1I= X-HE-Tag: 1665756896-52267 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ye xingchen , Zeal Robot , linuxppc-dev@lists.ozlabs.org, linux-kselftest@vger.kernel.org, shuah@kernel.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Fri, 2022-10-14 at 09:54 -0400, Sasha Levin wrote: > From: ye xingchen >=20 > [ Upstream commit c814bf958926ff45a9c1e899bd001006ab6cfbae ] >=20 > Use timersub() function to simplify the code. Why should a code simplification be backported? >=20 > Reported-by: Zeal Robot > Signed-off-by: ye xingchen > Signed-off-by: Michael Ellerman > Link: https://lore.kernel.org/r/20220816105106.82666-1-ye.xingchen@zte.co= m.cn > Signed-off-by: Sasha Levin > --- > tools/testing/selftests/powerpc/benchmarks/gettimeofday.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) >=20 > diff --git a/tools/testing/selftests/powerpc/benchmarks/gettimeofday.c b/= tools/testing/selftests/powerpc/benchmarks/gettimeofday.c > index 3af3c21e8036..7f4bb84f1c9c 100644 > --- a/tools/testing/selftests/powerpc/benchmarks/gettimeofday.c > +++ b/tools/testing/selftests/powerpc/benchmarks/gettimeofday.c > @@ -12,7 +12,7 @@ static int test_gettimeofday(void) > { > int i; > =20 > - struct timeval tv_start, tv_end; > + struct timeval tv_start, tv_end, tv_diff; > =20 > gettimeofday(&tv_start, NULL); > =20 > @@ -20,7 +20,9 @@ static int test_gettimeofday(void) > gettimeofday(&tv_end, NULL); > } > =20 > - printf("time =3D %.6f\n", tv_end.tv_sec - tv_start.tv_sec + (tv_end.tv_= usec - tv_start.tv_usec) * 1e-6); > + timersub(&tv_start, &tv_end, &tv_diff); > + > + printf("time =3D %.6f\n", tv_diff.tv_sec + (tv_diff.tv_usec) * 1e-6); > =20 > return 0; > }