-
Notifications
You must be signed in to change notification settings - Fork 646
Fix #471: Improve x86_64 emulation on arm64 platform #494
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
Conversation
pkg/qemu/qemu.go
Outdated
if origV, ok := argValue(args, k); ok { | ||
logrus.Warnf("Not adding QEMU argument %q %q, as it conflicts with %q %q", k, v, k, origV) | ||
return args | ||
if k != "-global" { |
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.
Why this check?
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.
Since we need to allow multiple -global arguments which doesn't seems to conflict according to UTM.
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.
Then you can use args = append(args, "-global", ...)
without using appendArgsIfNoConflict
// https://qemu-project.gitlab.io/qemu/system/invocation.html?highlight=tcg%20opts | ||
// this will make sure each vCPU will be backed by 1 host user thread. | ||
args = appendArgsIfNoConflict(args, "-accel", "tcg,thread=multi,tb-size=512") | ||
// This will disable CPU S3 state. |
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.
For what purpose?
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.
When running emulations I found that the VM doesn't use more than 125%. Which seems that nor more than 1 thread is used from host vm for emulation. But adding this tcg accel cause the VM to use more host threads (CPUs). After this change when running the VM load i found the CPU usage spike up to 300% - 400% on the same apple silicon machine. I found this when comparing the load test on the VM created using UTM App and Lima. The last s3 state toggle might not effect the performance directly. But may be it will help the VM to run without going into s3 state.
This change will use qemu64 cpu for better emulation and add some extra parameters like tcg accel and force multi threading where multiple host threads will be used for vcpus according to qemu documentation. Added few more extra parameters which are used by UTM for better emulation of x86_64 Signed-off-by: Gayan Perera <[email protected]>
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.
Thanks
// this will make sure each vCPU will be backed by 1 host user thread. | ||
args = appendArgsIfNoConflict(args, "-accel", "tcg,thread=multi,tb-size=512") | ||
// This will disable CPU S3 state. | ||
args = append(args, "-global", "ICH9-LPC.disable_s3=1") |
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.
Is there any reason you don't also disable the S4 state?
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.
s4 state is for hibernate if i'm not mistaken. It was not part of the UTM parameter list and also i thought that the hibernate state is not something that will the VM automatically go into. Thats why i didn't thought of adding it.
https://www.qemu.org/docs/master/system/i386/cpu.html qemu64 does not support x86_64-v3 needed by RHEL 10. Can we switch back to Haswell-v4 or something newer? |
This change will use qemu64 cpu for better emulation
and add some extra parameters like tcg accel and
force multi threading where multiple host threads will
be used for vcpus according to qemu documentation.
Added few more extra parameters which are used by
UTM for better emulation of x86_64