Files
xen/tools/libxc/xc_cpu_hotplug.c
T
Andrew Cooper 2bed1bc241 x86/smt: Support for enabling/disabling SMT at runtime
Currently, a user can in principle combine the output of `xl info -n`, the
APCI tables, and some manual CPUID data to figure out which CPU numbers to
feed into `xen-hptool cpu-offline` to effectively disable SMT at runtime.

A more convenient option is to teach Xen how to perform this action.

Extend XEN_SYSCTL_cpu_hotplug with two new operations.  Introduce a new
smt_up_down_helper() which wraps the cpu_{up,down}_helper() helpers with logic
which understands siblings based on their APIC_ID.

Add libxc stubs, and extend xen-hptool with smt-{enable,disable} options.
These are intended to be shorthands for a loop over cpu-{online,offline}.

To simplify the implemention, they will strictly enable/disable secondary
siblings (those with a non-zero thread id).  This functionality is intended
for use in production scenarios where debugging options such as `maxcpus=` or
other manual plug/unplug configuration has not been used.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
2019-04-09 19:34:41 +01:00

75 lines
1.9 KiB
C

/******************************************************************************
* xc_cpu_hotplug.c - Libxc API for Xen Physical CPU hotplug Management
*
* Copyright (c) 2008, Shan Haitao <haitao.shan@intel.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "xc_private.h"
int xc_cpu_online(xc_interface *xch, int cpu)
{
DECLARE_SYSCTL;
int ret;
sysctl.cmd = XEN_SYSCTL_cpu_hotplug;
sysctl.u.cpu_hotplug.cpu = cpu;
sysctl.u.cpu_hotplug.op = XEN_SYSCTL_CPU_HOTPLUG_ONLINE;
ret = xc_sysctl(xch, &sysctl);
return ret;
}
int xc_cpu_offline(xc_interface *xch, int cpu)
{
DECLARE_SYSCTL;
int ret;
sysctl.cmd = XEN_SYSCTL_cpu_hotplug;
sysctl.u.cpu_hotplug.cpu = cpu;
sysctl.u.cpu_hotplug.op = XEN_SYSCTL_CPU_HOTPLUG_OFFLINE;
ret = xc_sysctl(xch, &sysctl);
return ret;
}
int xc_smt_enable(xc_interface *xch)
{
DECLARE_SYSCTL;
int ret;
sysctl.cmd = XEN_SYSCTL_cpu_hotplug;
sysctl.u.cpu_hotplug.cpu = 0;
sysctl.u.cpu_hotplug.op = XEN_SYSCTL_CPU_HOTPLUG_SMT_ENABLE;
ret = xc_sysctl(xch, &sysctl);
return ret;
}
int xc_smt_disable(xc_interface *xch)
{
DECLARE_SYSCTL;
int ret;
sysctl.cmd = XEN_SYSCTL_cpu_hotplug;
sysctl.u.cpu_hotplug.cpu = 0;
sysctl.u.cpu_hotplug.op = XEN_SYSCTL_CPU_HOTPLUG_SMT_DISABLE;
ret = xc_sysctl(xch, &sysctl);
return ret;
}