Improve VM CPUfreq and task placement behavior
Subsystems (8)
v2 cover Improve VM CPUfreq and task placement behavior
Hi,
This patch series is a continuation of the talk Saravana gave at LPC 2022 titled "CPUfreq/sched and VM guest workload problems" [1][2][3]. The gist of the talk is that workloads running in a guest VM get terrible task placement and CPUfreq behavior when compared to running the same workload in the host. Effectively, no EAS(Energy Aware Scheduling) for threads inside VMs. This would make power and performance terrible just by running the workload in a VM even if we assume there is zero virtualization overhead.
We have been iterating over different options for communicating between guest and host, ways of applying the information coming from the guest/host, etc to figure out the best performance and power improvements we could get.
The patch series in its current state is NOT meant for landing in the upstream kernel. We are sending this patch series to share the current progress and data we have so far. The patch series is meant to be easy to cherry-pick and test on various devices to see what performance and power benefits this might give for others.
With this series, a workload running in a VM gets the same task placement and CPUfreq behavior as it would when running in the host.
As expected, we see significant performance improvement and better performance/power ratio. If anyone else wants to try this out for your VM workloads and report findings, that'd be very much appreciated.
The idea is to improve VM CPUfreq/sched behavior by:
- Having guest kernel to do accurate load tracking by taking host CPU arch/type and frequency into account.
- Sharing vCPU run queue utilization information with the host so that the host can do proper frequency scaling and task placement on the host side.
Results:
========
As of right now, the best results have been with using hypercalls (see more below first) to communicate between host and guest and treating the vCPU run queue util similar to util_est on the host side vCPU thread. So that's what this patch series does.
Let's look at the results for this series first and then look at the other options we are trying/tried out:
Use cases running Android inside a VM on a Chromebook:
======================================================
PCMark (Emulates real world usecases)
Higher is better
+-------------------+----------+------------+--------+ | Test Case (score) | Baseline | Util_guest | %delta | +-------------------+----------+------------+--------+ | Weighted Total | 6136 | 7274 | +19% | +-------------------+----------+------------+--------+ | Web Browsing | 5558 | 6273 | +13% | +-------------------+----------+------------+--------+ | Video Editing | 4921 | 5221 | +6% | +-------------------+----------+------------+--------+ | Writing | 6864 | 8825 | +29% | +-------------------+----------+------------+--------+ | Photo Editing | 7983 | 11593 | +45% | +-------------------+----------+------------+--------+ | Data Manipulation | 5814 | 6081 | +5% | +-------------------+----------+------------+--------+
PCMark Performance/mAh
Higher is better
+-----------+----------+------------+--------+ | | Baseline | Util_guest | %delta | +-----------+----------+------------+--------+ | Score/mAh | 79 | 88 | +11% | +-----------+----------+------------+--------+
Roblox
Higher is better
+-----+----------+------------+--------+ | | Baseline | Util_guest | %delta | +-----+----------+------------+--------+ | FPS | 18.25 | 28.66 | +57% | +-----+----------+------------+--------+
Roblox Frames/mAh
Higher is better
+--------+----------+------------+--------+ | | Baseline | Util_guest | %delta | +--------+----------+------------+--------+ | Frames | 91.25 | 114.64 | +26% | +--------+----------+------------+--------+
Use cases running a minimal system inside a VM on a Pixel 6:
============================================================
FIO
Higher is better
+----------------------+----------+------------+--------+ | Test Case (avg MB/s) | Baseline | Util_guest | %delta | +----------------------+----------+------------+--------+ | Seq Write | 9.27 | 12.6 | +36% | +----------------------+----------+------------+--------+ | Rand Write | 9.34 | 11.9 | +27% | +----------------------+----------+------------+--------+ | Seq Read | 106 | 124 | +17% | +----------------------+----------+------------+--------+ | Rand Read | 33.6 | 35 | +4% | +----------------------+----------+------------+--------+
CPU-based ML Inference Benchmark
Lower is better
+-------------------------+----------+------------+--------+ | Test Case (ms) | Baseline | Util_guest | %delta | +-------------------------+----------+------------+--------+ | Cached Sample Inference | 2.57 | 1.75 | -32% | +-------------------------+----------+------------+--------+ | Small Sample Inference | 6.8 | 5.57 | -18% | +-------------------------+----------+------------+--------+ | Large Sample Inference | 31.2 | 26.58 | -15% | +-------------------------+----------+------------+--------+
These patches expect the host to:
- Affine vCPUs to specific clusters.
- Set vCPU capacity to match the host CPU they are running on.
To make this easy to do/try out, we have put up patches[4][5] to do this on CrosVM. Once you pick up those patches, you can use options "--host-cpu-topology" and "--virt-cpufreq" to achieve the above.
The patch series can be broken into:
Patch 1: Add util_guest as an additional PELT signal for host vCPU threads Patch 2: Hypercall for guest to get current pCPU's frequency Patch 3: Send vCPU run queue util to host and apply as util_guest Patch 4: Query pCPU freq table from guest (we'll move this to DT in the
future)
Patch 5: Virtual cpufreq driver that uses the hypercalls to send util to
host and implement frequency invariance in the guest.
Alternative we have implemented and profiled:
=============================================
util_guest vs uclamp_min
========================
One suggestion at LPC was to use uclamp_min to apply the util info coming from the guest. As we suspected, it doesn't perform as well because uclamp_min is not additive, whereas the actual workload on the host CPU due to the vCPU is additive to the existing workloads on the host. Uclamp_min also has the undesirable side-effect of threads forked from the vCPU thread inheriting whatever uclamp_min value the vCPU thread had and then getting stuck with that uclamp_min value.
Below are some additional benchmark results comparing the uclamp_min prototype (listed as Uclamp) using the same test environment as before (including hypercalls).
As before, %delta is always comparing to baseline.
PCMark
Higher is better
+-------------------+----------+------------+--------+--------+--------+ | Test Case (score) | Baseline | Util_guest | %delta | Uclamp | %delta | +-------------------+----------+------------+--------+--------+--------+ | Weighted Total | 6136 | 7274 | +19% | 6848 | +12% | +-------------------+----------+------------+--------+--------+--------+ | Web Browsing | 5558 | 6273 | +13% | 6050 | +9% | +-------------------+----------+------------+--------+--------+--------+ | Video Editing | 4921 | 5221 | +6% | 5091 | +3% | +-------------------+----------+------------+--------+--------+--------+ | Writing | 6864 | 8825 | +29% | 8523 | +24% | +-------------------+----------+------------+--------+--------+--------+ | Photo Editing | 7983 | 11593 | +45% | 9865 | +24% | +-------------------+----------+------------+--------+--------+--------+ | Data Manipulation | 5814 | 6081 | +5% | 5836 | 0% | +-------------------+----------+------------+--------+--------+--------+
PCMark Performance/mAh
Higher is better
+-----------+----------+------------+--------+--------+--------+ | | Baseline | Util_guest | %delta | Uclamp | %delta | +-----------+----------+------------+--------+--------+--------+ | Score/mAh | 79 | 88 | +11% | 83 | +7% | +-----------+----------+------------+--------+--------+--------+
Hypercalls vs MMIO:
===================
We realize that hypercalls are not the recommended choice for this and we have no attachment to any communication method as long as it gives good results.
We started off with hypercalls to see what is the best we could achieve if we didn't have to context switch into host side userspace.
To see the impact of switching from hypercalls to MMIO, we kept util_guest and only switched from hypercall to MMIO. So in the results below:
- Hypercall = hypercall + util_guest
- MMIO = MMIO + util_guest
As before, %delta is always comparing to baseline.
PCMark
Higher is better
+-------------------+----------+------------+--------+-------+--------+ | Test Case (score) | Baseline | Hypercall | %delta | MMIO | %delta | +-------------------+----------+------------+--------+-------+--------+ | Weighted Total | 6136 | 7274 | +19% | 6867 | +12% | +-------------------+----------+------------+--------+-------+--------+ | Web Browsing | 5558 | 6273 | +13% | 6035 | +9% | +-------------------+----------+------------+--------+-------+--------+ | Video Editing | 4921 | 5221 | +6% | 5167 | +5% | +-------------------+----------+------------+--------+-------+--------+ | Writing | 6864 | 8825 | +29% | 8529 | +24% | +-------------------+----------+------------+--------+-------+--------+ | Photo Editing | 7983 | 11593 | +45% | 10812 | +35% | +-------------------+----------+------------+--------+-------+--------+ | Data Manipulation | 5814 | 6081 | +5% | 5327 | -8% | +-------------------+----------+------------+--------+-------+--------+
PCMark Performance/mAh
Higher is better
+-----------+----------+-----------+--------+------+--------+ | | Baseline | Hypercall | %delta | MMIO | %delta | +-----------+----------+-----------+--------+------+--------+ | Score/mAh | 79 | 88 | +11% | 83 | +7% | +-----------+----------+-----------+--------+------+--------+
Roblox
Higher is better
+-----+----------+------------+--------+-------+--------+ | | Baseline | Hypercall | %delta | MMIO | %delta | +-----+----------+------------+--------+-------+--------+ | FPS | 18.25 | 28.66 | +57% | 24.06 | +32% | +-----+----------+------------+--------+-------+--------+
Roblox Frames/mAh
Higher is better
+------------+----------+------------+--------+--------+--------+ | | Baseline | Hypercall | %delta | MMIO | %delta | +------------+----------+------------+--------+--------+--------+ | Frames/mAh | 91.25 | 114.64 | +26% | 103.11 | +13% | +------------+----------+------------+--------+--------+--------+
Next steps:
===========
We are continuing to look into communication mechanisms other than hypercalls that are just as/more efficient and avoid switching into the VMM userspace. Any inputs in this regard are greatly appreciated.
Thanks,
David & Saravana
v1 -> v2:
- Added description for EAS and removed DVFS in coverletter.
- Added a v2 tag to the subject.
- Fixed up the inconsistent "units" between tables.
- Made sure everyone is To/Cc-ed for all the patches in the series.
[1] - https://lpc.events/event/16/contributions/1195/
[2] - https://lpc.events/event/16/contributions/1195/attachments/970/1893/LPC%202022%20-%20VM%20DVFS.pdf
[3] - https://www.youtube.com/watch?v=hIg_5bg6opU
[4] - https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4208668
[5] - https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4288027
David Dai (6):
sched/fair: Add util_guest for tasks
kvm: arm64: Add support for get_cur_cpufreq service
kvm: arm64: Add support for util_hint service
kvm: arm64: Add support for get_freqtbl service
dt-bindings: cpufreq: add bindings for virtual kvm cpufreq
cpufreq: add kvm-cpufreq driver
.../bindings/cpufreq/cpufreq-virtual-kvm.yaml | 39 +++ Documentation/virt/kvm/api.rst | 28 ++ .../virt/kvm/arm/get_cur_cpufreq.rst | 21 ++ Documentation/virt/kvm/arm/get_freqtbl.rst | 23 ++ Documentation/virt/kvm/arm/index.rst | 3 + Documentation/virt/kvm/arm/util_hint.rst | 22 ++ arch/arm64/include/uapi/asm/kvm.h | 3 + arch/arm64/kvm/arm.c | 3 + arch/arm64/kvm/hypercalls.c | 60 +++++ drivers/cpufreq/Kconfig | 13 + drivers/cpufreq/Makefile | 1 + drivers/cpufreq/kvm-cpufreq.c | 245 ++++++++++++++++++ include/linux/arm-smccc.h | 21 ++ include/linux/sched.h | 12 + include/uapi/linux/kvm.h | 3 + kernel/sched/core.c | 24 +- kernel/sched/fair.c | 15 +- tools/arch/arm64/include/uapi/asm/kvm.h | 3 + 18 files changed, 536 insertions(+), 3 deletions(-) create mode 100644 Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml create mode 100644 Documentation/virt/kvm/arm/get_cur_cpufreq.rst create mode 100644 Documentation/virt/kvm/arm/get_freqtbl.rst create mode 100644 Documentation/virt/kvm/arm/util_hint.rst create mode 100644 drivers/cpufreq/kvm-cpufreq.c
Signature · 1 line
2.40.0.348.gf938b09366-goog
RFC PATCH v2 1/6 sched/fair: Add util_guest for tasks
For virtualization usecases, util_est and util_avg currently tracked on the host aren't sufficient to accurately represent the workload on vCPU threads, which results in poor frequency selection and performance. For example, when a large workload migrates from a busy vCPU thread to an idle vCPU thread, it incurs additional DVFS ramp-up latencies as util accumulates.
Introduce a new "util_guest" member as an additional PELT signal that's independently updated by the guest. When used, it's max aggregated to provide a boost to both task_util and task_util_est.
Updating task_util and task_util_est will ensure:
-Better task placement decisions for vCPU threads on the host -Correctly updating util_est.ewma during dequeue -Additive util with other threads on the same runqueue for more accurate frequency responses
--- include/linux/sched.h | 11 +++++++++++ kernel/sched/core.c | 18 +++++++++++++++++- kernel/sched/fair.c | 15 +++++++++++++-- 3 files changed, 41 insertions(+), 3 deletions(-)
include/linux/sched.h +11 -0
@@ -445,6 +445,16 @@ struct util_est {#define UTIL_AVG_UNCHANGED 0x80000000 } __attribute__((__aligned__(sizeof(u64)))); +/* +* For sched_setattr_nocheck() (kernel) only +* +* Allow vCPU threads to use UTIL_GUEST as a way to hint the scheduler with more +* accurate utilization info. This is useful when guest kernels have some way of +* tracking its own runqueue's utilization. +* +*/ +#define SCHED_FLAG_UTIL_GUEST 0x20000000 +/* * The load/runnable/util_avg accumulates an infinite geometric series * (see __update_load_avg_cfs_rq() in kernel/sched/pelt.c).
@@ -499,6 +509,7 @@ struct sched_avg {unsigned long load_avg;unsigned long runnable_avg;unsigned long util_avg; +unsigned long util_guest;struct util_est util_est; }____cacheline_aligned ;
kernel/sched/core.c +17 -1
@@ -2024,6 +2024,16 @@ static inline void uclamp_post_fork(struct task_struct *p) { }static inline void init_uclamp (void ) { }#endif /* CONFIG_UCLAMP_TASK */ +static void __setscheduler_task_util (struct task_struct *p, +const struct sched_attr *attr) +{ + +if (likely (!(attr->sched_flags &SCHED_FLAG_UTIL_GUEST ))) +return ; + + p->se.avg.util_guest = attr->sched_util_min; +} +bool sched_task_on_rq (struct task_struct *p) {return task_on_rq_queued (p);
@@ -7561,7 +7571,7 @@ static int __sched_setscheduler(struct task_struct *p,return -EINVAL ; } -if (attr->sched_flags & ~(SCHED_FLAG_ALL |SCHED_FLAG_SUGOV )) +if (attr->sched_flags & ~(SCHED_FLAG_ALL |SCHED_FLAG_SUGOV |SCHED_FLAG_UTIL_GUEST ))return -EINVAL ;/*
@@ -7583,6 +7593,9 @@ static int __sched_setscheduler(struct task_struct *p,if (attr->sched_flags &SCHED_FLAG_SUGOV )return -EINVAL ; +if (attr->sched_flags &SCHED_FLAG_UTIL_GUEST ) +return -EINVAL ; + retval =security_task_setscheduler (p);if (retval)return retval;
@@ -7629,6 +7642,8 @@ static int __sched_setscheduler(struct task_struct *p, goto change;if (attr->sched_flags &SCHED_FLAG_UTIL_CLAMP ) goto change; +if (attr->sched_flags &SCHED_FLAG_UTIL_GUEST ) + goto change; p->sched_reset_on_fork = reset_on_fork; retval =0 ;
@@ -7718,6 +7733,7 @@ static int __sched_setscheduler(struct task_struct *p,__setscheduler_prio (p, newprio); }__setscheduler_uclamp (p, attr); +__setscheduler_task_util (p, attr);if (queued) {/*
kernel/sched/fair.c +13 -2
@@ -4276,14 +4276,16 @@ static int newidle_balance(struct rq *this_rq, struct rq_flags *rf);static inline unsigned long task_util (struct task_struct *p) { -return READ_ONCE (p->se.avg.util_avg); +return max (READ_ONCE (p->se.avg.util_avg), +READ_ONCE (p->se.avg.util_guest)); }static inline unsigned long _task_util_est (struct task_struct *p) {struct util_est ue =READ_ONCE (p->se.avg.util_est); -return max (ue.ewma, (ue.enqueued & ~UTIL_AVG_UNCHANGED )); + return max_t(unsigned long, READ_ONCE(p->se.avg.util_guest), +max (ue.ewma, (ue.enqueued & ~UTIL_AVG_UNCHANGED ))); }static inline unsigned long task_util_est (struct task_struct *p)
@@ -6242,6 +6244,15 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)*/ util_est_enqueue (&rq->cfs, p); +/* +* The normal code path for host thread enqueue doesn't take into +* account guest task migrations when updating cpufreq util. +* So, always update the cpufreq when a vCPU thread has a +* non-zero util_guest value. +*/ +if (READ_ONCE (p->se.avg.util_guest)) +cpufreq_update_util (rq,0 ); +/* * If in_iowait is set, the code below may not trigger any cpufreq * utilization updates, so do it here explicitly with the IOWAIT flag
Signature · 1 line
2.40.0.348.gf938b09366-goog
kernel test robot
build botRe: [RFC PATCH v2 1/6] sched/fair: Add util_guest for tasks
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in…
Hi David,
[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on kvm/queue]
[also build test ERROR on kvmarm/next tip/sched/core linus/master v6.3-rc4 next-20230331] [cannot apply to kvm/linux-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/David-Dai/sched-fair-Add-util_guest-for-tasks/20230331-094936 base: https://git.kernel.org/pub/scm/virt/kvm/kvm.git queue patch link: https://lore.kernel.org/r/20230331014356.1033759-2-davidai%40google.com patch subject: [RFC PATCH v2 1/6] sched/fair: Add util_guest for tasks config: riscv-randconfig-r014-20230329 (https://download.01.org/0day-ci/archive/20230331/[email protected]/config) compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project 67409911353323ca5edf2049ef0df54132fa1ca7)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/intel-lab-lkp/linux/commit/80e880c6cbaadfdac1b7da1672f571d1d7331166
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review David-Dai/sched-fair-Add-util_guest-for-tasks/20230331-094936 git checkout 80e880c6cbaadfdac1b7da1672f571d1d7331166
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash kernel/sched/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> kernel/sched/core.c:2034:8: error: no member named 'avg' in 'struct sched_entity'
p->se.avg.util_guest = attr->sched_util_min;
~~~~~ ^
1 error generated.
--
>> kernel/sched/fair.c:6217:22: error: no member named 'avg' in 'struct sched_entity'
if (READ_ONCE(p->se.avg.util_guest))
~~~~~ ^
include/asm-generic/rwonce.h:49:33: note: expanded from macro 'READ_ONCE'
compiletime_assert_rwonce_type(x); \
^
include/asm-generic/rwonce.h:36:35: note: expanded from macro 'compiletime_assert_rwonce_type'
compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \
^
include/linux/compiler_types.h:364:10: note: expanded from macro '__native_word'
(sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || \
^
include/linux/compiler_types.h:397:22: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^~~~~~~~~
include/linux/compiler_types.h:385:23: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^~~~~~~~~
include/linux/compiler_types.h:377:9: note: expanded from macro '__compiletime_assert'
if (!(condition)) \
^~~~~~~~~
>> kernel/sched/fair.c:6217:22: error: no member named 'avg' in 'struct sched_entity'
if (READ_ONCE(p->se.avg.util_guest))
~~~~~ ^
include/asm-generic/rwonce.h:49:33: note: expanded from macro 'READ_ONCE'
compiletime_assert_rwonce_type(x); \
^
include/asm-generic/rwonce.h:36:35: note: expanded from macro 'compiletime_assert_rwonce_type'
compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \
^
include/linux/compiler_types.h:364:39: note: expanded from macro '__native_word'
(sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || \
^
include/linux/compiler_types.h:397:22: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^~~~~~~~~
include/linux/compiler_types.h:385:23: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^~~~~~~~~
include/linux/compiler_types.h:377:9: note: expanded from macro '__compiletime_assert'
if (!(condition)) \
^~~~~~~~~
>> kernel/sched/fair.c:6217:22: error: no member named 'avg' in 'struct sched_entity'
if (READ_ONCE(p->se.avg.util_guest))
~~~~~ ^
include/asm-generic/rwonce.h:49:33: note: expanded from macro 'READ_ONCE'
compiletime_assert_rwonce_type(x); \
^
include/asm-generic/rwonce.h:36:35: note: expanded from macro 'compiletime_assert_rwonce_type'
compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \
^
include/linux/compiler_types.h:365:10: note: expanded from macro '__native_word'
sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long))
^
include/linux/compiler_types.h:397:22: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^~~~~~~~~
include/linux/compiler_types.h:385:23: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^~~~~~~~~
include/linux/compiler_types.h:377:9: note: expanded from macro '__compiletime_assert'
if (!(condition)) \
^~~~~~~~~
>> kernel/sched/fair.c:6217:22: error: no member named 'avg' in 'struct sched_entity'
if (READ_ONCE(p->se.avg.util_guest))
~~~~~ ^
include/asm-generic/rwonce.h:49:33: note: expanded from macro 'READ_ONCE'
compiletime_assert_rwonce_type(x); \
^
include/asm-generic/rwonce.h:36:35: note: expanded from macro 'compiletime_assert_rwonce_type'
compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \
^
include/linux/compiler_types.h:365:38: note: expanded from macro '__native_word'
sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long))
^
include/linux/compiler_types.h:397:22: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^~~~~~~~~
include/linux/compiler_types.h:385:23: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^~~~~~~~~
include/linux/compiler_types.h:377:9: note: expanded from macro '__compiletime_assert'
if (!(condition)) \
^~~~~~~~~
>> kernel/sched/fair.c:6217:22: error: no member named 'avg' in 'struct sched_entity'
if (READ_ONCE(p->se.avg.util_guest))
~~~~~ ^
include/asm-generic/rwonce.h:49:33: note: expanded from macro 'READ_ONCE'
compiletime_assert_rwonce_type(x); \
^
include/asm-generic/rwonce.h:36:48: note: expanded from macro 'compiletime_assert_rwonce_type'
compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \
^
include/linux/compiler_types.h:397:22: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^~~~~~~~~
include/linux/compiler_types.h:385:23: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^~~~~~~~~
include/linux/compiler_types.h:377:9: note: expanded from macro '__compiletime_assert'
if (!(condition)) \
^~~~~~~~~
>> kernel/sched/fair.c:6217:22: error: no member named 'avg' in 'struct sched_entity'
if (READ_ONCE(p->se.avg.util_guest))
~~~~~ ^
include/asm-generic/rwonce.h:50:14: note: expanded from macro 'READ_ONCE'
__READ_ONCE(x); \
^
include/asm-generic/rwonce.h:44:65: note: expanded from macro '__READ_ONCE'
#define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x))
^
include/linux/compiler_types.h:353:13: note: expanded from macro '__unqual_scalar_typeof'
_Generic((x), \
^
>> kernel/sched/fair.c:6217:22: error: no member named 'avg' in 'struct sched_entity'
if (READ_ONCE(p->se.avg.util_guest))
~~~~~ ^
include/asm-generic/rwonce.h:50:14: note: expanded from macro 'READ_ONCE'
__READ_ONCE(x); \
^
include/asm-generic/rwonce.h:44:65: note: expanded from macro '__READ_ONCE'
#define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x))
^
include/linux/compiler_types.h:360:15: note: expanded from macro '__unqual_scalar_typeof'
default: (x)))
^
>> kernel/sched/fair.c:6217:22: error: no member named 'avg' in 'struct sched_entity'
if (READ_ONCE(p->se.avg.util_guest))
~~~~~ ^
include/asm-generic/rwonce.h:50:14: note: expanded from macro 'READ_ONCE'
__READ_ONCE(x); \
^
include/asm-generic/rwonce.h:44:72: note: expanded from macro '__READ_ONCE'
#define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x))
^
>> kernel/sched/fair.c:6217:2: error: statement requires expression of scalar type ('void' invalid)
if (READ_ONCE(p->se.avg.util_guest))
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~9 errors generated.
vim +2034 kernel/sched/core.c
2030
2031 if (likely(!(attr->sched_flags & SCHED_FLAG_UTIL_GUEST)))
2032 return;
2033
> 2034 p->se.avg.util_guest = attr->sched_util_min;
2035 }
2036
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
kernel test robot
build botRe: [RFC PATCH v2 1/6] sched/fair: Add util_guest for tasks
In reply to David Dai[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in…
Hi David,
[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on kvm/queue]
[also build test ERROR on kvmarm/next tip/sched/core linus/master v6.3-rc4 next-20230331] [cannot apply to kvm/linux-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/David-Dai/sched-fair-Add-util_guest-for-tasks/20230331-094936 base: https://git.kernel.org/pub/scm/virt/kvm/kvm.git queue patch link: https://lore.kernel.org/r/20230331014356.1033759-2-davidai%40google.com patch subject: [RFC PATCH v2 1/6] sched/fair: Add util_guest for tasks config: csky-randconfig-r006-20230329 (https://download.01.org/0day-ci/archive/20230331/[email protected]/config) compiler: csky-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/80e880c6cbaadfdac1b7da1672f571d1d7331166
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review David-Dai/sched-fair-Add-util_guest-for-tasks/20230331-094936
git checkout 80e880c6cbaadfdac1b7da1672f571d1d7331166
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=csky olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=csky SHELL=/bin/bash kernel/sched/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
kernel/sched/core.c: In function '__setscheduler_task_util':
>> kernel/sched/core.c:2034:14: error: 'struct sched_entity' has no member named 'avg'
2034 | p->se.avg.util_guest = attr->sched_util_min;
| ^
--
kernel/sched/fair.c:6076:6: warning: no previous prototype for 'init_cfs_bandwidth' [-Wmissing-prototypes]
6076 | void init_cfs_bandwidth(struct cfs_bandwidth *cfs_b) {}
| ^~~~~~~~~~~~~~~~~~
In file included from <command-line>:
kernel/sched/fair.c: In function 'enqueue_task_fair':
>> kernel/sched/fair.c:6217:28: error: 'struct sched_entity' has no member named 'avg'
6217 | if (READ_ONCE(p->se.avg.util_guest))
| ^
include/linux/compiler_types.h:377:23: note: in definition of macro '__compiletime_assert'
377 | if (!(condition)) \
| ^~~~~~~~~
include/linux/compiler_types.h:397:9: note: in expansion of macro '_compiletime_assert'
397 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/asm-generic/rwonce.h:36:9: note: in expansion of macro 'compiletime_assert'
36 | compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \
| ^~~~~~~~~~~~~~~~~~
include/asm-generic/rwonce.h:36:28: note: in expansion of macro '__native_word'
36 | compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \
| ^~~~~~~~~~~~~
include/asm-generic/rwonce.h:49:9: note: in expansion of macro 'compiletime_assert_rwonce_type'
49 | compiletime_assert_rwonce_type(x); \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/sched/fair.c:6217:13: note: in expansion of macro 'READ_ONCE'
6217 | if (READ_ONCE(p->se.avg.util_guest))
| ^~~~~~~~~
>> kernel/sched/fair.c:6217:28: error: 'struct sched_entity' has no member named 'avg'
6217 | if (READ_ONCE(p->se.avg.util_guest))
| ^
include/linux/compiler_types.h:377:23: note: in definition of macro '__compiletime_assert'
377 | if (!(condition)) \
| ^~~~~~~~~
include/linux/compiler_types.h:397:9: note: in expansion of macro '_compiletime_assert'
397 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/asm-generic/rwonce.h:36:9: note: in expansion of macro 'compiletime_assert'
36 | compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \
| ^~~~~~~~~~~~~~~~~~
include/asm-generic/rwonce.h:36:28: note: in expansion of macro '__native_word'
36 | compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \
| ^~~~~~~~~~~~~
include/asm-generic/rwonce.h:49:9: note: in expansion of macro 'compiletime_assert_rwonce_type'
49 | compiletime_assert_rwonce_type(x); \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/sched/fair.c:6217:13: note: in expansion of macro 'READ_ONCE'
6217 | if (READ_ONCE(p->se.avg.util_guest))
| ^~~~~~~~~
>> kernel/sched/fair.c:6217:28: error: 'struct sched_entity' has no member named 'avg'
6217 | if (READ_ONCE(p->se.avg.util_guest))
| ^
include/linux/compiler_types.h:377:23: note: in definition of macro '__compiletime_assert'
377 | if (!(condition)) \
| ^~~~~~~~~
include/linux/compiler_types.h:397:9: note: in expansion of macro '_compiletime_assert'
397 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/asm-generic/rwonce.h:36:9: note: in expansion of macro 'compiletime_assert'
36 | compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \
| ^~~~~~~~~~~~~~~~~~
include/asm-generic/rwonce.h:36:28: note: in expansion of macro '__native_word'
36 | compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \
| ^~~~~~~~~~~~~
include/asm-generic/rwonce.h:49:9: note: in expansion of macro 'compiletime_assert_rwonce_type'
49 | compiletime_assert_rwonce_type(x); \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/sched/fair.c:6217:13: note: in expansion of macro 'READ_ONCE'
6217 | if (READ_ONCE(p->se.avg.util_guest))
| ^~~~~~~~~
>> kernel/sched/fair.c:6217:28: error: 'struct sched_entity' has no member named 'avg'
6217 | if (READ_ONCE(p->se.avg.util_guest))
| ^
include/linux/compiler_types.h:377:23: note: in definition of macro '__compiletime_assert'
377 | if (!(condition)) \
| ^~~~~~~~~
include/linux/compiler_types.h:397:9: note: in expansion of macro '_compiletime_assert'
397 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/asm-generic/rwonce.h:36:9: note: in expansion of macro 'compiletime_assert'
36 | compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \
| ^~~~~~~~~~~~~~~~~~
include/asm-generic/rwonce.h:36:28: note: in expansion of macro '__native_word'
36 | compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \
| ^~~~~~~~~~~~~
include/asm-generic/rwonce.h:49:9: note: in expansion of macro 'compiletime_assert_rwonce_type'
49 | compiletime_assert_rwonce_type(x); \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/sched/fair.c:6217:13: note: in expansion of macro 'READ_ONCE'
6217 | if (READ_ONCE(p->se.avg.util_guest))
| ^~~~~~~~~
>> kernel/sched/fair.c:6217:28: error: 'struct sched_entity' has no member named 'avg'
6217 | if (READ_ONCE(p->se.avg.util_guest))
| ^
include/linux/compiler_types.h:377:23: note: in definition of macro '__compiletime_assert'
377 | if (!(condition)) \
| ^~~~~~~~~
include/linux/compiler_types.h:397:9: note: in expansion of macro '_compiletime_assert'
397 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/asm-generic/rwonce.h:36:9: note: in expansion of macro 'compiletime_assert'
36 | compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \
| ^~~~~~~~~~~~~~~~~~
include/asm-generic/rwonce.h:49:9: note: in expansion of macro 'compiletime_assert_rwonce_type'
49 | compiletime_assert_rwonce_type(x); \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/sched/fair.c:6217:13: note: in expansion of macro 'READ_ONCE'
6217 | if (READ_ONCE(p->se.avg.util_guest))
| ^~~~~~~~~
>> kernel/sched/fair.c:6217:28: error: 'struct sched_entity' has no member named 'avg'
6217 | if (READ_ONCE(p->se.avg.util_guest))
| ^
include/linux/compiler_types.h:353:27: note: in definition of macro '__unqual_scalar_typeof'
353 | _Generic((x), \
| ^
include/asm-generic/rwonce.h:50:9: note: in expansion of macro '__READ_ONCE'
50 | __READ_ONCE(x); \
| ^~~~~~~~~~~
kernel/sched/fair.c:6217:13: note: in expansion of macro 'READ_ONCE'
6217 | if (READ_ONCE(p->se.avg.util_guest))
| ^~~~~~~~~
In file included from ./arch/csky/include/generated/asm/rwonce.h:1,
from include/linux/compiler.h:247,
from include/linux/kernel.h:20,
from include/linux/cpumask.h:10,
from include/linux/energy_model.h:4,
from kernel/sched/fair.c:23:
>> kernel/sched/fair.c:6217:28: error: 'struct sched_entity' has no member named 'avg'
6217 | if (READ_ONCE(p->se.avg.util_guest))
| ^
include/asm-generic/rwonce.h:44:73: note: in definition of macro '__READ_ONCE'
44 | #define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x))
| ^
kernel/sched/fair.c:6217:13: note: in expansion of macro 'READ_ONCE'
6217 | if (READ_ONCE(p->se.avg.util_guest))
| ^~~~~~~~~
kernel/sched/fair.c: At top level:
kernel/sched/fair.c:12500:6: warning: no previous prototype for 'free_fair_sched_group' [-Wmissing-prototypes]
12500 | void free_fair_sched_group(struct task_group *tg) { }
| ^~~~~~~~~~~~~~~~~~~~~
kernel/sched/fair.c:12502:5: warning: no previous prototype for 'alloc_fair_sched_group' [-Wmissing-prototypes]
12502 | int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent)
| ^~~~~~~~~~~~~~~~~~~~~~
kernel/sched/fair.c:12507:6: warning: no previous prototype for 'online_fair_sched_group' [-Wmissing-prototypes]
12507 | void online_fair_sched_group(struct task_group *tg) { }
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/sched/fair.c:12509:6: warning: no previous prototype for 'unregister_fair_sched_group' [-Wmissing-prototypes]
12509 | void unregister_fair_sched_group(struct task_group *tg) { }
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~vim +2034 kernel/sched/core.c
2030
2031 if (likely(!(attr->sched_flags & SCHED_FLAG_UTIL_GUEST)))
2032 return;
2033
> 2034 p->se.avg.util_guest = attr->sched_util_min;
2035 }
2036
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
RFC PATCH v2 2/6 kvm: arm64: Add support for get_cur_cpufreq service
In reply to David DaiThis service allows guests to query the host for frequency of the CPU that the vCPU is currently running on.
--- Documentation/virt/kvm/api.rst | 8 +++++++ .../virt/kvm/arm/get_cur_cpufreq.rst | 21 +++++++++++++++++++ Documentation/virt/kvm/arm/index.rst | 1 + arch/arm64/include/uapi/asm/kvm.h | 1 + arch/arm64/kvm/arm.c | 1 + arch/arm64/kvm/hypercalls.c | 18 ++++++++++++++++ include/linux/arm-smccc.h | 7 +++++++ include/uapi/linux/kvm.h | 1 + tools/arch/arm64/include/uapi/asm/kvm.h | 1 + 9 files changed, 59 insertions(+) create mode 100644 Documentation/virt/kvm/arm/get_cur_cpufreq.rst
Documentation/virt/kvm/api.rst +8 -0
@@ -8380,6 +8380,14 @@ structure. When getting the Modified Change Topology Report value, the attr->addr must point to a byte where the value will be stored or retrieved from. +8.40 KVM_CAP_GET_CUR_CPUFREQ +------------------------ + +:Architectures: arm64 + +This capability indicates that KVM supports getting the +frequency of the current CPU that the vCPU thread is running on. + 9. Known KVM API problems =========================
Documentation/virt/kvm/arm/get_cur_cpufreq.rst new file +21 -0
@@ -0,0 +1,21 @@ +.. SPDX-License-Identifier: GPL-2.0 + +get_cur_cpufreq support for arm/arm64 +============================= + +Get_cur_cpufreq support is used to get current frequency(in KHz) of the +current CPU that the vCPU thread is running on. + +* ARM_SMCCC_VENDOR_HYP_KVM_GET_CUR_CPUFREQ_FUNC_ID: 0x86000040 + +This hypercall uses the SMC32/HVC32 calling convention: + +ARM_SMCCC_VENDOR_HYP_KVM_GET_CUR_CPUFREQ_FUNC_ID + ============== ======== ===================================== + Function ID: (uint32) 0x86000040 + Return Values: (int32) NOT_SUPPORTED(-1) on error, or + (uint32) Frequency in KHz of current CPU that the + vCPU thread is running on. + Endianness: Must be the same endianness + as the host. + ============== ======== =====================================
Documentation/virt/kvm/arm/index.rst +1 -0
@@ -11,3 +11,4 @@ ARM hypercalls pvtime ptp_kvm + get_cur_cpufreq
arch/arm64/include/uapi/asm/kvm.h +1 -0
@@ -367,6 +367,7 @@ enum {enum {KVM_REG_ARM_VENDOR_HYP_BIT_FUNC_FEAT =0 ,KVM_REG_ARM_VENDOR_HYP_BIT_PTP =1 , +KVM_REG_ARM_VENDOR_HYP_BIT_GET_CUR_CPUFREQ =2 ,#ifdef __KERNEL__KVM_REG_ARM_VENDOR_HYP_BMAP_BIT_COUNT ,#endif
arch/arm64/kvm/arm.c +1 -0
@@ -220,6 +220,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)case KVM_CAP_VCPU_ATTRIBUTES :case KVM_CAP_PTP_KVM :case KVM_CAP_ARM_SYSTEM_SUSPEND : +case KVM_CAP_GET_CUR_CPUFREQ : r =1 ;break ;case KVM_CAP_SET_GUEST_DEBUG2 :
arch/arm64/kvm/hypercalls.c +18 -0
@@ -3,6 +3,9 @@#include <linux/arm-smccc.h> #include <linux/kvm_host.h> +#include <linux/cpufreq.h> +#include <linux/sched.h> +#include <uapi/linux/sched/types.h> #include <asm/kvm_emulate.h>
@@ -16,6 +19,15 @@#define KVM_ARM_SMCCC_VENDOR_HYP_FEATURES \ GENMASK(KVM_REG_ARM_VENDOR_HYP_BMAP_BIT_COUNT - 1, 0) +static void kvm_sched_get_cur_cpufreq (struct kvm_vcpu *vcpu,u64 *val) +{ +unsigned long ret_freq; + + ret_freq =cpufreq_get (task_cpu (current)); + + val[0 ] = ret_freq; +} +static void kvm_ptp_get_time (struct kvm_vcpu *vcpu,u64 *val) {struct system_time_snapshot systime_snapshot;
@@ -116,6 +128,9 @@ static bool kvm_hvc_call_allowed(struct kvm_vcpu *vcpu, u32 func_id)case ARM_SMCCC_VENDOR_HYP_KVM_PTP_FUNC_ID :return test_bit (KVM_REG_ARM_VENDOR_HYP_BIT_PTP , &smccc_feat->vendor_hyp_bmap); +case ARM_SMCCC_VENDOR_HYP_KVM_GET_CUR_CPUFREQ_FUNC_ID : +return test_bit (KVM_REG_ARM_VENDOR_HYP_BIT_GET_CUR_CPUFREQ , + &smccc_feat->vendor_hyp_bmap);default :return kvm_hvc_call_default_allowed (func_id); }
@@ -213,6 +228,9 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu)case ARM_SMCCC_VENDOR_HYP_KVM_PTP_FUNC_ID :kvm_ptp_get_time (vcpu, val);break ; +case ARM_SMCCC_VENDOR_HYP_KVM_GET_CUR_CPUFREQ_FUNC_ID : +kvm_sched_get_cur_cpufreq (vcpu, val); +break ;case ARM_SMCCC_TRNG_VERSION :case ARM_SMCCC_TRNG_FEATURES :case ARM_SMCCC_TRNG_GET_UUID :
include/linux/arm-smccc.h +7 -0
@@ -112,6 +112,7 @@/* KVM "vendor specific" services */ #define ARM_SMCCC_KVM_FUNC_FEATURES 0#define ARM_SMCCC_KVM_FUNC_PTP 1 +#define ARM_SMCCC_KVM_FUNC_GET_CUR_CPUFREQ 64#define ARM_SMCCC_KVM_FUNC_FEATURES_2 127#define ARM_SMCCC_KVM_NUM_FUNCS 128
@@ -138,6 +139,12 @@#define KVM_PTP_VIRT_COUNTER 0#define KVM_PTP_PHYS_COUNTER 1 +#define ARM_SMCCC_VENDOR_HYP_KVM_GET_CUR_CPUFREQ_FUNC_ID \ + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \ + ARM_SMCCC_SMC_32, \ + ARM_SMCCC_OWNER_VENDOR_HYP, \ + ARM_SMCCC_KVM_FUNC_GET_CUR_CPUFREQ) +/* Paravirtualised time calls (defined by ARM DEN0057A) */ #define ARM_SMCCC_HV_PV_TIME_FEATURES \ ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \
include/uapi/linux/kvm.h +1 -0
@@ -1184,6 +1184,7 @@ struct kvm_ppc_resize_hpt {#define KVM_CAP_S390_PROTECTED_ASYNC_DISABLE 224#define KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP 225#define KVM_CAP_PMU_EVENT_MASKED_EVENTS 226 +#define KVM_CAP_GET_CUR_CPUFREQ 512#ifdef KVM_CAP_IRQ_ROUTING
tools/arch/arm64/include/uapi/asm/kvm.h +1 -0
@@ -367,6 +367,7 @@ enum {enum {KVM_REG_ARM_VENDOR_HYP_BIT_FUNC_FEAT =0 ,KVM_REG_ARM_VENDOR_HYP_BIT_PTP =1 , +KVM_REG_ARM_VENDOR_HYP_BIT_GET_CUR_CPUFREQ =2 ,#ifdef __KERNEL__KVM_REG_ARM_VENDOR_HYP_BMAP_BIT_COUNT ,#endif
Signature · 1 line
2.40.0.348.gf938b09366-goog
Re: [RFC PATCH v2 2/6] kvm: arm64: Add support for get_cur_cpufreq service
Quoted 36 lines · David Dai
Documentation/virt/kvm/api.rst +8
-0@@ -8380,6 +8380,14 @@ structure. When getting the Modified Change Topology Report value, the attr->addr must point to a byte where the value will be stored or retrieved from. +8.40 KVM_CAP_GET_CUR_CPUFREQ +------------------------ + +:Architectures: arm64 + +This capability indicates that KVM supports getting the +frequency of the current CPU that the vCPU thread is running on. + 9. Known KVM API problems =========================Documentation/virt/kvm/arm/get_cur_cpufreq.rst new file +11
-0@@ -0,0 +1,21 @@ +.. SPDX-License-Identifier: GPL-2.0 + +get_cur_cpufreq support for arm/arm64 +============================= + +Get_cur_cpufreq support is used to get current frequency(in KHz) of the +current CPU that the vCPU thread is running on. + +* ARM_SMCCC_VENDOR_HYP_KVM_GET_CUR_CPUFREQ_FUNC_ID: 0x86000040 + +This hypercall uses the SMC32/HVC32 calling convention:
Documentation/virt/kvm/arm/get_cur_cpufreq.rst line 21
Quoted 10 lines
Documentation/virt/kvm/arm/get_cur_cpufreq.rst new file +10
-0+ +ARM_SMCCC_VENDOR_HYP_KVM_GET_CUR_CPUFREQ_FUNC_ID + ============== ======== ===================================== + Function ID: (uint32) 0x86000040 + Return Values: (int32) NOT_SUPPORTED(-1) on error, or + (uint32) Frequency in KHz of current CPU that the + vCPU thread is running on. + Endianness: Must be the same endianness + as the host. + ============== ======== =====================================
Sphinx reports htmldocs warnings:/home/bagas/repo/linux-kernel/Documentation/virt/kvm/api.rst:8384: WARNING: Title underline too short.
8.40 KVM_CAP_GET_CUR_CPUFREQ
------------------------/home/bagas/repo/linux-kernel/Documentation/virt/kvm/api.rst:8384: WARNING: Title underline too short.
8.40 KVM_CAP_GET_CUR_CPUFREQ
------------------------/home/bagas/repo/linux-kernel/Documentation/virt/kvm/api.rst:8404: WARNING: Title underline too short.
I have applied the fixup:
---- >8 ----
Documentation/virt/kvm/api.rst +1 -1
@@ -8381,7 +8381,7 @@ When getting the Modified Change Topology Report value, the attr->addr must point to a byte where the value will be stored or retrieved from. 8.40 KVM_CAP_GET_CUR_CPUFREQ ------------------------- +---------------------------- :Architectures: arm64
Documentation/virt/kvm/arm/get_cur_cpufreq.rst +3 -2
@@ -11,11 +11,12 @@ current CPU that the vCPU thread is running on. This hypercall uses the SMC32/HVC32 calling convention: ARM_SMCCC_VENDOR_HYP_KVM_GET_CUR_CPUFREQ_FUNC_ID - ============== ======== ===================================== + + ============== ======== ======================================== Function ID: (uint32) 0x86000040 Return Values: (int32) NOT_SUPPORTED(-1) on error, or (uint32) Frequency in KHz of current CPU that the vCPU thread is running on. Endianness: Must be the same endianness as the host. - ============== ======== ===================================== + ============== ======== ========================================
Thanks.
Signature · 1 line
An old man doll... just what I always wanted! - Clara
Re: [RFC PATCH v2 2/6] kvm: arm64: Add support for get_cur_cpufreq service
In reply to David DaiQuoted 2 lines · David Dai
+get_cur_cpufreq support for arm/arm64
+=============================
Oops, I have to also fix this heading too:
---- >8 ----
Documentation/virt/kvm/arm/get_cur_cpufreq.rst +1 -1
@@ -1,7 +1,7 @@ .. SPDX-License-Identifier: GPL-2.0 get_cur_cpufreq support for arm/arm64 -============================= +===================================== Get_cur_cpufreq support is used to get current frequency(in KHz) of the current CPU that the vCPU thread is running on.
Thanks.
Signature · 1 line
An old man doll... just what I always wanted! - Clara
RFC PATCH v2 3/6 kvm: arm64: Add support for util_hint service
In reply to David DaiThis service allows guests to send the utilization of workoads on its vCPUs to the host. Utilization is represented as an arbitrary value of 0-1024 where 1024 represents the highest performance point normalized for frequency and architecture across all CPUs. This hint is used by the host for scheduling vCPU threads and deciding CPU frequency.
--- Documentation/virt/kvm/api.rst | 12 ++++++++++++ Documentation/virt/kvm/arm/index.rst | 1 + Documentation/virt/kvm/arm/util_hint.rst | 22 ++++++++++++++++++++++ arch/arm64/include/uapi/asm/kvm.h | 1 + arch/arm64/kvm/arm.c | 1 + arch/arm64/kvm/hypercalls.c | 20 ++++++++++++++++++++ include/linux/arm-smccc.h | 7 +++++++ include/uapi/linux/kvm.h | 1 + tools/arch/arm64/include/uapi/asm/kvm.h | 1 + 9 files changed, 66 insertions(+) create mode 100644 Documentation/virt/kvm/arm/util_hint.rst
Documentation/virt/kvm/api.rst +12 -0
@@ -8388,6 +8388,18 @@ must point to a byte where the value will be stored or retrieved from. This capability indicates that KVM supports getting the frequency of the current CPU that the vCPU thread is running on. +8.41 KVM_CAP_UTIL_HINT +---------------------- + +:Architectures: arm64 + +This capability indicates that the KVM supports taking utilization +hints from the guest. Utilization is represented as a value from 0-1024 +where 1024 represents the highest performance point across all physical CPUs +after normalizing for architecture. This is useful when guests are tracking +workload on its vCPUs. Util hints allow the host to make more accurate +frequency selections and task placement for vCPU threads. + 9. Known KVM API problems =========================
Documentation/virt/kvm/arm/index.rst +1 -0
@@ -12,3 +12,4 @@ ARM pvtime ptp_kvm get_cur_cpufreq + util_hint
Documentation/virt/kvm/arm/util_hint.rst new file +22 -0
@@ -0,0 +1,22 @@ +.. SPDX-License-Identifier: GPL-2.0 + +Util_hint support for arm64 +============================ + +Util_hint is used for sharing the utilization value from the guest +to the host. + +* ARM_SMCCC_HYP_KVM_UTIL_HINT_FUNC_ID: 0x86000041 + +This hypercall using the SMC32/HVC32 calling convention: + +ARM_SMCCC_HYP_KVM_UTIL_HINT_FUNC_ID + ============== ========= ============================ + Function ID: (uint32) 0x86000041 + Arguments: (uint32) util value(0-1024) where 1024 represents + the highest performance point normalized + across all CPUs + Return values: (int32) NOT_SUPPORTED(-1) on error. + Endianness: Must be the same endianness + as the host. + ============== ======== ============================
arch/arm64/include/uapi/asm/kvm.h +1 -0
@@ -368,6 +368,7 @@ enum {KVM_REG_ARM_VENDOR_HYP_BIT_FUNC_FEAT =0 ,KVM_REG_ARM_VENDOR_HYP_BIT_PTP =1 ,KVM_REG_ARM_VENDOR_HYP_BIT_GET_CUR_CPUFREQ =2 , +KVM_REG_ARM_VENDOR_HYP_BIT_UTIL_HINT =3 , #ifdef __KERNEL__ KVM_REG_ARM_VENDOR_HYP_BMAP_BIT_COUNT, #endif
arch/arm64/kvm/arm.c +1 -0
@@ -221,6 +221,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)case KVM_CAP_PTP_KVM :case KVM_CAP_ARM_SYSTEM_SUSPEND :case KVM_CAP_GET_CUR_CPUFREQ : +case KVM_CAP_UTIL_HINT : r =1 ;break ;case KVM_CAP_SET_GUEST_DEBUG2 :
arch/arm64/kvm/hypercalls.c +20 -0
@@ -28,6 +28,20 @@ static void kvm_sched_get_cur_cpufreq(struct kvm_vcpu *vcpu, u64 *val) val[0 ] = ret_freq; } +static void kvm_sched_set_util (struct kvm_vcpu *vcpu,u64 *val) +{ +struct sched_attr attr = { + .sched_flags =SCHED_FLAG_UTIL_GUEST , + }; +int ret; + + attr.sched_util_min =smccc_get_arg1 (vcpu); + + ret =sched_setattr_nocheck (current, &attr); + + val[0 ] = (u64 )ret; +} +static void kvm_ptp_get_time (struct kvm_vcpu *vcpu,u64 *val) {struct system_time_snapshot systime_snapshot;
@@ -131,6 +145,9 @@ static bool kvm_hvc_call_allowed(struct kvm_vcpu *vcpu, u32 func_id)case ARM_SMCCC_VENDOR_HYP_KVM_GET_CUR_CPUFREQ_FUNC_ID :return test_bit (KVM_REG_ARM_VENDOR_HYP_BIT_GET_CUR_CPUFREQ , &smccc_feat->vendor_hyp_bmap); +case ARM_SMCCC_VENDOR_HYP_KVM_UTIL_HINT_FUNC_ID : +return test_bit (KVM_REG_ARM_VENDOR_HYP_BIT_UTIL_HINT , + &smccc_feat->vendor_hyp_bmap);default :return kvm_hvc_call_default_allowed (func_id); }
@@ -231,6 +248,9 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu)case ARM_SMCCC_VENDOR_HYP_KVM_GET_CUR_CPUFREQ_FUNC_ID :kvm_sched_get_cur_cpufreq (vcpu, val);break ; +case ARM_SMCCC_VENDOR_HYP_KVM_UTIL_HINT_FUNC_ID : +kvm_sched_set_util (vcpu, val); +break ;case ARM_SMCCC_TRNG_VERSION :case ARM_SMCCC_TRNG_FEATURES :case ARM_SMCCC_TRNG_GET_UUID :
include/linux/arm-smccc.h +7 -0
@@ -113,6 +113,7 @@#define ARM_SMCCC_KVM_FUNC_FEATURES 0#define ARM_SMCCC_KVM_FUNC_PTP 1#define ARM_SMCCC_KVM_FUNC_GET_CUR_CPUFREQ 64 +#define ARM_SMCCC_KVM_FUNC_UTIL_HINT 65#define ARM_SMCCC_KVM_FUNC_FEATURES_2 127#define ARM_SMCCC_KVM_NUM_FUNCS 128
@@ -145,6 +146,12 @@ ARM_SMCCC_OWNER_VENDOR_HYP, \ ARM_SMCCC_KVM_FUNC_GET_CUR_CPUFREQ) +#define ARM_SMCCC_VENDOR_HYP_KVM_UTIL_HINT_FUNC_ID \ + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \ + ARM_SMCCC_SMC_32, \ + ARM_SMCCC_OWNER_VENDOR_HYP, \ + ARM_SMCCC_KVM_FUNC_UTIL_HINT) +/* Paravirtualised time calls (defined by ARM DEN0057A) */ #define ARM_SMCCC_HV_PV_TIME_FEATURES \ ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \
include/uapi/linux/kvm.h +1 -0
@@ -1185,6 +1185,7 @@ struct kvm_ppc_resize_hpt {#define KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP 225#define KVM_CAP_PMU_EVENT_MASKED_EVENTS 226#define KVM_CAP_GET_CUR_CPUFREQ 512 +#define KVM_CAP_UTIL_HINT 513#ifdef KVM_CAP_IRQ_ROUTING
tools/arch/arm64/include/uapi/asm/kvm.h +1 -0
@@ -368,6 +368,7 @@ enum {KVM_REG_ARM_VENDOR_HYP_BIT_FUNC_FEAT =0 ,KVM_REG_ARM_VENDOR_HYP_BIT_PTP =1 ,KVM_REG_ARM_VENDOR_HYP_BIT_GET_CUR_CPUFREQ =2 , +KVM_REG_ARM_VENDOR_HYP_BIT_UTIL_HINT =3 , #ifdef __KERNEL__ KVM_REG_ARM_VENDOR_HYP_BMAP_BIT_COUNT, #endif
Signature · 1 line
2.40.0.348.gf938b09366-goog
Re: [RFC PATCH v2 3/6] kvm: arm64: Add support for util_hint service
Review
Quoted 10 lines · David Dai
(quoted diff) +10
-0+ARM_SMCCC_HYP_KVM_UTIL_HINT_FUNC_ID + ============== ========= ============================ + Function ID: (uint32) 0x86000041 + Arguments: (uint32) util value(0-1024) where 1024 represents + the highest performance point normalized + across all CPUs + Return values: (int32) NOT_SUPPORTED(-1) on error. + Endianness: Must be the same endianness + as the host. + ============== ======== ============================
Sphinx reports htmldocs warning:/home/bagas/repo/linux-kernel/Documentation/virt/kvm/arm/util_hint.rst:21: WARNING: Malformed table. Column span alignment problem in table line 8.
============== ========= ============================
Function ID: (uint32) 0x86000041
Arguments: (uint32) util value(0-1024) where 1024 represents
the highest performance point normalized
across all CPUs
Return values: (int32) NOT_SUPPORTED(-1) on error.
Endianness: Must be the same endianness as the host.
============== ======== ============================
I have to fix the table:
---- >8 ----
Documentation/virt/kvm/arm/util_hint.rst +3 -2
@@ -11,7 +11,8 @@ to the host. This hypercall using the SMC32/HVC32 calling convention: ARM_SMCCC_HYP_KVM_UTIL_HINT_FUNC_ID - ============== ========= ============================ + + ============== ========= ======================================== Function ID: (uint32) 0x86000041 Arguments: (uint32) util value(0-1024) where 1024 represents the highest performance point normalized
@@ -19,4 +20,4 @@ ARM_SMCCC_HYP_KVM_UTIL_HINT_FUNC_ID Return values: (int32) NOT_SUPPORTED(-1) on error. Endianness: Must be the same endianness as the host. - ============== ======== ============================ + ============== ========= ========================================
Thanks.
Signature · 1 line
An old man doll... just what I always wanted! - Clara
RFC PATCH v2 4/6 kvm: arm64: Add support for get_freqtbl service
In reply to David DaiThis service allows guests to query the host for the frequency table of the CPU that the vCPU is currently running on.
--- Documentation/virt/kvm/api.rst | 8 ++++++++ Documentation/virt/kvm/arm/get_freqtbl.rst | 23 ++++++++++++++++++++++ Documentation/virt/kvm/arm/index.rst | 1 + arch/arm64/include/uapi/asm/kvm.h | 1 + arch/arm64/kvm/arm.c | 1 + arch/arm64/kvm/hypercalls.c | 22 +++++++++++++++++++++ include/linux/arm-smccc.h | 7 +++++++ include/uapi/linux/kvm.h | 1 + tools/arch/arm64/include/uapi/asm/kvm.h | 1 + 9 files changed, 65 insertions(+) create mode 100644 Documentation/virt/kvm/arm/get_freqtbl.rst
Documentation/virt/kvm/api.rst +8 -0
@@ -8400,6 +8400,14 @@ after normalizing for architecture. This is useful when guests are tracking workload on its vCPUs. Util hints allow the host to make more accurate frequency selections and task placement for vCPU threads. +8.42 KVM_CAP_GET_CPUFREQ_TBL +--------------------------- + +:Architectures: arm64 + +This capability indicates that the KVM supports getting the +frequency table of the current CPU that the vCPU thread is running on. + 9. Known KVM API problems =========================
Documentation/virt/kvm/arm/get_freqtbl.rst new file +23 -0
@@ -0,0 +1,23 @@ +.. SPDX-License-Identifier: GPL-2.0 + +get_freqtbl support for arm/arm64 +============================= + +Allows guest to query the frequency(in KHz) table of the current CPU that +the vCPU thread is running on. + +* ARM_SMCCC_VENDOR_HYP_KVM_GET_CPUFREQ_TBL_FUNC_ID: 0x86000042 + +This hypercall uses the SMC32/HVC32 calling convention: + +ARM_SMCCC_VENDOR_HYP_KVM_GET_CPUFREQ_TBL_FUNC_ID + ============== ======== ===================================== + Function ID: (uint32) 0x86000042 + Arguments: (uint32) index of the current CPU's frequency table + Return Values: (int32) NOT_SUPPORTED(-1) on error, or + (uint32) Frequency table entry of requested index + in KHz + of current CPU(r1) + Endianness: Must be the same endianness + as the host. + ============== ======== =====================================
Documentation/virt/kvm/arm/index.rst +1 -0
@@ -13,3 +13,4 @@ ARM ptp_kvm get_cur_cpufreq util_hint + get_freqtbl
arch/arm64/include/uapi/asm/kvm.h +1 -0
@@ -369,6 +369,7 @@ enum {KVM_REG_ARM_VENDOR_HYP_BIT_PTP =1 ,KVM_REG_ARM_VENDOR_HYP_BIT_GET_CUR_CPUFREQ =2 ,KVM_REG_ARM_VENDOR_HYP_BIT_UTIL_HINT =3 , +KVM_REG_ARM_VENDOR_HYP_BIT_GET_CPUFREQ_TBL =4 , #ifdef __KERNEL__ KVM_REG_ARM_VENDOR_HYP_BMAP_BIT_COUNT, #endif
arch/arm64/kvm/arm.c +1 -0
@@ -222,6 +222,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)case KVM_CAP_ARM_SYSTEM_SUSPEND :case KVM_CAP_GET_CUR_CPUFREQ :case KVM_CAP_UTIL_HINT : +case KVM_CAP_GET_CPUFREQ_TBL : r =1 ;break ;case KVM_CAP_SET_GUEST_DEBUG2 :
arch/arm64/kvm/hypercalls.c +22 -0
@@ -42,6 +42,22 @@ static void kvm_sched_set_util(struct kvm_vcpu *vcpu, u64 *val) val[0 ] = (u64 )ret; } +static void kvm_sched_get_cpufreq_table (struct kvm_vcpu *vcpu,u64 *val) +{ +struct cpufreq_policy *policy; +u32 idx =smccc_get_arg1 (vcpu); + + policy =cpufreq_cpu_get (task_cpu (current)); + +if (!policy) +return ; + + val[0 ] =SMCCC_RET_SUCCESS ; + val[1 ] = policy->freq_table[idx].frequency; + +cpufreq_cpu_put (policy); +} +static void kvm_ptp_get_time (struct kvm_vcpu *vcpu,u64 *val) {struct system_time_snapshot systime_snapshot;
@@ -148,6 +164,9 @@ static bool kvm_hvc_call_allowed(struct kvm_vcpu *vcpu, u32 func_id)case ARM_SMCCC_VENDOR_HYP_KVM_UTIL_HINT_FUNC_ID :return test_bit (KVM_REG_ARM_VENDOR_HYP_BIT_UTIL_HINT , &smccc_feat->vendor_hyp_bmap); +case ARM_SMCCC_VENDOR_HYP_KVM_GET_CPUFREQ_TBL_FUNC_ID : +return test_bit (KVM_REG_ARM_VENDOR_HYP_BIT_GET_CPUFREQ_TBL , + &smccc_feat->vendor_hyp_bmap);default :return kvm_hvc_call_default_allowed (func_id); }
@@ -251,6 +270,9 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu)case ARM_SMCCC_VENDOR_HYP_KVM_UTIL_HINT_FUNC_ID :kvm_sched_set_util (vcpu, val);break ; +case ARM_SMCCC_VENDOR_HYP_KVM_GET_CPUFREQ_TBL_FUNC_ID : +kvm_sched_get_cpufreq_table (vcpu, val); +break ;case ARM_SMCCC_TRNG_VERSION :case ARM_SMCCC_TRNG_FEATURES :case ARM_SMCCC_TRNG_GET_UUID :
include/linux/arm-smccc.h +7 -0
@@ -114,6 +114,7 @@#define ARM_SMCCC_KVM_FUNC_PTP 1#define ARM_SMCCC_KVM_FUNC_GET_CUR_CPUFREQ 64#define ARM_SMCCC_KVM_FUNC_UTIL_HINT 65 +#define ARM_SMCCC_KVM_FUNC_GET_CPUFREQ_TBL 66#define ARM_SMCCC_KVM_FUNC_FEATURES_2 127#define ARM_SMCCC_KVM_NUM_FUNCS 128
@@ -152,6 +153,12 @@ ARM_SMCCC_OWNER_VENDOR_HYP, \ ARM_SMCCC_KVM_FUNC_UTIL_HINT) +#define ARM_SMCCC_VENDOR_HYP_KVM_GET_CPUFREQ_TBL_FUNC_ID \ + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \ + ARM_SMCCC_SMC_32, \ + ARM_SMCCC_OWNER_VENDOR_HYP, \ + ARM_SMCCC_KVM_FUNC_GET_CPUFREQ_TBL) +/* Paravirtualised time calls (defined by ARM DEN0057A) */ #define ARM_SMCCC_HV_PV_TIME_FEATURES \ ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \
include/uapi/linux/kvm.h +1 -0
@@ -1186,6 +1186,7 @@ struct kvm_ppc_resize_hpt {#define KVM_CAP_PMU_EVENT_MASKED_EVENTS 226#define KVM_CAP_GET_CUR_CPUFREQ 512#define KVM_CAP_UTIL_HINT 513 +#define KVM_CAP_GET_CPUFREQ_TBL 514#ifdef KVM_CAP_IRQ_ROUTING
tools/arch/arm64/include/uapi/asm/kvm.h +1 -0
@@ -369,6 +369,7 @@ enum {KVM_REG_ARM_VENDOR_HYP_BIT_PTP =1 ,KVM_REG_ARM_VENDOR_HYP_BIT_GET_CUR_CPUFREQ =2 ,KVM_REG_ARM_VENDOR_HYP_BIT_UTIL_HINT =3 , +KVM_REG_ARM_VENDOR_HYP_BIT_CPUFREQ_TBL =4 , #ifdef __KERNEL__ KVM_REG_ARM_VENDOR_HYP_BMAP_BIT_COUNT, #endif
Signature · 1 line
2.40.0.348.gf938b09366-goog
Re: [RFC PATCH v2 4/6] kvm: arm64: Add support for get_freqtbl service
Quoted 38 lines · David Dai
Documentation/virt/kvm/api.rst +8
-0@@ -8400,6 +8400,14 @@ after normalizing for architecture. This is useful when guests are tracking workload on its vCPUs. Util hints allow the host to make more accurate frequency selections and task placement for vCPU threads. +8.42 KVM_CAP_GET_CPUFREQ_TBL +--------------------------- + +:Architectures: arm64 + +This capability indicates that the KVM supports getting the +frequency table of the current CPU that the vCPU thread is running on. + 9. Known KVM API problems =========================Documentation/virt/kvm/arm/get_freqtbl.rst new file +13
-0@@ -0,0 +1,23 @@ +.. SPDX-License-Identifier: GPL-2.0 + +get_freqtbl support for arm/arm64 +============================= + +Allows guest to query the frequency(in KHz) table of the current CPU that +the vCPU thread is running on. + +* ARM_SMCCC_VENDOR_HYP_KVM_GET_CPUFREQ_TBL_FUNC_ID: 0x86000042 + +This hypercall uses the SMC32/HVC32 calling convention: + +ARM_SMCCC_VENDOR_HYP_KVM_GET_CPUFREQ_TBL_FUNC_ID
Documentation/virt/kvm/arm/get_freqtbl.rst line 23
Quoted 10 lines
Documentation/virt/kvm/arm/get_freqtbl.rst new file +10
-0+ ============== ======== ===================================== + Function ID: (uint32) 0x86000042 + Arguments: (uint32) index of the current CPU's frequency table + Return Values: (int32) NOT_SUPPORTED(-1) on error, or + (uint32) Frequency table entry of requested index + in KHz + of current CPU(r1) + Endianness: Must be the same endianness + as the host. + ============== ======== =====================================
Sphinx reports htmldocs warnings:/home/bagas/repo/linux-kernel/Documentation/virt/kvm/api.rst:8404: WARNING: Title underline too short.
8.42 KVM_CAP_GET_CPUFREQ_TBL
---------------------------/home/bagas/repo/linux-kernel/Documentation/virt/kvm/api.rst:8404: WARNING: Title underline too short.
8.42 KVM_CAP_GET_CPUFREQ_TBL
---------------------------/home/bagas/repo/linux-kernel/Documentation/virt/kvm/arm/get_freqtbl.rst:4: WARNING: Title underline too short.
get_freqtbl support for arm/arm64
=============================
I have applied the fixup:
---- >8 ----
Documentation/virt/kvm/api.rst +1 -1
@@ -8401,7 +8401,7 @@ workload on its vCPUs. Util hints allow the host to make more accurate frequency selections and task placement for vCPU threads. 8.42 KVM_CAP_GET_CPUFREQ_TBL ---------------------------- +---------------------------- :Architectures: arm64
Documentation/virt/kvm/arm/get_freqtbl.rst +1 -1
@@ -1,7 +1,7 @@ .. SPDX-License-Identifier: GPL-2.0 get_freqtbl support for arm/arm64 -============================= +================================= Allows guest to query the frequency(in KHz) table of the current CPU that the vCPU thread is running on.
Thanks.
Signature · 1 line
An old man doll... just what I always wanted! - Clara
RFC PATCH v2 5/6 dt-bindings: cpufreq: add bindings for virtual kvm cpufreq
In reply to David DaiAdd devicetree bindings for a virtual kvm cpufreq driver.
--- .../bindings/cpufreq/cpufreq-virtual-kvm.yaml | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml
Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml new file +39 -0
@@ -0,0 +1,39 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/cpufreq/cpufreq-virtual-kvm.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Virtual KVM CPUFreq + +maintainers: + - David Dai <[email protected]> + +description: | + + KVM CPUFreq is a virtualized driver in guest kernels that sends utilization + of its vCPUs as a hint to the host. The host uses hint to schedule vCPU + threads and select CPU frequency. It enables accurate Per-Entity Load + Tracking for tasks running in the guest by querying host CPU frequency + unless a virtualized FIE exists(Like AMUs). + +properties: + compatible: + const: virtual,kvm-cpufreq + +required: + - compatible + +additionalProperties: false + +examples: + - | + { + #address-cells = <2>; + #size-cells = <2>; + + cpufreq { + compatible = "virtual,kvm-cpufreq"; + }; + + };
Signature · 1 line
2.40.0.348.gf938b09366-goog
Re: [RFC PATCH v2 5/6] dt-bindings: cpufreq: add bindings for virtual kvm cpufreq
Quoted 1 line · David Dai
Add devicetree bindings for a virtual kvm cpufreq driver.
Why? Why virtual devices should be documented in DT? DT is for non-discoverable hardware, right? You have entire commit msg to explain it instead of saying something easily visible by the diff.
Quoted 17 lines
Co-developed-by Saravana Kannan <[email protected]>Signed-off-by Saravana Kannan <[email protected]>Signed-off-by David Dai <[email protected]>--- .../bindings/cpufreq/cpufreq-virtual-kvm.yaml | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yamlDocumentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml new file +2
-0@@ -0,0 +1,39 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2
Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml line 12
Quoted 10 lines
Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml new file +10
-0+--- +$id: http://devicetree.org/schemas/cpufreq/cpufreq-virtual-kvm.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Virtual KVM CPUFreq + +maintainers: + - David Dai <[email protected]> + +description: |
Do not need '|'.
Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml line 13
Quoted 1 line
Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml new file +1
-0+
Drop stray blank line.
Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml line 18
Quoted 5 lines
Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml new file +5
-0+ KVM CPUFreq is a virtualized driver in guest kernels that sends utilization + of its vCPUs as a hint to the host. The host uses hint to schedule vCPU + threads and select CPU frequency. It enables accurate Per-Entity Load + Tracking for tasks running in the guest by querying host CPU frequency + unless a virtualized FIE exists(Like AMUs).
No clue why you need DT bindings for this. KVM has interfaces between host and guests.
Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml line 31
Quoted 13 lines
Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml new file +13
-0+ +properties: + compatible: + const: virtual,kvm-cpufreq + +required: + - compatible + +additionalProperties: false + +examples: + - | + {
This is some broken syntax and/or indentation.
I don't get what this node is about.
Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml line 33
Quoted 2 lines
Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml new file +2
-0+ #address-cells = <2>; + #size-cells = <2>;
Why?
Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml line 38
Quoted 5 lines
Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml new file +5
-0+ + cpufreq { + compatible = "virtual,kvm-cpufreq"; + }; +
Drop stray blank lines
Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml line 39
Quoted 1 line
Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml new file +1
-0+ };
Best regards,
Krzysztof
Rob Herring
maintainerRe: [RFC PATCH v2 5/6] dt-bindings: cpufreq: add bindings for virtual kvm cpufreq
In reply to David DaiQuoted 10 lines · David Dai
Add devicetree bindings for a virtual kvm cpufreq driver.
Co-developed-by Saravana Kannan <[email protected]>Signed-off-by Saravana Kannan <[email protected]>Signed-off-by David Dai <[email protected]>--- .../bindings/cpufreq/cpufreq-virtual-kvm.yaml | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml
My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):
yamllint warnings/errors:
dtschema/dtc warnings/errors:
Error: Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.example.dts:18.9-10 syntax error FATAL ERROR: Unable to parse input tree
make[1]: *** [scripts/Makefile.lib:419: Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.example.dtb] Error 1 make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:1512: dt_binding_check] Error 2
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]
The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.
Re: [RFC PATCH v2 5/6] dt-bindings: cpufreq: add bindings for virtual kvm cpufreq
In reply to David DaiQuoted 44 lines · David Dai
Add devicetree bindings for a virtual kvm cpufreq driver.
Co-developed-by Saravana Kannan <[email protected]>Signed-off-by Saravana Kannan <[email protected]>Signed-off-by David Dai <[email protected]>--- .../bindings/cpufreq/cpufreq-virtual-kvm.yaml | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yamlDocumentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml new file +27
-0@@ -0,0 +1,39 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/cpufreq/cpufreq-virtual-kvm.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Virtual KVM CPUFreq + +maintainers: + - David Dai <[email protected]> + +description: | + + KVM CPUFreq is a virtualized driver in guest kernels that sends utilization + of its vCPUs as a hint to the host. The host uses hint to schedule vCPU + threads and select CPU frequency. It enables accurate Per-Entity Load + Tracking for tasks running in the guest by querying host CPU frequency + unless a virtualized FIE exists(Like AMUs). + +properties: + compatible: + const: virtual,kvm-cpufreq + +required: + - compatible + +additionalProperties: false
Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml line 37
Quoted 10 lines
Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml new file +10
-0+ +examples: + - | + { + #address-cells = <2>; + #size-cells = <2>; + + cpufreq { + compatible = "virtual,kvm-cpufreq"; + };
The same thing was tried on non-virtual h/w too. This is not a device so it doesn't go in DT. It is just an abuse of DT as a kernel driver instantiation mechanism.
Rob
Re: [RFC PATCH v2 5/6] dt-bindings: cpufreq: add bindings for virtual kvm cpufreq
Quoted 52 lines · Rob Herring
Quoted 50 lines · David Dai
Add devicetree bindings for a virtual kvm cpufreq driver.
Co-developed-by Saravana Kannan <[email protected]>Signed-off-by Saravana Kannan <[email protected]>Signed-off-by David Dai <[email protected]>--- .../bindings/cpufreq/cpufreq-virtual-kvm.yaml | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yamlDocumentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml new file +33
-0@@ -0,0 +1,39 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/cpufreq/cpufreq-virtual-kvm.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Virtual KVM CPUFreq + +maintainers: + - David Dai <[email protected]> + +description: | + + KVM CPUFreq is a virtualized driver in guest kernels that sends utilization + of its vCPUs as a hint to the host. The host uses hint to schedule vCPU + threads and select CPU frequency. It enables accurate Per-Entity Load + Tracking for tasks running in the guest by querying host CPU frequency + unless a virtualized FIE exists(Like AMUs). + +properties: + compatible: + const: virtual,kvm-cpufreq + +required: + - compatible + +additionalProperties: false + +examples: + - | + { + #address-cells = <2>; + #size-cells = <2>;
Quoted 8 lines
Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml line 37
Quoted 4 lines
Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml new file +4
-0+ + cpufreq { + compatible = "virtual,kvm-cpufreq"; + };The same thing was tried on non-virtual h/w too. This is not a device so it doesn't go in DT. It is just an abuse of DT as a kernel driver instantiation mechanism.
Because it has no registers it's reading and writing, right? Yeah, just went with this for now to make it easy for people to cherry pick and test it. Maybe we shouldn't have added documentation and made this look too official.
In the end, I'm expecting this will be a real MMIO device. Until we move from RFC to PATCH, feel free to ignore this patch.
-Saravana
RFC PATCH v2 6/6 cpufreq: add kvm-cpufreq driver
In reply to David DaiIntroduce a virtualized cpufreq driver for guest kernels to improve performance and power of workloads within VMs.
This driver does two main things:
1. Sends utilization of vCPUs as a hint to the host. The host uses the hint to schedule the vCPU threads and decide physical CPU frequency.
2. If a VM does not support a virtualized FIE(like AMUs), it uses hypercalls to update the guest's frequency scaling factor periodically by querying the host CPU frequency. This enables accurate Per-Entity Load Tracking for tasks running in the guest.
Note that because the host already employs a rate_limit_us, we set the transition_delay_us of the cpufreq policy to a miniscule value(1) to avoid any additional delays between when the runqueue's util change and a frequency response on the host.
--- drivers/cpufreq/Kconfig | 13 ++ drivers/cpufreq/Makefile | 1 + drivers/cpufreq/kvm-cpufreq.c | 245 ++++++++++++++++++++++++++++++++++ include/linux/sched.h | 1 + kernel/sched/core.c | 6 + 5 files changed, 266 insertions(+) create mode 100644 drivers/cpufreq/kvm-cpufreq.c
drivers/cpufreq/Kconfig +13 -0
@@ -217,6 +217,19 @@ config CPUFREQ_DT If in doubt, say N. +config CPUFREQ_KVM + tristate "KVM cpufreq driver" + help + This adds a virtualized KVM cpufreq driver for guest kernels that + uses hypercalls to communicate with the host. It sends utilization + updates to the host and gets used to schedule vCPU threads and + select CPU frequency. If a VM does not support a virtualized FIE + such as AMUs, it updates the frequency scaling factor by polling + host CPU frequency to enable accurate Per-Entity Load Tracking + for tasks running in the guest. + + If in doubt, say N. + config CPUFREQ_DT_PLATDEV bool help
drivers/cpufreq/Makefile +1 -0
@@ -16,6 +16,7 @@ obj-$(CONFIG_CPU_FREQ_GOV_ATTR_SET) += cpufreq_governor_attr_set.o obj-$(CONFIG_CPUFREQ_DT) += cpufreq-dt.o obj-$(CONFIG_CPUFREQ_DT_PLATDEV) += cpufreq-dt-platdev.o +obj-$(CONFIG_CPUFREQ_KVM) += kvm-cpufreq.o # Traces CFLAGS_amd-pstate-trace.o := -I$(src)
drivers/cpufreq/kvm-cpufreq.c new file +245 -0
245 lines not on this page · raw message
include/linux/sched.h +1 -0
@@ -2303,6 +2303,7 @@ static inline bool owner_on_cpu(struct task_struct *owner)/* Returns effective CPU energy utilization, as seen by the scheduler */ unsigned long sched_cpu_util (int cpu); +unsigned long sched_cpu_util_freq (int cpu);#endif /* CONFIG_SMP */ #ifdef CONFIG_RSEQ
kernel/sched/core.c +6 -0
@@ -7421,6 +7421,12 @@ unsigned long sched_cpu_util(int cpu) {return effective_cpu_util (cpu,cpu_util_cfs (cpu),ENERGY_UTIL ,NULL ); } + +unsigned long sched_cpu_util_freq (int cpu) +{ +return effective_cpu_util (cpu,cpu_util_cfs (cpu),FREQUENCY_UTIL ,NULL ); +} +#endif /* CONFIG_SMP */ /**
Signature · 1 line
2.40.0.348.gf938b09366-goog