-
-
Notifications
You must be signed in to change notification settings - Fork 169
feat(x86_64): 添加KVM时钟源支持 #1683
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat(x86_64): 添加KVM时钟源支持 #1683
Conversation
- 新增kvm_clock模块,支持在KVM虚拟化环境中使用pvclock作为时钟源 - 添加kvm_para和pvclock模块,提供KVM特性检测和pvclock数据结构 - 修改TSC管理器,添加从KVM设置TSC频率的方法 - 调整时钟源初始化顺序,优先使用KVM时钟源 - 修复时钟源选择和timekeeper初始化的相关问题 Signed-off-by: longjin <longjin@DragonOS.org>
|
@codex review |
There was a problem hiding this 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".
| CUR_CLOCKSOURCE.lock().replace(best.clone()); | ||
| if timekeeping::timekeeping_is_initialized() { | ||
| timekeeping::timekeeper().timekeeper_setup_internals(best.clone()); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 👍 / 👎.
Inspired by: #1681 这个添加了smp支持