From: Laszlo Ersek <lersek@redhat.com>
To: mdroth <mdroth@linux.vnet.ibm.com>
Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, lcapitulino@redhat.com
Subject: Re: [Qemu-devel] [PATCH 2/3] qga: implement qmp_guest_get_vcpus() for Linux with sysfs
Date: Tue, 05 Mar 2013 22:05:48 +0100 [thread overview]
Message-ID: <51365E2C.8080402@redhat.com> (raw)
In-Reply-To: <20130305200345.GF21850@vm>
On 03/05/13 21:03, mdroth wrote:> On Mon, Mar 04, 2013 at 11:19:56PM +0100, Laszlo Ersek wrote:
>> +#if defined(__linux__)
>
> There's a section in commands-posix.c set aside under "linux-specific
> implementations" for these, and another underneath for stubs so we can
> avoid having too many ifdef's.
I'll check it, thanks.
>> + buf = g_strdup_printf("/sys/devices/system/cpu/cpu%ld/online",
>> + current);
>> + f = fopen(buf, "r");
>> + if (f == NULL) {
>> + error_setg_errno(&local_err, errno, "fopen(\"%s\", \"r\")", buf);
>> + } else {
>> + unsigned online;
>> +
>> + if (fscanf(f, "%u", &online) != 1) {
>
> On Fedora 18 and Ubuntu 12.04 at least there doesn't seem to be per-cpu
> values for online/offline/etc, but instead just a 'global' entry at
> /sys/devices/system/cpu/{online,offline} that provides a range. This is
> what's currently described in
> linux/Documentation/ABI/testing/sysfs-devices-system-cpu as well.
>
> Is that file also available on the distro you're testing with? Hopefully
> there's a single interfaces we can rely on.
On RHEL-6, both "/sys/devices/system/cpu/cpu*/online" and
"/sys/devices/system/cpu/online " are available.
On RHEL-5, only "/sys/devices/system/cpu/cpu*/online" is available.
"/sys/devices/system/cpu/cpu*/online" is documented in
"Documentation/cpu-hotplug.txt", in all of RHEL-5, RHEL-6, and upstream
Linux.
#pwd
#/sys/devices/system/cpu
#ls -l
total 0
drwxr-xr-x 10 root root 0 Sep 19 07:44 .
drwxr-xr-x 13 root root 0 Sep 19 07:45 ..
drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu0
drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu1
drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu2
drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu3
drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu4
drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu5
drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu6
drwxr-xr-x 3 root root 0 Sep 19 07:48 cpu7
Under each directory you would find an "online" file which is the control
file to logically online/offline a processor.
Q: Does hot-add/hot-remove refer to physical add/remove of cpus?
A: The usage of hot-add/remove may not be very consistently used in the code.
CONFIG_HOTPLUG_CPU enables logical online/offline capability in the kernel.
To support physical addition/removal, one would need some BIOS hooks and
the platform should have something like an attention button in PCI hotplug.
CONFIG_ACPI_HOTPLUG_CPU enables ACPI support for physical add/remove of CPUs.
The kernels you mention may not have CONFIG_HOTPLUG_CPU enabled
(consequently they would probably not support the functionality either).
... I just checked "/boot/config-3.8.2-201.fc18.x86_64" in
"kernel-3.8.2-201.fc18.x86_64.rpm" and all required config options seem
to be set. I checked on a much older F18 guest as well
(3.6.10-4.fc18.x86_64), and the per-cpu "online" files are there. (Not
for cpu0, but I'll address that in response to Eric's review.) I'm not
sure why you don't get them under F18.
Thanks
Laszlo
next prev parent reply other threads:[~2013-03-05 21:04 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-04 22:19 [Qemu-devel] [PATCH 0/3] qga/Linux: online/offline/query VCPUs via guest sysfs Laszlo Ersek
2013-03-04 22:19 ` [Qemu-devel] [PATCH 1/3] qga: introduce guest-get-vcpus / guest-set-vcpus with stubs Laszlo Ersek
2013-03-05 21:08 ` Eric Blake
2013-03-05 23:05 ` Laszlo Ersek
2013-03-05 23:12 ` Eric Blake
2013-03-05 23:32 ` Laszlo Ersek
2013-03-06 7:40 ` Andrew Jones
2013-03-06 13:49 ` Eric Blake
2013-03-06 16:37 ` Laszlo Ersek
2013-03-04 22:19 ` [Qemu-devel] [PATCH 2/3] qga: implement qmp_guest_get_vcpus() for Linux with sysfs Laszlo Ersek
2013-03-05 20:03 ` mdroth
2013-03-05 20:22 ` Eric Blake
2013-03-05 20:45 ` mdroth
2013-03-05 21:05 ` Laszlo Ersek [this message]
2013-03-05 20:25 ` Eric Blake
2013-03-05 21:34 ` Laszlo Ersek
2013-03-05 22:06 ` mdroth
2013-03-04 22:19 ` [Qemu-devel] [PATCH 3/3] qga: implement qmp_guest_set_vcpus() " Laszlo Ersek
2013-03-05 20:09 ` mdroth
2013-03-05 21:09 ` Laszlo Ersek
2013-03-05 21:19 ` Eric Blake
2013-03-05 23:23 ` Laszlo Ersek
2013-03-05 23:37 ` Eric Blake
2013-03-06 0:44 ` Laszlo Ersek
2013-03-06 9:57 ` Paolo Bonzini
2013-03-06 13:46 ` Eric Blake
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=51365E2C.8080402@redhat.com \
--to=lersek@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).