1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

CPUをRyzenに変えたらPPS同期のntpdのoffsetが急増した

Last updated at Posted at 2020-10-28

現象

タイトルの通り、CPUをRyzenに変えたらPPS同期のntpdのoffsetが急増した。
しかも、数usから20ms以上に急増。
jitterも数usecから数百usecに。単位が違いすぎる。
何故。

環境

Ryzen移行前

  • CPU: J3455
  • OS: ArchLinux
    • linuxカーネル
    • intel_idle.max_cstate=1でC Stateを制限済み1
  • 時刻源: GPS18x LVC2
  • ntpd: 4.2.8.p15
    • timepps.hを設置してコンパイル済み
    • ntpd -Nでhighest priority化済み1
  • ntpd Reference Clock Driver: Type 20
    • PPS使用

Ryzen移行後

  • CPU: Ryzen 5 PRO 3400GE
    • 流行りのM75q-1
  • OS: ArchLiux
    • linux-zenカーネル
  • 時刻源: GPS18x LVC2
    • 移行前と同じ
  • ntpd: 4.2.8.p15
    • 移行前と同じく、timepps.hを設置してコンパイル済み
  • ntpd Reference Clock Driver: Type 20
    • 移行前と同じく、PPS使用

実験

ntpd -Nでhighest priority化

結果は、あまり?変わらず。

fudgetime1でPPSのoffsetを調整

本家によると、

Specifies the PPS time offset calibration factor, in seconds and fraction, with default 0.0

とのこと。
結果は、time 1をいくら修正しても、offsetの値は変わらない。

ただ、実験の過程で、色々調べたところ、みなさん3他のNTPサーバーでPPSのoffsetを較正していることが分かった。
実際、Type 20のoffsetが20msであっても、time 1を調整したら、他のNTPサーバーのoffsetは0に近づいた。
今まではPPSの精度を信じていたが、例えそうであっても、PPSがntpdに到着してカーネルの時刻に反映されるまでの遅延は、システム毎に異なる可能性を考慮すべきかも。

C Stateの制限

とはいえ、time 1では、jitterは減らせなかった。
過去に書いたこちらの記事と同じことを、Ryzenでやるには、どうすれば。

CPU idle driver

本家によると、CPU idle driverには、intel_idleacpi_idleの2種類があるらしい。
まずは、Ryzen移行後のM75q-1で、どちらが使われているか、見てみよう。

$ cat /sys/devices/system/cpu/cpuidle/current_driver
acpi_idle

ほーそうですか。そして、先ほどの本家によると、

(前略) there are parameters affecting individual CPUIdle drivers that can be passed to them via the kernel command line. Specifically, the intel_idle.max_cstate= and processor.max_cstate= parameters (中略) causes the intel_idle and acpi_idle drivers, respectively, to discard all of the idle states deeper than idle state .

とある。acpi_idleにはprocessor.max_cstate=<n>ということか。

grubにカーネルパラメーターを設定

/etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 quiet processor.max_cstate=1"
sudo grub-mkconfig -o /boot/grub/grub.cfg

そして再起動。

結果

$ ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
oGPS_NMEA(0)     .GPS.            0 l   15   16  377    0.000   -0.001   0.001

ntp_kernel_pll_off-day.png

こうでなくっちゃ!

宿題

  • 消費電力やCPU温度の変化は一体…
  • Kernel discipline(Type 22)
  • Stratum 1はRaspberry Piで作る時代でしょう
  • PTPによる配布
    • M75q-1で動くr8169はPTP対応…してないか…
    • そもそもPTP対応スイッチ持ってなかった…
  1. 過去に書いたこちらの記事参照 2

  2. こちらによると、ファームウェアVer 4.40が2019年10月に出ていたりして、まだ現役 2

  3. こちらこちら

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?