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

Matias Ezequiel Vara Larsen posted 3 patches 5 months, 4 weeks ago
Only 1 patches received!
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
[RFC PATCH v3 0/3] Add a new acquire resource to query vcpu statistics
Posted by Matias Ezequiel Vara Larsen 5 months, 4 weeks ago
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

-- 
2.34.1