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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A16FC4332F for ; Fri, 14 Oct 2022 14:21:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230215AbiJNOVc convert rfc822-to-8bit (ORCPT ); Fri, 14 Oct 2022 10:21:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229633AbiJNOVa (ORCPT ); Fri, 14 Oct 2022 10:21:30 -0400 Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA11A1CC747; Fri, 14 Oct 2022 07:21:29 -0700 (PDT) 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 Cc: ye xingchen , Zeal Robot , Michael Ellerman , shuah@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kselftest@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: 8BIT 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2022-10-14 at 09:54 -0400, Sasha Levin wrote: > From: ye xingchen > > [ Upstream commit c814bf958926ff45a9c1e899bd001006ab6cfbae ] > > Use timersub() function to simplify the code. Why should a code simplification be backported? > > 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.com.cn > Signed-off-by: Sasha Levin > --- > tools/testing/selftests/powerpc/benchmarks/gettimeofday.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > 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; > > - struct timeval tv_start, tv_end; > + struct timeval tv_start, tv_end, tv_diff; > > gettimeofday(&tv_start, NULL); > > @@ -20,7 +20,9 @@ static int test_gettimeofday(void) > gettimeofday(&tv_end, NULL); > } > > - printf("time = %.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 = %.6f\n", tv_diff.tv_sec + (tv_diff.tv_usec) * 1e-6); > > return 0; > }