Re: TSC as timecounter makes system lag

From: Jia-Shiun Li <jiashiun_at_gmail.com>
Date: Mon, 16 Jan 2017 22:34:27 +0800
On Mon, Jan 16, 2017 at 8:00 PM, Konstantin Belousov <kostikbel_at_gmail.com>
wrote:

> On Mon, Jan 16, 2017 at 12:28:54PM +0800, Jia-Shiun Li wrote:
> > BTW please see my other mail of this thread. It seems to be related to
> > EARLY_AP_STARTUP option.
> Yes, I noted, I might have an idea, but the report that changing the
> timecounter makes the lags go away still does not fit into my understanding
> of the code.
>
> Most likely this is an interaction between the EARLY_AP_STARTUP and the
> fact that HPET interrupt is global, while most modern systems use LAPIC
> event timer, which is per-cpu, and the testing of the option was done
> on them. There are some differences in handling the configurations, see
> sys/kern/kern_clocksource.c, the option and ET_FLAG_PERCPU.
>
>
And, changing the _timecounter_ fixes the issue ?  Can you double-check
> this ?
>

Yes. I noticed this because systat refreshes looked slower,
and keystroke did not repeat smoothly for 30/s.
I have system clock shown on tmux status line. On c2d it drifted away.
Setting timecounter brings it back to normal.
See also eventtimer & timecounter tests below.


>
> With the settings above, i.e. HPET for both eventtimer and timecounter,
> please show vmstat -ia output for two times with the interval of 2 secs.
>

Attached.


>
> What if you change _eventtimer_ to APIC and then immediately back to HPET,
> does the problem go away ?
>
>
It doesn't look so. But keeping LAPIC as eventtimer helps.

jsli_at_jsli-bsd:/home/jsli # sysctl kern.eventtimer.timer=LAPIC && sysctl
kern.eventtimer.timer=HPET && ntpdate tw.pool.ntp.org && sleep 30 &&
ntpdate tw.pool.ntp.org
kern.eventtimer.timer: HPET -> LAPIC
kern.eventtimer.timer: LAPIC -> HPET
16 Jan 22:00:21 ntpdate[8472]: step time server 203.71.244.7 offset
18.980716 sec
16 Jan 22:01:56 ntpdate[8601]: step time server 103.226.213.30 offset
58.813079 sec
jsli_at_jsli-bsd:/home/jsli # sysctl kern.eventtimer.timer=LAPIC && ntpdate
tw.pool.ntp.org && sleep 30 && ntpdate tw.pool.ntp.org
 kern.eventtimer.timer: HPET -> LAPIC
16 Jan 22:02:36 ntpdate[8666]: step time server 103.226.213.30 offset
19.773086 sec
16 Jan 22:03:13 ntpdate[8776]: adjust time server 103.226.213.30 offset
0.000455 sec
jsli_at_jsli-bsd:/home/jsli # sysctl kern.eventtimer.timer=HPET && ntpdate
tw.pool.ntp.org && sleep 30 && ntpdate tw.pool.ntp.org
kern.eventtimer.timer: LAPIC -> HPET
16 Jan 22:03:47 ntpdate[8853]: step time server 103.226.213.30 offset
6.344004 sec
16 Jan 22:05:18 ntpdate[8975]: step time server 61.216.153.105 offset
54.908872 sec
jsli_at_jsli-bsd:/home/jsli # sysctl kern.timecounter.hardware=HPET && ntpdate
tw.pool.ntp.org && sleep 30 && ntpdate tw.pool.ntp.org
kern.timecounter.hardware: TSC-low -> HPET
16 Jan 22:06:29 ntpdate[9073]: step time server 59.124.29.241 offset
39.211691 sec
16 Jan 22:07:05 ntpdate[9185]: adjust time server 61.216.153.105 offset
0.001015 sec
jsli_at_jsli-bsd:/home/jsli # sysctl kern.timecounter.hardware=TSC-low &&
ntpdate tw.pool.ntp.org && sleep 30 && ntpdate tw.pool.ntp.org
kern.timecounter.hardware: HPET -> TSC-low
16 Jan 22:07:28 ntpdate[9244]: step time server 61.216.153.105 offset
3.122954 sec
16 Jan 22:08:58 ntpdate[9357]: step time server 61.216.153.104 offset
53.758451 sec
jsli_at_jsli-bsd:/home/jsli #



> Also, if you set the loader tunable kern.eventtimer.timer to LAPIC,
> and do not enable C2+, does the system boot into the usable state ?
>
>
Not sure if you mean disabling C2 from BIOS.
Right now I don't have BIOS access to the c2d, and my notebook only
has minimal BIOS settings to play with. Anyway on notebook

  set kern.eventtimer.timer=LAPIC

in loader prompt to boot , and the system still lags. But after setting

  sysctl dev.cpu.0.cx_lowest=C1 &&  sysctl dev.cpu.1.cx_lowest=C1

system clock returns to normal speed.


-Jia-Shiun.

Received on Mon Jan 16 2017 - 13:34:59 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:09 UTC