[PATCH v6 3/3] Add support for RAPL MSRs in KVM/Qemu

2024-05-22 Thread Anthony Harivel
th/sock.sock Actual limitation: - Works only on Intel host CPU because AMD CPUs are using different MSR adresses. - Only the Package Power-Plane (MSR_PKG_ENERGY_STATUS) is reported at the moment. Signed-off-by: Anthony Harivel --- accel/kvm/kvm-all.c | 27 +++ docs/specs/index.rst

[PATCH v6 1/3] qio: add support for SO_PEERCRED for socket channel

2024-05-22 Thread Anthony Harivel
of the sending process */ gid_t gid;/* Group ID of the sending process */ }; The use of this function is possible only for connected AF_UNIX stream sockets and for AF_UNIX stream and datagram socket pairs. On platform other than Linux, the function return 0. Signed-off-by: Anthony Harivel

[PATCH v6 2/3] tools: build qemu-vmsr-helper

2024-05-22 Thread Anthony Harivel
Us but can be extended to support AMD CPUs in the future. Signed-off-by: Anthony Harivel --- contrib/systemd/qemu-vmsr-helper.service | 15 + contrib/systemd/qemu-vmsr-helper.socket | 9 + docs/tools/index.rst | 1 + docs/tools/qemu-vmsr-helper.rst | 89 m

[PATCH v6 0/3] Add support for the RAPL MSRs series

2024-05-22 Thread Anthony Harivel
html [4]: https://mail.gnu.org/archive/html/qemu-devel/2024-04/msg02481.html Anthony Harivel (3): qio: add support for SO_PEERCRED for socket channel tools: build qemu-vmsr-helper Add support for RAPL MSRs in KVM/Qemu accel/kvm/kvm-all.c | 27 ++ contrib/systemd/qemu-v

Re: [PATCH v5 3/3] Add support for RAPL MSRs in KVM/Qemu

2024-05-06 Thread Anthony Harivel
Anthony Harivel, Apr 26, 2024 at 10:36: > > Hi Paolo, > > Daniel P. Berrangé, Apr 25, 2024 at 17:42: > > On Thu, Apr 25, 2024 at 05:34:52PM +0200, Anthony Harivel wrote: > > > Hi Daniel, > > > > > > Daniel P. Berrangé, Apr 18, 2024 at 18:42: > &g

Re: [PATCH v5 3/3] Add support for RAPL MSRs in KVM/Qemu

2024-04-26 Thread Anthony Harivel
Hi Paolo, Daniel P. Berrangé, Apr 25, 2024 at 17:42: > On Thu, Apr 25, 2024 at 05:34:52PM +0200, Anthony Harivel wrote: > > Hi Daniel, > > > > Daniel P. Berrangé, Apr 18, 2024 at 18:42: > > > > > > +if (kvm_is_rapl_feat_enable(cs)) {

Re: [PATCH v5 3/3] Add support for RAPL MSRs in KVM/Qemu

2024-04-25 Thread Anthony Harivel
Hi Daniel, Daniel P. Berrangé, Apr 18, 2024 at 18:42: > > +if (kvm_is_rapl_feat_enable(cs)) { > > +if (!IS_INTEL_CPU(env)) { > > +error_setg(errp, "RAPL feature can only be\ > > + enabled with Intel CPU models"); > > +return

Re: [PATCH v5 3/3] Add support for RAPL MSRs in KVM/Qemu

2024-04-18 Thread Anthony Harivel
Hi Daniel, Daniel P. Berrangé, Apr 18, 2024 at 18:42: > On Thu, Apr 11, 2024 at 02:14:34PM +0200, Anthony Harivel wrote: > > Starting with the "Sandy Bridge" generation, Intel CPUs provide a RAPL > > interface (Running Average Power Limit) for advertising the accumulat

Re: [PATCH v5 3/3] Add support for RAPL MSRs in KVM/Qemu

2024-04-18 Thread Anthony Harivel
Hi Zhao, Zhao Liu, Apr 17, 2024 at 12:07: > Hi Anthony, > > May I ask what your usage scenario is? Is it to measure Guest's energy > consumption and to charged per watt consumed? ;-) See previous email from Daniel. > On Thu, Apr 11, 2024 at 02:14:34PM +0200, Anthony Harivel

Re: [PATCH v5 3/3] Add support for RAPL MSRs in KVM/Qemu

2024-04-18 Thread Anthony Harivel
RAPL MSRs in KVM/Qemu > > > > On Wed, Apr 17, 2024 at 06:07:02PM +0800, Zhao Liu wrote: > > > Hi Anthony, > > > > > > May I ask what your usage scenario is? Is it to measure Guest's energy > > > consumption and to charged per watt consumed? ;-) >

Re: [PATCH v5 0/3] Add support for the RAPL MSRs series

2024-04-18 Thread Anthony Harivel
Hi Daniel, Daniel P. Berrangé, Apr 17, 2024 at 19:23: > On Thu, Apr 11, 2024 at 02:14:31PM +0200, Anthony Harivel wrote: > > Dear maintainers, > > > > First of all, thank you very much for your review of my patch > > [1]. > > > > In this versio

[PATCH v5 1/3] qio: add support for SO_PEERCRED for socket channel

2024-04-11 Thread Anthony Harivel
of the sending process */ gid_t gid;/* Group ID of the sending process */ }; The use of this function is possible only for connected AF_UNIX stream sockets and for AF_UNIX stream and datagram socket pairs. On platform other than Linux, the function return 0. Signed-off-by: Anthony Harivel

[PATCH v5 3/3] Add support for RAPL MSRs in KVM/Qemu

2024-04-11 Thread Anthony Harivel
th/sock.sock Actual limitation: - Works only on Intel host CPU because AMD CPUs are using different MSR adresses. - Only the Package Power-Plane (MSR_PKG_ENERGY_STATUS) is reported at the moment. Signed-off-by: Anthony Harivel --- accel/kvm/kvm-all.c | 27 +++ docs/specs/index.rst

[PATCH v5 0/3] Add support for the RAPL MSRs series

2024-04-11 Thread Anthony Harivel
ards, Anthony [1]: https://lists.gnu.org/archive/html/qemu-devel/2024-03/msg04417.html Anthony Harivel (3): qio: add support for SO_PEERCRED for socket channel tools: build qemu-vmsr-helper Add support for RAPL MSRs in KVM/Qemu accel/kvm/kvm-all.c | 27 ++

[PATCH v5 2/3] tools: build qemu-vmsr-helper

2024-04-11 Thread Anthony Harivel
Us but can be extended to support AMD CPUs in the future. Signed-off-by: Anthony Harivel --- contrib/systemd/qemu-vmsr-helper.service | 15 + contrib/systemd/qemu-vmsr-helper.socket | 9 + docs/tools/index.rst | 1 + docs/tools/qemu-vmsr-helper.rst | 89 m

Re: [PATCH v4 3/3] Add support for RAPL MSRs in KVM/Qemu

2024-04-05 Thread Anthony Harivel
Hi Daniel, > > +SocketAddress saddr = { > > +.type = SOCKET_ADDRESS_TYPE_UNIX, > > +.u.q_unix.path = socket_path > > +}; > > +QIOChannelSocket *sioc = qio_channel_socket_new(); > > +Error *local_err = NULL; > > + > > +int r; > > + > > +

Re: [PATCH v4 2/3] tools: build qemu-vmsr-helper

2024-03-28 Thread Anthony Harivel
Hi Daniel, My apologies for all the missed feedback in v2. I'll be more organized for my next iteration. For this specific comment below, I would like to make sure I'm testing the right way. > > diff --git a/meson.build b/meson.build > > index b375248a7614..376da49b60ab 100644 > > ---

[PATCH v4 3/3] Add support for RAPL MSRs in KVM/Qemu

2024-03-18 Thread Anthony Harivel
th/sock.sock Actual limitation: - Works only on Intel host CPU because AMD CPUs are using different MSR adresses. - Only the Package Power-Plane (MSR_PKG_ENERGY_STATUS) is reported at the moment. Signed-off-by: Anthony Harivel --- accel/kvm/kvm-all.c | 27 +++ docs/specs/index.rst

[PATCH v4 2/3] tools: build qemu-vmsr-helper

2024-03-18 Thread Anthony Harivel
Us but can be extended to support AMD CPUs in the future. Signed-off-by: Anthony Harivel --- contrib/systemd/qemu-vmsr-helper.service | 15 + contrib/systemd/qemu-vmsr-helper.socket | 9 + docs/tools/index.rst | 1 + docs/tools/qemu-vmsr-helper.rst | 89 m

[PATCH v4 0/3] Add support for the RAPL MSRs series

2024-03-18 Thread Anthony Harivel
nd usage Best regards, Anthony [1]: https://lore.kernel.org/all/20240125072214.318382-1-ahari...@redhat.com/#t Anthony Harivel (3): qio: add support for SO_PEERCRED for socket channel tools: build qemu-vmsr-helper Add support for RAPL MSRs in KVM/Qemu accel/kvm/kvm-all.c |

[PATCH v4 1/3] qio: add support for SO_PEERCRED for socket channel

2024-03-18 Thread Anthony Harivel
of the sending process */ gid_t gid;/* Group ID of the sending process */ }; The use of this function is possible only for connected AF_UNIX stream sockets and for AF_UNIX stream and datagram socket pairs. On platform other than Linux, the function return 0. Signed-off-by: Anthony Harivel

Re: [PATCH v3 3/3] Add support for RAPL MSRs in KVM/Qemu

2024-03-14 Thread Anthony Harivel
Hi Daniel, > You don't need to access it via the /node/ hierarchy > > The canonical path for CPUs would be > > /sys/devices/system/cpu/cpuNNN/topology > > The core_cpus_list file is giving you hyper-thread siblings within > a core, which I don't think is what you want. > > If you're after

Re: [PATCH v3 3/3] Add support for RAPL MSRs in KVM/Qemu

2024-03-13 Thread Anthony Harivel
Hi Daniel, Daniel P. Berrangé, Mar 12, 2024 at 16:49: > The point still stands though. NUMA node ID numbers are not > guaranteed to be the same as socket ID numbers. Very often > then will be the same (which makes it annoying to test as it > is easy to not realize the difference), but we can't

Re: [PATCH v3 3/3] Add support for RAPL MSRs in KVM/Qemu

2024-03-12 Thread Anthony Harivel
Hi Daniel, Paolo, Here my last questions before wrapping up and send v4, or maybe call off my attempt to add RAPL interface in QEMU. Daniel P. Berrangé, Jan 30, 2024 at 10:39: > > +rcu_register_thread(); > > + > > +/* Get QEMU PID*/ > > +pid = getpid(); > > + > > +/* Nb of

Re: [PATCH v3 3/3] Add support for RAPL MSRs in KVM/Qemu

2024-03-05 Thread Anthony Harivel
Hi Daniel, > > + > > +/* Retrieve all packages power plane energy counter */ > > +for (int i = 0; i <= maxpkgs; i++) { > > +for (int j = 0; j < num_threads; j++) { > > +/* > > + * Use the first thread we found that ran on the CPU > > +

Re: [PATCH v3 3/3] Add support for RAPL MSRs in KVM/Qemu

2024-03-05 Thread Anthony Harivel
Daniel P. Berrangé, Mar 04, 2024 at 15:48: > On Mon, Mar 04, 2024 at 03:41:02PM +0100, Anthony Harivel wrote: > > > > Hi Daniel, > > > > > > +if (s->msr_energy.enable == true) { > > > > > > This looks to be where we need

Re: [PATCH v3 3/3] Add support for RAPL MSRs in KVM/Qemu

2024-03-04 Thread Anthony Harivel
Hi Daniel, > > +if (s->msr_energy.enable == true) { > > This looks to be where we need to check that both the host CPU > vendor is intel, and the guest CPU vendor is intel, and that > the host CPU has the RAPL feature we're using. > > With regards, > Daniel > -- > |:

Re: [PATCH v3 2/3] tools: build qemu-vmsr-helper

2024-03-01 Thread Anthony Harivel
Hi Paolo, > > > +static void compute_default_paths(void) > > > +{ > > > +socket_path = g_build_filename("/run", "qemu-vmsr-helper.sock", > > > NULL); > > > +pidfile = g_build_filename("/run", "qemu-vmsr-helper.pid", NULL); > > > +} > > > > We shouldn't be hardcoding /run, we need to

Re: [PATCH v3 2/3] tools: build qemu-vmsr-helper

2024-02-21 Thread Anthony Harivel
Daniel P. Berrangé, Feb 21, 2024 at 14:47: > On Wed, Feb 21, 2024 at 02:19:11PM +0100, Anthony Harivel wrote: > > Daniel P. Berrangé, Jan 29, 2024 at 20:45: > > > On Mon, Jan 29, 2024 at 08:33:21PM +0100, Paolo Bonzini wrote: > > > > On Mon, Jan 29, 2024

Re: [PATCH v3 2/3] tools: build qemu-vmsr-helper

2024-02-21 Thread Anthony Harivel
Daniel P. Berrangé, Jan 29, 2024 at 20:45: > On Mon, Jan 29, 2024 at 08:33:21PM +0100, Paolo Bonzini wrote: > > On Mon, Jan 29, 2024 at 7:53 PM Daniel P. Berrangé > > wrote: > > > > diff --git a/meson.build b/meson.build > > > > index d0329966f1b4..93fc233b0891 100644 > > > > --- a/meson.build >

Re: [PATCH v3 3/3] Add support for RAPL MSRs in KVM/Qemu

2024-02-20 Thread Anthony Harivel
Daniel P. Berrangé, Jan 29, 2024 at 20:29: > On Thu, Jan 25, 2024 at 08:22:14AM +0100, Anthony Harivel wrote: > > diff --git a/docs/specs/rapl-msr.rst b/docs/specs/rapl-msr.rst > > new file mode 100644 > > index ..04d27c198fc0 > > --- /dev/null > &

[PATCH v3 0/3] Add support for the RAPL MSRs series

2024-01-24 Thread Anthony Harivel
age Best regards, Anthony [1]: https://www.mail-archive.com/qemu-devel@nongnu.org/msg1003382.html Anthony Harivel (3): qio: add support for SO_PEERCRED for socket channel tools: build qemu-vmsr-helper Add support for RAPL MSRs in KVM/Qemu accel/kvm/kvm-all.c | 27 ++

[PATCH v3 3/3] Add support for RAPL MSRs in KVM/Qemu

2024-01-24 Thread Anthony Harivel
th/sock.sock Actual limitation: - Works only on Intel host CPU because AMD CPUs are using different MSR adresses. - Only the Package Power-Plane (MSR_PKG_ENERGY_STATUS) is reported at the moment. Signed-off-by: Anthony Harivel --- accel/kvm/kvm-all.c | 27 +++ docs/specs/index.rst

[PATCH v3 1/3] qio: add support for SO_PEERCRED for socket channel

2024-01-24 Thread Anthony Harivel
of the sending process */ gid_t gid;/* Group ID of the sending process */ }; The use of this function is possible only for connected AF_UNIX stream sockets and for AF_UNIX stream and datagram socket pairs. On platform other than Linux, the function return 0. Signed-off-by: Anthony Harivel

[PATCH v3 2/3] tools: build qemu-vmsr-helper

2024-01-24 Thread Anthony Harivel
Us but can be extended to support AMD CPUs in the future. Signed-off-by: Anthony Harivel --- contrib/systemd/qemu-vmsr-helper.service | 15 + contrib/systemd/qemu-vmsr-helper.socket | 9 + docs/tools/index.rst | 1 + docs/tools/qemu-vmsr-helper.rst | 89 m

[PATCH v2 1/3] qio: add support for SO_PEERCRED for socket channel

2023-10-31 Thread Anthony Harivel
of the sending process */ gid_t gid;/* Group ID of the sending process */ }; The use of this function is possible only for connected AF_UNIX stream sockets and for AF_UNIX stream and datagram socket pairs. Signed-off-by: Anthony Harivel --- include/io/channel.h | 20 io

[PATCH v2 0/3] Add support for RAPL MSRs series

2023-10-31 Thread Anthony Harivel
-devel/20230616140830.316655-1-ahari...@redhat.com/ Anthony Harivel (3): qio: add support for SO_PEERCRED for socket channel tools: build qemu-vmsr-helper Add support for RAPL MSRs in KVM/Qemu accel/kvm/kvm-all.c | 26 ++ docs/specs/index.rst| 1 + docs/specs/rapl-m

[PATCH v2 2/3] tools: build qemu-vmsr-helper

2023-10-31 Thread Anthony Harivel
is defined in rapl-msr-index.h. This list corresponds to the RAPL MSRs that will be supported in the next commit titled "Add support for RAPL MSRs in KVM/QEMU." Signed-off-by: Anthony Harivel --- docs/tools/index.rst| 1 + docs/tools/qemu-vmsr-helper.rst | 89 ++ m

[PATCH v2 3/3] Add support for RAPL MSRs in KVM/Qemu

2023-10-31 Thread Anthony Harivel
reality. There must be a single vCPU per virtual socket (e.g.: -smp 4,sockets=4). Accessing pkg-0 energy will give vCPU 0 energy, pkg-1 will give vCPU 1 energy, etc. Signed-off-by: Anthony Harivel accel/kvm/kvm-all.c | 26 +++ docs/specs/index.rst | 1 + docs/specs/rapl

Re: [PATCH] Add support for RAPL MSRs in KVM/Qemu

2023-06-28 Thread Anthony Harivel
Marcelo Tosatti, Jun 28, 2023 at 19:26: Hi Marcelo, > On Fri, Jun 16, 2023 at 04:08:30PM +0200, Anthony Harivel wrote: > This feature is activated with -accel kvm,rapl=true. > >> I suppose this should be a CPU flag instead? -cpu xxx,rapl=on. It's possible yes then I might ne

[PATCH] Add support for RAPL MSRs in KVM/Qemu

2023-06-16 Thread Anthony Harivel
dependent vMSR value, the vCPU topology must be changed to match that reality. There must be a single vCPU per virtual socket (e.g.: -smp 4,sockets=4). Accessing pkg-0 energy will give vCPU 0 energy, pkg-1 will give vCPU 1 energy, etc. Signed-off-by: Anthony Harivel --- Notes: This is a

Re: [RFC PATCH] Add support for RAPL MSRs in KVM/Qemu

2023-05-24 Thread Anthony Harivel
, > > > > + strerror(-ret)); > > > > +exit(1); > > > > +} > > > > + > > > > + r = kvm_filter_msr(s, MSR_PKG_POWER_LIMIT, > > > > + kvm_rdmsr_

Re: [RFC PATCH] Add support for RAPL MSRs in KVM/Qemu

2023-05-19 Thread Anthony Harivel
Philippe Mathieu-Daudé, May 19, 2023 at 13:32: Hi Philippe, > > +/* > > + * Package statistic > > + * @ e_start: package energy counter before the sleep > > + * @ e_end: package energy counter after the sleep > > + * @ e_delta: delta of package energy counter > > + * @ e_ratio: store the energy

Re: [RFC PATCH] Add support for RAPL MSRs in KVM/Qemu

2023-05-18 Thread Anthony Harivel
Marcelo Tosatti, May 17, 2023 at 17:43: Hi Marcelo, > On Wed, May 17, 2023 at 03:07:30PM +0200, Anthony Harivel wrote: > diff --git a/target/i386/cpu.h b/target/i386/cpu.h > > index 8504aaac6807..14f9c2901680 100644 > > --- a/target/i386/cpu.h > > +++ b/target/i386/cpu

[RFC PATCH] Add support for RAPL MSRs in KVM/Qemu

2023-05-17 Thread Anthony Harivel
dependent vMSR value, the vCPU topology must be changed to match that reality. There must be a single vCPU per virtual socket (e.g.: -smp 4,sockets=4). Accessing pkg-0 energy will give vCPU 0 energy, pkg-1 will give vCPU 1 energy, etc. Signed-off-by: Anthony Harivel --- Notes: Ear