All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandru Elisei <alexandru.elisei@arm.com>
To: will@kernel.org, julien.thierry.kdev@gmail.com,
	linux-arm-kernel@lists.infradead.org,
	kvmarm@lists.cs.columbia.edu, maz@kernel.org,
	james.morse@arm.com, suzuki.poulose@arm.com,
	mark.rutland@arm.com, andre.przywara@arm.com
Subject: [PATCH v2 kvmtool 00/10] arm64: Improve PMU support on heterogeneous systems
Date: Thu, 27 Jan 2022 16:20:23 +0000	[thread overview]
Message-ID: <20220127162033.54290-1-alexandru.elisei@arm.com> (raw)

The series can be found at [1], and the Linux patches that this series is
based on at [2].

The series adds support for the KVM_ARM_VCPU_PMU_V3_SET_PMU PMU attribute,
which allows userspace to set a PMU for a VCPU. This PMU is used by KVM
when creating perf events to emulate the guest PMU.

Without settings this attribute, the PMU used when creating events is the
first one that successfully probed when booting, but this is unreliable as
the probe order can change (if the order of the PMUs is changed in the DTB
or if asynchronous driver probing is enabled on the host's command line),
and furthermore it requires the user to have intimate knowledge of how the
PMU was chosen in order to pin the VM on the correct physical CPUs.

With KVM_ARM_VCPU_PMU_V3_SET_PMU, the user is still expected to pin the
VCPUs on a particular set of CPUs, but now it can be any CPUs as long as
they share the same PMU. The set does not depend anymore on the driver
probe order and all that is necessary for the user to know is which CPUs
are the little core and which are the big cores, in a big.little
configuration, which I believe is more reasonable.

Patches #1-#2 are fixes and can be taken independently of this series.

Patches #3-#6 move the PMU code to aarch64, where it belongs, because the
PMU has never been supported on KVM for arm. This also paves the way for
pulling in the KVM_ARM_VCPU_PMU_V3_SET_PMU attribute, which was not defined
for KVM for arm (when KVM supported arm). This also can be merged right
now, independently of the other patches.

Patch #7 adds the cpumask_* functions which are necessary for subsequent
patches.

Patch #9 adds basic support for KVM_ARM_VCPU_PMU_V3_SET_PMU; the user is
still expected to use taskset to pin the entire VM to the correct CPUs.

Patch #10 adds --vcpu-affinity command line argument to pin VCPUs to the
correct CPUs without pinning the rest of the kvmtool threads.

Changes since v1:

* Patch #2 ("bitops.h: Include wordsize.h to provide the __WORDSIZE
  define") is new.

* Added for_each_cpu(), cpumask_and() and cpumask_subset() functions and
  all the cpumask_* functions are added in one patch.

* Bumped NR_CPUS fro arm64 to 4096 to match the Linux Kconfig option.

* Reworked the way kvmtool specific header files were included to use
  quotes to clearly differentiate them from the system level headers and to
  keep the style consistent with the current code (for example, #include
  <linux/bitops.h> is now "linux/bitops.h").

* Patch #10 ("arm64: Add --vcpu-affinity command line argument") is new.

[1] https://gitlab.arm.com/linux-arm/kvmtool-ae/-/tree/pmu-big-little-fix-v2
[2] https://gitlab.arm.com/linux-arm/linux-ae/-/tree/pmu-big-little-fix-v4

Alexandru Elisei (10):
  linux/err.h: Add missing stdbool.h include
  bitops.h: Include wordsize.h to provide the __WORDSIZE define
  arm: Move arch specific VCPU features to the arch specific function
  arm: Get rid of the ARM_VCPU_FEATURE_FLAGS() macro
  arm: Make the PMUv3 emulation code arm64 specific
  arm64: Rework set_pmu_attr()
  Add cpumask functions
  update_headers.sh: Sync headers with Linux v5.17-rc1 + SET_PMU
    attribute
  arm64: Add support for KVM_ARM_VCPU_PMU_V3_SET_PMU
  arm64: Add --vcpu-affinity command line argument

 Makefile                                      |   6 +-
 arm/aarch32/include/asm/kernel.h              |   8 +
 arm/aarch32/include/kvm/kvm-cpu-arch.h        |   4 -
 arm/aarch64/arm-cpu.c                         |   3 +-
 arm/aarch64/include/asm/kernel.h              |   8 +
 arm/aarch64/include/asm/kvm.h                 |   4 +
 .../arm-common => aarch64/include/asm}/pmu.h  |   0
 arm/aarch64/include/kvm/kvm-config-arch.h     |   5 +
 arm/aarch64/include/kvm/kvm-cpu-arch.h        |   6 -
 arm/aarch64/kvm-cpu.c                         |  21 ++
 arm/aarch64/kvm.c                             |  32 +++
 arm/aarch64/pmu.c                             | 231 ++++++++++++++++
 arm/include/arm-common/kvm-arch.h             |   7 +
 arm/include/arm-common/kvm-config-arch.h      |   1 +
 arm/kvm-cpu.c                                 |  14 +-
 arm/pmu.c                                     |  76 ------
 include/linux/bitmap.h                        |  71 +++++
 include/linux/bitops.h                        |   4 +
 include/linux/bits.h                          |   8 +
 include/linux/cpumask.h                       |  67 +++++
 include/linux/err.h                           |   2 +
 include/linux/find.h                          |  30 ++
 include/linux/kernel.h                        |   6 +
 include/linux/kvm.h                           |  16 ++
 mips/include/asm/kernel.h                     |   8 +
 powerpc/include/asm/kernel.h                  |   8 +
 util/bitmap.c                                 | 256 ++++++++++++++++++
 util/find.c                                   |  40 +++
 x86/include/asm/kernel.h                      |   8 +
 x86/include/asm/kvm.h                         |  16 +-
 30 files changed, 867 insertions(+), 99 deletions(-)
 create mode 100644 arm/aarch32/include/asm/kernel.h
 create mode 100644 arm/aarch64/include/asm/kernel.h
 rename arm/{include/arm-common => aarch64/include/asm}/pmu.h (100%)
 create mode 100644 arm/aarch64/pmu.c
 delete mode 100644 arm/pmu.c
 create mode 100644 include/linux/bitmap.h
 create mode 100644 include/linux/bits.h
 create mode 100644 include/linux/cpumask.h
 create mode 100644 include/linux/find.h
 create mode 100644 mips/include/asm/kernel.h
 create mode 100644 powerpc/include/asm/kernel.h
 create mode 100644 util/bitmap.c
 create mode 100644 util/find.c
 create mode 100644 x86/include/asm/kernel.h

-- 
2.31.1

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

WARNING: multiple messages have this Message-ID (diff)
From: Alexandru Elisei <alexandru.elisei@arm.com>
To: will@kernel.org, julien.thierry.kdev@gmail.com,
	linux-arm-kernel@lists.infradead.org,
	kvmarm@lists.cs.columbia.edu, maz@kernel.org,
	james.morse@arm.com, suzuki.poulose@arm.com,
	mark.rutland@arm.com, andre.przywara@arm.com
Subject: [PATCH v2 kvmtool 00/10] arm64: Improve PMU support on heterogeneous systems
Date: Thu, 27 Jan 2022 16:20:23 +0000	[thread overview]
Message-ID: <20220127162033.54290-1-alexandru.elisei@arm.com> (raw)

The series can be found at [1], and the Linux patches that this series is
based on at [2].

The series adds support for the KVM_ARM_VCPU_PMU_V3_SET_PMU PMU attribute,
which allows userspace to set a PMU for a VCPU. This PMU is used by KVM
when creating perf events to emulate the guest PMU.

Without settings this attribute, the PMU used when creating events is the
first one that successfully probed when booting, but this is unreliable as
the probe order can change (if the order of the PMUs is changed in the DTB
or if asynchronous driver probing is enabled on the host's command line),
and furthermore it requires the user to have intimate knowledge of how the
PMU was chosen in order to pin the VM on the correct physical CPUs.

With KVM_ARM_VCPU_PMU_V3_SET_PMU, the user is still expected to pin the
VCPUs on a particular set of CPUs, but now it can be any CPUs as long as
they share the same PMU. The set does not depend anymore on the driver
probe order and all that is necessary for the user to know is which CPUs
are the little core and which are the big cores, in a big.little
configuration, which I believe is more reasonable.

Patches #1-#2 are fixes and can be taken independently of this series.

Patches #3-#6 move the PMU code to aarch64, where it belongs, because the
PMU has never been supported on KVM for arm. This also paves the way for
pulling in the KVM_ARM_VCPU_PMU_V3_SET_PMU attribute, which was not defined
for KVM for arm (when KVM supported arm). This also can be merged right
now, independently of the other patches.

Patch #7 adds the cpumask_* functions which are necessary for subsequent
patches.

Patch #9 adds basic support for KVM_ARM_VCPU_PMU_V3_SET_PMU; the user is
still expected to use taskset to pin the entire VM to the correct CPUs.

Patch #10 adds --vcpu-affinity command line argument to pin VCPUs to the
correct CPUs without pinning the rest of the kvmtool threads.

Changes since v1:

* Patch #2 ("bitops.h: Include wordsize.h to provide the __WORDSIZE
  define") is new.

* Added for_each_cpu(), cpumask_and() and cpumask_subset() functions and
  all the cpumask_* functions are added in one patch.

* Bumped NR_CPUS fro arm64 to 4096 to match the Linux Kconfig option.

* Reworked the way kvmtool specific header files were included to use
  quotes to clearly differentiate them from the system level headers and to
  keep the style consistent with the current code (for example, #include
  <linux/bitops.h> is now "linux/bitops.h").

* Patch #10 ("arm64: Add --vcpu-affinity command line argument") is new.

[1] https://gitlab.arm.com/linux-arm/kvmtool-ae/-/tree/pmu-big-little-fix-v2
[2] https://gitlab.arm.com/linux-arm/linux-ae/-/tree/pmu-big-little-fix-v4

Alexandru Elisei (10):
  linux/err.h: Add missing stdbool.h include
  bitops.h: Include wordsize.h to provide the __WORDSIZE define
  arm: Move arch specific VCPU features to the arch specific function
  arm: Get rid of the ARM_VCPU_FEATURE_FLAGS() macro
  arm: Make the PMUv3 emulation code arm64 specific
  arm64: Rework set_pmu_attr()
  Add cpumask functions
  update_headers.sh: Sync headers with Linux v5.17-rc1 + SET_PMU
    attribute
  arm64: Add support for KVM_ARM_VCPU_PMU_V3_SET_PMU
  arm64: Add --vcpu-affinity command line argument

 Makefile                                      |   6 +-
 arm/aarch32/include/asm/kernel.h              |   8 +
 arm/aarch32/include/kvm/kvm-cpu-arch.h        |   4 -
 arm/aarch64/arm-cpu.c                         |   3 +-
 arm/aarch64/include/asm/kernel.h              |   8 +
 arm/aarch64/include/asm/kvm.h                 |   4 +
 .../arm-common => aarch64/include/asm}/pmu.h  |   0
 arm/aarch64/include/kvm/kvm-config-arch.h     |   5 +
 arm/aarch64/include/kvm/kvm-cpu-arch.h        |   6 -
 arm/aarch64/kvm-cpu.c                         |  21 ++
 arm/aarch64/kvm.c                             |  32 +++
 arm/aarch64/pmu.c                             | 231 ++++++++++++++++
 arm/include/arm-common/kvm-arch.h             |   7 +
 arm/include/arm-common/kvm-config-arch.h      |   1 +
 arm/kvm-cpu.c                                 |  14 +-
 arm/pmu.c                                     |  76 ------
 include/linux/bitmap.h                        |  71 +++++
 include/linux/bitops.h                        |   4 +
 include/linux/bits.h                          |   8 +
 include/linux/cpumask.h                       |  67 +++++
 include/linux/err.h                           |   2 +
 include/linux/find.h                          |  30 ++
 include/linux/kernel.h                        |   6 +
 include/linux/kvm.h                           |  16 ++
 mips/include/asm/kernel.h                     |   8 +
 powerpc/include/asm/kernel.h                  |   8 +
 util/bitmap.c                                 | 256 ++++++++++++++++++
 util/find.c                                   |  40 +++
 x86/include/asm/kernel.h                      |   8 +
 x86/include/asm/kvm.h                         |  16 +-
 30 files changed, 867 insertions(+), 99 deletions(-)
 create mode 100644 arm/aarch32/include/asm/kernel.h
 create mode 100644 arm/aarch64/include/asm/kernel.h
 rename arm/{include/arm-common => aarch64/include/asm}/pmu.h (100%)
 create mode 100644 arm/aarch64/pmu.c
 delete mode 100644 arm/pmu.c
 create mode 100644 include/linux/bitmap.h
 create mode 100644 include/linux/bits.h
 create mode 100644 include/linux/cpumask.h
 create mode 100644 include/linux/find.h
 create mode 100644 mips/include/asm/kernel.h
 create mode 100644 powerpc/include/asm/kernel.h
 create mode 100644 util/bitmap.c
 create mode 100644 util/find.c
 create mode 100644 x86/include/asm/kernel.h

-- 
2.31.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

             reply	other threads:[~2022-01-27 16:20 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-27 16:20 Alexandru Elisei [this message]
2022-01-27 16:20 ` [PATCH v2 kvmtool 00/10] arm64: Improve PMU support on heterogeneous systems Alexandru Elisei
2022-01-27 16:20 ` [PATCH v2 kvmtool 01/10] linux/err.h: Add missing stdbool.h include Alexandru Elisei
2022-01-27 16:20   ` Alexandru Elisei
2022-01-27 16:20 ` [PATCH v2 kvmtool 02/10] bitops.h: Include wordsize.h to provide the __WORDSIZE define Alexandru Elisei
2022-01-27 16:20   ` Alexandru Elisei
2022-01-27 16:20 ` [PATCH v2 kvmtool 03/10] arm: Move arch specific VCPU features to the arch specific function Alexandru Elisei
2022-01-27 16:20   ` Alexandru Elisei
2022-01-27 16:20 ` [PATCH v2 kvmtool 04/10] arm: Get rid of the ARM_VCPU_FEATURE_FLAGS() macro Alexandru Elisei
2022-01-27 16:20   ` Alexandru Elisei
2022-01-27 16:20 ` [PATCH v2 kvmtool 05/10] arm: Make the PMUv3 emulation code arm64 specific Alexandru Elisei
2022-01-27 16:20   ` Alexandru Elisei
2022-01-27 16:20 ` [PATCH v2 kvmtool 06/10] arm64: Rework set_pmu_attr() Alexandru Elisei
2022-01-27 16:20   ` Alexandru Elisei
2022-01-27 16:20 ` [PATCH v2 kvmtool 07/10] Add cpumask functions Alexandru Elisei
2022-01-27 16:20   ` Alexandru Elisei
2022-01-27 16:20 ` [PATCH v2 kvmtool 08/10] update_headers.sh: Sync headers with Linux v5.17-rc1 + SET_PMU attribute Alexandru Elisei
2022-01-27 16:20   ` Alexandru Elisei
2022-01-27 16:20 ` [PATCH v2 kvmtool 09/10] arm64: Add support for KVM_ARM_VCPU_PMU_V3_SET_PMU Alexandru Elisei
2022-01-27 16:20   ` Alexandru Elisei
2022-01-27 16:20 ` [PATCH v2 kvmtool 10/10] arm64: Add --vcpu-affinity command line argument Alexandru Elisei
2022-01-27 16:20   ` Alexandru Elisei
2022-02-14 10:20 ` [PATCH v2 kvmtool 00/10] arm64: Improve PMU support on heterogeneous systems Alexandru Elisei
2022-02-14 10:20   ` Alexandru Elisei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220127162033.54290-1-alexandru.elisei@arm.com \
    --to=alexandru.elisei@arm.com \
    --cc=andre.przywara@arm.com \
    --cc=james.morse@arm.com \
    --cc=julien.thierry.kdev@gmail.com \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.