Skip to content

RFC Add a new acquire resource to query vcpu statistics

Matias Ezequiel Vara Larsen xen-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v3 RFC Latest3 patches 2 repliesIn review

Changes in v3 from the cover letter

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3xen/memory : Add a stats_table resource typexen/common/domain.c xen/common/memory.c xen/common/sched/core.c +4 more+225 -01 reply
2/3x86/mm: Do not validate/devalidate PGT_none typexen/arch/x86/mm.c xen/common/memory.c+3 -21 reply
3/3tools/misc: Add xen-vcpus-stats tooltools/misc/Makefile tools/misc/xen-vcpus-stats.c+138 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [RFC PATCH v3 0/3] Add a new acquire resource to query vcpu statistics

Hello all and apologies for the delay in sending v3,

the purpose of this RFC is to get feedback about a new acquire resource that exposes vcpu statistics for a given domain. The current mechanism to get those statistics is by querying the hypervisor. This mechanism relies on a hypercall and holds the domctl spinlock during its execution. When a pv tool like xcp-rrdd periodically samples these counters, it ends up affecting other paths that share that spinlock. By using acquire resources, the pv tool only requires a few hypercalls to set the shared memory region and samples are got without issuing any other hypercall. The original idea has been suggested by Andrew Cooper to which I have been discussing about how to implement the current PoC. You can find the RFC patch series at [1]. The series is rebased on top of stable-4.16.

The current series includes a simple pv tool that shows how this new interface is used. This tool maps the counter and periodically samples it.

Any feedback/help would be appreciated.

Thanks, Matias.

[1] https://github.com/MatiasVara/xen/commits/feature_vcpu_stats

Changes in v3:
- use memory layout discussed at
https://lists.xenproject.org/archives/html/xen-devel/2023-03/msg00383.html

Changes in v2:
- rework to ensure that consumer fetches consistent data

Changes in v1:
- rework how the resource is allocated and released
- rework when the resource is allocated that happens only when the resource is requested
- rework the structure shared between the tool and Xen to make it extensible to new counters and declare it in a public header

There are still the following questions:
- resource shall be released when there are no more readers otherwise we keep updating it during a hot path

Matias Ezequiel Vara Larsen (3):
xen/memory : Add a stats_table resource type x86/mm: Do not validate/devalidate PGT_none type tools/misc: Add xen-vcpus-stats tool

 tools/misc/Makefile          |   6 ++
 tools/misc/xen-vcpus-stats.c | 132 +++++++++++++++++++++++++++
 xen/arch/x86/mm.c            |   3 +-
 xen/common/domain.c          |   1 +
 xen/common/memory.c          | 167 +++++++++++++++++++++++++++++++++++
 xen/common/sched/core.c      |  20 +++++
 xen/include/public/memory.h  |   3 +
 xen/include/public/vcpu.h    |  27 ++++++
 xen/include/xen/mm.h         |   2 +
 xen/include/xen/sched.h      |   5 ++
 10 files changed, 365 insertions(+), 1 deletion(-)
 create mode 100644 tools/misc/xen-vcpus-stats.c
Signature · 1 line
2.34.1