SCIENTIFIC-LINUX-DEVEL Archives

March 2018

SCIENTIFIC-LINUX-DEVEL@LISTSERV.FNAL.GOV

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Jason Vas Dias <[log in to unmask]>
Reply To:
Jason Vas Dias <[log in to unmask]>
Date:
Wed, 14 Mar 2018 13:48:19 +0000
Content-Type:
multipart/mixed
Parts/Attachments:
The attached kernel patch, which I have running on my
HP EliteDesk i7-4770 4/8 core 3.3-3.9ghz workstation
under Scientific Linux 7.4+, recently upgraded yesterday
to the new kernel-3.10.0-693.21.1.el7.x86 and gcc-4.8.5-16.el7_4.2.x86_64,
allows calls to :
      struct timespec &ts;
      clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
to see about the same latency or less than calls to
      clock_gettime(CLOCK_MONOTONIC, &ts);
which, on the above machine, is now about 20ns, compared
with 300-800ns before the patch, because the vDSO WAS
using
      vdso_fallback_gtod()
, which issues a syscall, entering the kernel and doing kernel <-> user
address space switch and copy_to_user() .

Running the attached timer_latency program:
   $ gcc -o timer_latency timer_latency.c

$ ./timer_latency -?
Usage: timer_latency
 [ -m : use CLOCK_MONOTONIC clock
   (not CLOCK_MONOTONIC_RAW) ;
    -d : dump timespec contents. N_SAMPLES: 100
 ] : Calculates average timer latency (minimum time that can be measured) over
     N_SAMPLES.
$ bash -c 'for ((i=0; i < 10; i++)); do ./timer_latency; done'
sum: 1855
Total time: 0.000001855S - Average Latency: 0.000000018S
sum: 1838
Total time: 0.000001838S - Average Latency: 0.000000018S
sum: 1830
Total time: 0.000001830S - Average Latency: 0.000000018S
sum: 1828
Total time: 0.000001828S - Average Latency: 0.000000018S
sum: 1823
Total time: 0.000001823S - Average Latency: 0.000000018S
sum: 1872
Total time: 0.000001872S - Average Latency: 0.000000018S
sum: 1834
Total time: 0.000001834S - Average Latency: 0.000000018S
sum: 1848
Total time: 0.000001848S - Average Latency: 0.000000018S
sum: 1802
Total time: 0.000001802S - Average Latency: 0.000000018S
sum: 1865
Total time: 0.000001865S - Average Latency: 0.000000018S

Under unpatched  3.10.0-693.21.1.el7.x86_64 kernel, the
same program produces widely varying latency
results between 200 and 1000ns .

I applied the patch by downloading the kernel-3.10.0-693.21.1.el7.x86_64.srpm ,
editing the kernel.spec file to produce the attached kernel.spec which
applies it, and doing "rpmbuild -ba SPECS/kernel.spec --define
_topdir' '$PWD ..." .

It produces a kernel with release 3.10.0-693.21.1.el7.jvd.x86_64
(users will want to edit that '.jvd' in the Release: tag)  - it works great!

The tools/testing/selftests/timers/inconsistency_test.c
from linux 4.x+ runs fine with the '-c 4' (CLOCK_MONOTONIC_RAW)
argument under the patched kernel, as does ntpd itself, which is
a heavy user of CLOCK_MONOTONIC_RAW, and the ntpd
computes much lower offsets and drift values.

Just wanted to share this one with the SL community.

Thanks & Best Regards,
Jason


ATOM RSS1 RSS2