Skip to content

Conversation

@fslongjin
Copy link
Member

@fslongjin fslongjin commented Jan 18, 2026

  • 新增kvm_clock模块,支持在KVM虚拟化环境中使用pvclock作为时钟源
  • 添加kvm_para和pvclock模块,提供KVM特性检测和pvclock数据结构
  • 修改TSC管理器,添加从KVM设置TSC频率的方法
  • 调整时钟源初始化顺序,优先使用KVM时钟源
  • 修复时钟源选择和timekeeper初始化的相关问题

Inspired by: #1681 这个添加了smp支持

- 新增kvm_clock模块,支持在KVM虚拟化环境中使用pvclock作为时钟源
- 添加kvm_para和pvclock模块,提供KVM特性检测和pvclock数据结构
- 修改TSC管理器,添加从KVM设置TSC频率的方法
- 调整时钟源初始化顺序,优先使用KVM时钟源
- 修复时钟源选择和timekeeper初始化的相关问题

Signed-off-by: longjin <longjin@DragonOS.org>
@fslongjin
Copy link
Member Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 852c97d9b6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 1005 to +1008
CUR_CLOCKSOURCE.lock().replace(best.clone());
if timekeeping::timekeeping_is_initialized() {
timekeeping::timekeeper().timekeeper_setup_internals(best.clone());
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve timekeeping state when switching clocksource

The new call to timekeeper_setup_internals inside clocksource_select will reset cycle_last and xtime_nsec without first carrying forward elapsed time from the previous clocksource (see timekeeping.rs around timekeeper_setup_internals, lines 115–136). When a higher-rated clocksource registers after timekeeping_init (e.g., kvm-clock during setup_arch_post before clocksource_boot_finish), this drops the time elapsed since the last update and can make getnstimeofday()/monotonic time step backwards by up to a tick. Consider advancing timekeeping to “now” before resetting internals, or using the existing update path used for clocksource switches to preserve continuity.

Useful? React with 👍 / 👎.

fi
fi

qemu_accel="tcg"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 Badge Avoid unconditionally forcing QEMU to TCG

The script now unconditionally sets qemu_accel="tcg" after the KVM/HVF detection logic, so even when /dev/kvm is present (or HVF is selected on macOS) it will still run with software emulation. This defeats the accel selection, makes runs much slower, and prevents exercising the new KVM clock path. If the intent was only to default to TCG when KVM isn’t available, the unconditional override should be removed or guarded by an explicit opt-out flag.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant