[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 3/3] Add support for RAPL MSRs in KVM/Qemu
From: |
Daniel P . Berrangé |
Subject: |
Re: [PATCH v3 3/3] Add support for RAPL MSRs in KVM/Qemu |
Date: |
Thu, 14 Mar 2024 08:55:29 +0000 |
User-agent: |
Mutt/2.2.12 (2023-09-09) |
On Thu, Mar 14, 2024 at 09:26:53AM +0100, Anthony Harivel wrote:
>
> 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 discrete physical packages, then 'package_cpus_list'
> > gives you all CPUs within a physical socket (package) I believe.
> >
>
> Yes, this could work.
> However, on laptop, I've got:
> cat package_cpus_list
> 0-11
>
> Where on server:
> package_cpus_list
> 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46
>
> I asked my teammate: always the same results. This is I guess due to
> either a difference in the kernel version or how the kernel is handling
> the case where there is only one package, versus the case with multiple
> packages.
Both are the same data format - it is a list of ranges. In the
laptop example, there's only a single range to parse. In the
server example there are many ranges but since each range is
only 1 cpu, it has collapsed the ranges to the single CPU id.
> Anyway, writing a C function to handle both cases might not be easy.
Approximately
* Read the whole file with g_get_file_contents
* Use g_strsplit(data, ",", 0) to get a list of ranges
* Iterate over the return list of ranges and g_strsplit(range, "-", 2);
- The returned list should be either a single element (if there was
no '-'), or a pair of elements (if there was a N-M)
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|