Linux Kernel Selftest development
 help / color / mirror / Atom feed
* [PATCH v1] tools: timers: fix freq average calculation
@ 2023-07-06  3:22 Minjie Du
  2023-07-06  3:46 ` John Stultz
  0 siblings, 1 reply; 3+ messages in thread
From: Minjie Du @ 2023-07-06  3:22 UTC (permalink / raw)
  To: John Stultz, Thomas Gleixner, Stephen Boyd, Shuah Khan,
	open list:TIMEKEEPING, CLOCKSOURCE CORE, NTP, ALARMTIMER,
	open list:KERNEL SELFTEST FRAMEWORK
  Cc: opensource.kernel, Minjie Du

Delete a duplicate assignment from this function implementation.
The note means ppm is average of the two actual freq samples.
But ppm have a duplicate assignment.

Signed-off-by: Minjie Du <duminjie@vivo.com>
---
 tools/testing/selftests/timers/raw_skew.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/testing/selftests/timers/raw_skew.c b/tools/testing/selftests/timers/raw_skew.c
index 5beceeed0..6eba203f9 100644
--- a/tools/testing/selftests/timers/raw_skew.c
+++ b/tools/testing/selftests/timers/raw_skew.c
@@ -129,8 +129,7 @@ int main(int argc, char **argv)
 	printf("%lld.%i(est)", eppm/1000, abs((int)(eppm%1000)));
 
 	/* Avg the two actual freq samples adjtimex gave us */
-	ppm = (tx1.freq + tx2.freq) * 1000 / 2;
-	ppm = (long long)tx1.freq * 1000;
+	ppm = (long long)(tx1.freq + tx2.freq) * 1000 / 2;
 	ppm = shift_right(ppm, 16);
 	printf(" %lld.%i(act)", ppm/1000, abs((int)(ppm%1000)));
 
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] tools: timers: fix freq average calculation
  2023-07-06  3:22 [PATCH v1] tools: timers: fix freq average calculation Minjie Du
@ 2023-07-06  3:46 ` John Stultz
  2023-07-13 19:33   ` Shuah Khan
  0 siblings, 1 reply; 3+ messages in thread
From: John Stultz @ 2023-07-06  3:46 UTC (permalink / raw)
  To: Minjie Du
  Cc: Thomas Gleixner, Stephen Boyd, Shuah Khan,
	open list:TIMEKEEPING, CLOCKSOURCE CORE, NTP, ALARMTIMER,
	open list:KERNEL SELFTEST FRAMEWORK, opensource.kernel

On Wed, Jul 5, 2023 at 8:23 PM Minjie Du <duminjie@vivo.com> wrote:
>
> Delete a duplicate assignment from this function implementation.
> The note means ppm is average of the two actual freq samples.
> But ppm have a duplicate assignment.
>
> Signed-off-by: Minjie Du <duminjie@vivo.com>
> ---
>  tools/testing/selftests/timers/raw_skew.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/timers/raw_skew.c b/tools/testing/selftests/timers/raw_skew.c
> index 5beceeed0..6eba203f9 100644
> --- a/tools/testing/selftests/timers/raw_skew.c
> +++ b/tools/testing/selftests/timers/raw_skew.c
> @@ -129,8 +129,7 @@ int main(int argc, char **argv)
>         printf("%lld.%i(est)", eppm/1000, abs((int)(eppm%1000)));
>
>         /* Avg the two actual freq samples adjtimex gave us */
> -       ppm = (tx1.freq + tx2.freq) * 1000 / 2;
> -       ppm = (long long)tx1.freq * 1000;
> +       ppm = (long long)(tx1.freq + tx2.freq) * 1000 / 2;

Huh. So yeah, I looked back in my own history and this has been there
forever. I'm guessing I was intending to average the two samples and
then due to reasons I can't remember decided to just use the first in
the short-term for some debugging (with the second assignment) and
committed both.

I think it should be safe, because if the freq values are not the same
the test will return SKIP, so it's unlikely changing this would cause
new test failures.

Acked-by: John Stultz <jstultz@google.com>

Thanks for noticing this and sending this out!
-john

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] tools: timers: fix freq average calculation
  2023-07-06  3:46 ` John Stultz
@ 2023-07-13 19:33   ` Shuah Khan
  0 siblings, 0 replies; 3+ messages in thread
From: Shuah Khan @ 2023-07-13 19:33 UTC (permalink / raw)
  To: John Stultz, Minjie Du
  Cc: Thomas Gleixner, Stephen Boyd, Shuah Khan,
	open list:TIMEKEEPING, CLOCKSOURCE CORE, NTP, ALARMTIMER,
	open list:KERNEL SELFTEST FRAMEWORK, opensource.kernel,
	Shuah Khan

On 7/5/23 21:46, John Stultz wrote:
> On Wed, Jul 5, 2023 at 8:23 PM Minjie Du <duminjie@vivo.com> wrote:
>>
>> Delete a duplicate assignment from this function implementation.
>> The note means ppm is average of the two actual freq samples.
>> But ppm have a duplicate assignment.
>>
>> Signed-off-by: Minjie Du <duminjie@vivo.com>
>> ---
>>   tools/testing/selftests/timers/raw_skew.c | 3 +--
>>   1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/tools/testing/selftests/timers/raw_skew.c b/tools/testing/selftests/timers/raw_skew.c
>> index 5beceeed0..6eba203f9 100644
>> --- a/tools/testing/selftests/timers/raw_skew.c
>> +++ b/tools/testing/selftests/timers/raw_skew.c
>> @@ -129,8 +129,7 @@ int main(int argc, char **argv)
>>          printf("%lld.%i(est)", eppm/1000, abs((int)(eppm%1000)));
>>
>>          /* Avg the two actual freq samples adjtimex gave us */
>> -       ppm = (tx1.freq + tx2.freq) * 1000 / 2;
>> -       ppm = (long long)tx1.freq * 1000;
>> +       ppm = (long long)(tx1.freq + tx2.freq) * 1000 / 2;
> 
> Huh. So yeah, I looked back in my own history and this has been there
> forever. I'm guessing I was intending to average the two samples and
> then due to reasons I can't remember decided to just use the first in
> the short-term for some debugging (with the second assignment) and
> committed both.
> 
> I think it should be safe, because if the freq values are not the same
> the test will return SKIP, so it's unlikely changing this would cause
> new test failures.
> 
> Acked-by: John Stultz <jstultz@google.com>
> 
> Thanks for noticing this and sending this out!
> -john

Applied to linux-kselftest fixes branch for next rc2 or rc3

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-07-13 19:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-06  3:22 [PATCH v1] tools: timers: fix freq average calculation Minjie Du
2023-07-06  3:46 ` John Stultz
2023-07-13 19:33   ` Shuah Khan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox