1 /******************************************************************************
2  * xc_cpu_hotplug.c - Libxc API for Xen Physical CPU hotplug Management
3  *
4  * Copyright (c) 2008, Shan Haitao <haitao.shan@intel.com>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation;
9  * version 2.1 of the License.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 #include "xc_private.h"
22 
xc_cpu_online(xc_interface * xch,int cpu)23 int xc_cpu_online(xc_interface *xch, int cpu)
24 {
25     DECLARE_SYSCTL;
26     int ret;
27 
28     sysctl.cmd = XEN_SYSCTL_cpu_hotplug;
29     sysctl.u.cpu_hotplug.cpu = cpu;
30     sysctl.u.cpu_hotplug.op = XEN_SYSCTL_CPU_HOTPLUG_ONLINE;
31     ret = xc_sysctl(xch, &sysctl);
32 
33     return ret;
34 }
35 
xc_cpu_offline(xc_interface * xch,int cpu)36 int xc_cpu_offline(xc_interface *xch, int cpu)
37 {
38     DECLARE_SYSCTL;
39     int ret;
40 
41     sysctl.cmd = XEN_SYSCTL_cpu_hotplug;
42     sysctl.u.cpu_hotplug.cpu = cpu;
43     sysctl.u.cpu_hotplug.op = XEN_SYSCTL_CPU_HOTPLUG_OFFLINE;
44     ret = xc_sysctl(xch, &sysctl);
45 
46     return ret;
47 }
48 
xc_smt_enable(xc_interface * xch)49 int xc_smt_enable(xc_interface *xch)
50 {
51     DECLARE_SYSCTL;
52     int ret;
53 
54     sysctl.cmd = XEN_SYSCTL_cpu_hotplug;
55     sysctl.u.cpu_hotplug.cpu = 0;
56     sysctl.u.cpu_hotplug.op = XEN_SYSCTL_CPU_HOTPLUG_SMT_ENABLE;
57     ret = xc_sysctl(xch, &sysctl);
58 
59     return ret;
60 }
61 
xc_smt_disable(xc_interface * xch)62 int xc_smt_disable(xc_interface *xch)
63 {
64     DECLARE_SYSCTL;
65     int ret;
66 
67     sysctl.cmd = XEN_SYSCTL_cpu_hotplug;
68     sysctl.u.cpu_hotplug.cpu = 0;
69     sysctl.u.cpu_hotplug.op = XEN_SYSCTL_CPU_HOTPLUG_SMT_DISABLE;
70     ret = xc_sysctl(xch, &sysctl);
71 
72     return ret;
73 }
74 
75