From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
"Wei Liu" <wei.liu2@citrix.com>,
"Jan Beulich" <JBeulich@suse.com>,
"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [PATCH 2/3] x86/sysctl: Clean up XEN_SYSCTL_cpu_hotplug
Date: Tue, 2 Apr 2019 20:57:27 +0100 [thread overview]
Message-ID: <1554235048-3373-3-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1554235048-3373-1-git-send-email-andrew.cooper3@citrix.com>
A future change is going to introduce two more cases. Instead of opcoding the
XSM checks and contine_hypercall logic, collect the data into local variables.
Switch the default return value to -EOPNOTSUPP to distinguish a bad op from a
bad cpu index.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
---
xen/arch/x86/sysctl.c | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c
index 1916a3d..b3cc4b5 100644
--- a/xen/arch/x86/sysctl.c
+++ b/xen/arch/x86/sysctl.c
@@ -137,27 +137,35 @@ long arch_do_sysctl(
case XEN_SYSCTL_cpu_hotplug:
{
unsigned int cpu = sysctl->u.cpu_hotplug.cpu;
+ bool plug;
+ long (*fn)(void *) = NULL;
+ void *hcpu = NULL;
switch ( sysctl->u.cpu_hotplug.op )
{
case XEN_SYSCTL_CPU_HOTPLUG_ONLINE:
- ret = xsm_resource_plug_core(XSM_HOOK);
- if ( ret )
- break;
- ret = continue_hypercall_on_cpu(
- 0, cpu_up_helper, (void *)(unsigned long)cpu);
+ plug = true;
+ fn = cpu_up_helper;
+ hcpu = (void *)(unsigned long)cpu;
break;
+
case XEN_SYSCTL_CPU_HOTPLUG_OFFLINE:
- ret = xsm_resource_unplug_core(XSM_HOOK);
- if ( ret )
- break;
- ret = continue_hypercall_on_cpu(
- 0, cpu_down_helper, (void *)(unsigned long)cpu);
+ plug = false;
+ fn = cpu_down_helper;
+ hcpu = (void *)(unsigned long)cpu;
break;
+
default:
- ret = -EINVAL;
+ ret = -EOPNOTSUPP;
break;
}
+
+ if ( !ret )
+ ret = plug ? xsm_resource_plug_core(XSM_HOOK)
+ : xsm_resource_unplug_core(XSM_HOOK);
+
+ if ( !ret )
+ ret = continue_hypercall_on_cpu(0, fn, hcpu);
}
break;
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2019-04-02 19:57 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-02 19:57 [PATCH 0/3] x86/smt: Runtime SMT controls Andrew Cooper
2019-04-02 19:57 ` [PATCH 1/3] xen/cpu: Distinguish "cpu already in that state" in cpu_{up, down}() Andrew Cooper
2019-04-03 8:49 ` Jan Beulich
2019-04-02 19:57 ` Andrew Cooper [this message]
2019-04-03 8:53 ` [PATCH 2/3] x86/sysctl: Clean up XEN_SYSCTL_cpu_hotplug Jan Beulich
2019-04-03 9:06 ` Andrew Cooper
2019-04-03 9:38 ` Jan Beulich
2019-04-04 13:31 ` Andrew Cooper
2019-04-02 19:57 ` [PATCH 3/3] x86/smt: Support for enabling/disabling SMT at runtime Andrew Cooper
2019-04-03 9:33 ` Jan Beulich
2019-04-03 10:17 ` Andrew Cooper
2019-04-03 10:44 ` Jan Beulich
2019-04-03 11:33 ` Andrew Cooper
2019-04-03 12:10 ` Jan Beulich
2019-04-11 8:16 ` Jan Beulich
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=1554235048-3373-3-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=roger.pau@citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.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).