adjust error return values for cpupool operations
cover adjust error return values for cpupool operations
Some cpupool operations return the same error value for multiple situations. This makes it hard for the tools to react accordingly e.g. by issuing a suitable error message.
Return appropriate error values and document them.
Juergen Gross (3):
xen: return different error values for cpupool operations
libxc: adjust retry loop in xc_cpupool_removecpu()
xen: Document XEN_SYSCTL_CPUPOOL_OP_* error codes
tools/libxc/xc_cpupool.c | 6 ++---- xen/common/cpupool.c | 10 +++++----- xen/common/schedule.c | 2 +- xen/include/public/sysctl.h | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 10 deletions(-)
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH 1/3 xen: return different error values for cpupool operations
Today there are several different situations in which moving a cpu from or to a cpupool will return -EBUSY. This makes it hard for the user to know what he did wrong, as the Xen tools are not capable to print a detailed error message.
Depending on the situation return different error codes in order to enable the tools to print useful messages.
--- xen/common/cpupool.c | 10 +++++----- xen/common/schedule.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-)
xen/common/cpupool.c +5 -5
@@ -264,7 +264,7 @@ static int cpupool_assign_cpu_locked(struct cpupool *c, unsigned int cpu)struct domain *d;if ( (cpupool_moving_cpu == cpu) && (c != cpupool_cpu_moving) ) -return -EBUSY ; +return -EADDRNOTAVAIL ; ret =schedule_cpu_switch (cpu, c);if ( ret )return ret;
@@ -301,7 +301,7 @@ static long cpupool_unassign_cpu_helper(void *info)spin_lock (&cpupool_lock);if ( c != cpupool_cpu_moving ) { - ret = -EBUSY ; + ret = -EADDRNOTAVAIL ; goto out; }
@@ -366,7 +366,7 @@ static int cpupool_unassign_cpu(struct cpupool *c, unsigned int cpu) c->cpupool_id, cpu);spin_lock (&cpupool_lock); - ret = -EBUSY ; + ret = -EADDRNOTAVAIL ;if ( (cpupool_moving_cpu !=-1 ) && (cpu != cpupool_moving_cpu) ) goto out;if (cpumask_test_cpu (cpu, &cpupool_locked_cpus) )
@@ -537,7 +537,7 @@ static int cpupool_cpu_add(unsigned int cpu)*/ static int cpupool_cpu_remove (unsigned int cpu) { -int ret = -EBUSY ; +int ret = -ENODEV ;spin_lock (&cpupool_lock);if ( system_state == SYS_STATE_suspend )
@@ -647,7 +647,7 @@ int cpupool_do_sysctl(struct xen_sysctl_cpupool_op *op) ret = -EINVAL ;if ( cpu >= nr_cpu_ids ) goto addcpu_out; - ret = -EBUSY ; + ret = -ENODEV ;if ( !cpumask_test_cpu (cpu, &cpupool_free_cpus) ) goto addcpu_out; c =cpupool_find_by_id (op->cpupool_id);
xen/common/schedule.c +1 -1
@@ -688,7 +688,7 @@ int cpu_disable_scheduler(unsigned int cpu) {/* The vcpu is temporarily pinned, can't move it. */ vcpu_schedule_unlock_irqrestore (lock, flags, v); - ret = -EBUSY ; + ret = -EADDRINUSE ;break ; }
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH 1/3] xen: return different error values for cpupool operations
Juergen Gross writes ("[PATCH 1/3] xen: return different error values for cpupool operations"):
Quoted 7 lines
Today there are several different situations in which moving a cpu from or to a cpupool will return
-EBUSY. This makes it hard for the user to know what he did wrong, as the Xen tools are not capable to print a detailed error message.Depending on the situation return different error codes in order to enable the tools to print useful messages.
For what it's worth
although I have no real ability to review this code for correctness.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Dario Faggioli
Acked-byRe: [PATCH 1/3] xen: return different error values for cpupool operations
Quoted 8 lines · Ian Jackson
Juergen Gross writes ("[PATCH 1/3] xen: return different error values for cpupool operations"):
Quoted 6 lines
Today there are several different situations in which moving a cpu from or to a cpupool will return
-EBUSY. This makes it hard for the user to know what he did wrong, as the Xen tools are not capable to print a detailed error message.
Quoted 6 lines
Quoted 2 lines
Depending on the situation return different error codes in order to enable the tools to print useful messages.
For what it's worth
Acked-by Ian Jackson <[email protected]>
Regards,
Dario
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 1/3] xen: return different error values for cpupool operations
In reply to Juergen GrossQuoted 11 lines
Quoted 1 line
Quoted 1 line
Juergen Gross <[email protected]> 04/15/16 4:54 PM >>>
Today there are several different situations in which moving a cpu from or to a cpupool will return
-EBUSY. This makes it hard for the user to know what he did wrong, as the Xen tools are not capable to print a detailed error message.Depending on the situation return different error codes in order to enable the tools to print useful messages.
Requested-by Ian Jackson <[email protected]>Signed-off-by Juergen Gross <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH 2/3 libxc: adjust retry loop in xc_cpupool_removecpu()
In reply to Juergen GrossCommit 1ef6beea187b ("libxc: do some retries in xc_cpupool_removecpu() for EBUSY case") added a retry loop in xc_cpupool_removecpu() for the EBUSY case. As EBUSY was returned in multiple error situations the loop would have been executed in situations where a retry would not be successful. Additionally calling sleep(1) between the rerires is a bad idea when being called in a daemon.
The hypervisor has been changed to return different error values now. The retry added in above mentioned commit should be done in the EADDRINUSE case now. As the error condition should last only for a very short time, the sleep(1) call can be removed.
--- tools/libxc/xc_cpupool.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
tools/libxc/xc_cpupool.c +2 -4
@@ -139,7 +139,7 @@ int xc_cpupool_addcpu(xc_interface *xch, }/* -* The hypervisor might return EBUSY when trying to remove a cpu from a +* The hypervisor might return EADDRINUSE when trying to remove a cpu from a * cpupool when a domain running in this cpupool has pinned a vcpu * temporarily. Do some retries in this case, perhaps the situation * cleans up.
@@ -160,9 +160,7 @@ int xc_cpupool_removecpu(xc_interface *xch, sysctl.u.cpupool_op.cpu = (cpu <0 ) ?XEN_SYSCTL_CPUPOOL_PAR_ANY : cpu;for ( retries =0 ; retries <NUM_RMCPU_BUSY_RETRIES ; retries++ ) { err =do_sysctl_save (xch, &sysctl); -if ( err <0 && errno ==EBUSY ) -sleep (1 ); -else +if ( err ==0 || errno !=EADDRINUSE )break ; }return err;
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH 2/3] libxc: adjust retry loop in xc_cpupool_removecpu()
Juergen Gross writes ("[PATCH 2/3] libxc: adjust retry loop in xc_cpupool_removecpu()"):
Quoted 7 lines
Commit
1ef6beea187b("libxc: do some retries inxc_cpupool_removecpu()for EBUSY case") added a retry loop inxc_cpupool_removecpu()for the EBUSY case. As EBUSY was returned in multiple error situations the loop would have been executed in situations where a retry would not be successful. Additionally calling sleep(1) between the rerires is a bad idea when being called in a daemon.
Quoted 7 lines
The hypervisor has been changed to return different error values now. The retry added in above mentioned commit should be done in the EADDRINUSE case now. As the error condition should last only for a very short time, the sleep(1) call can be removed.
Requested-by Ian Jackson <[email protected]>Signed-off-by Juergen Gross <[email protected]>
Thanks.
I will follow up with further patches to improve the behaviour of xl.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Dario Faggioli
Reviewed-byRe: [PATCH 2/3] libxc: adjust retry loop in xc_cpupool_removecpu()
Quoted 19 lines · Ian Jackson
Juergen Gross writes ("[PATCH 2/3] libxc: adjust retry loop in
xc_cpupool_removecpu()"):Quoted 17 lines
Commit
1ef6beea187b("libxc: do some retries inxc_cpupool_removecpu()
for EBUSY case") added a retry loop inxc_cpupool_removecpu()for the
EBUSY case. As EBUSY was returned in multiple error situations the loop would have been executed in situations where a retry would not be successful. Additionally calling sleep(1) between the rerires is a
bad idea when being called in a daemon.The hypervisor has been changed to return different error values now.
The retry added in above mentioned commit should be done in the EADDRINUSE case now. As the error condition should last only for a very short time, the sleep(1) call can be removed.
Quoted 6 lines
Quoted 2 lines
Requested-by Ian Jackson <[email protected]>Signed-off-by Juergen Gross <[email protected]>Thanks.
Acked-by Ian Jackson <[email protected]>
Regards,
Dario
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 2/3] libxc: adjust retry loop in xc_cpupool_removecpu()
In reply to Juergen GrossQuoted 9 lines · Juergen Gross
Subject: [Xen-devel] [PATCH 2/3] libxc: adjust retry loop in
xc_cpupool_removecpu()
List-Id: Xen developer discussion <xen-devel.lists.xen.org>Commit
1ef6beea187b("libxc: do some retries inxc_cpupool_removecpu()for EBUSY case") added a retry loop inxc_cpupool_removecpu()for the EBUSY case. As EBUSY was returned in multiple error situations the loop would have been executed in situations where a retry would not be successful. Additionally calling sleep(1) between the rerires is a
s/rerires/retries/
Alan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Wei Liu writes ("Re: [PATCH 0/3] adjust error return values for cpupool operations"):
Quoted 6 lines
In principle I agree we need better semantics and documentation of this hypercall, and because this is new code so it's risk free, so:
Release-acked-by Wei Liu <[email protected]>I will leave this series for Ian to review.
Thanks for all the reviews and acks. I have queued these three patches.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH 3/3 xen: Document XEN_SYSCTL_CPUPOOL_OP_* error codes
In reply to Juergen Gross--- xen/include/public/sysctl.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
xen/include/public/sysctl.h +36 -0
@@ -559,6 +559,42 @@ struct xen_sysctl_cpupool_op {typedef struct xen_sysctl_cpupool_op xen_sysctl_cpupool_op_t ;DEFINE_XEN_GUEST_HANDLE (xen_sysctl_cpupool_op_t); +/* +* Error return values of cpupool operations: +* +* -EADDRINUSE: +* XEN_SYSCTL_CPUPOOL_OP_RMCPU: A vcpu is temporarily pinned to the cpu +* which is to be removed from a cpupool. +* -EADDRNOTAVAIL: +* XEN_SYSCTL_CPUPOOL_OP_ADDCPU, XEN_SYSCTL_CPUPOOL_OP_RMCPU: A previous +* request to remove a cpu from a cpupool was terminated with -EAGAIN +* and has not been retried using the same parameters. +* -EAGAIN: +* XEN_SYSCTL_CPUPOOL_OP_RMCPU: The cpu can't be removed from the cpupool +* as it is active in the hypervisor. A retry will succeed soon. +* -EBUSY: +* XEN_SYSCTL_CPUPOOL_OP_DESTROY, XEN_SYSCTL_CPUPOOL_OP_RMCPU: A cpupool +* can't be destroyed or the last cpu can't be removed as there is still +* a running domain in that cpupool. +* -EEXIST: +* XEN_SYSCTL_CPUPOOL_OP_CREATE: A cpupool_id was specified and is already +* existing. +* -EINVAL: +* XEN_SYSCTL_CPUPOOL_OP_ADDCPU, XEN_SYSCTL_CPUPOOL_OP_RMCPU: An illegal +* cpu was specified (cpu does not exist). +* XEN_SYSCTL_CPUPOOL_OP_MOVEDOMAIN: An illegal domain was specified +* (domain id illegal or not suitable for operation). +* -ENODEV: +* XEN_SYSCTL_CPUPOOL_OP_ADDCPU, XEN_SYSCTL_CPUPOOL_OP_RMCPU: The specified +* cpu is either not free (add) or not member of the specified cpupool +* (remove). +* -ENOENT: +* all: The cpupool with the specified cpupool_id doesn't exist. +* +* Some common error return values like -ENOMEM and -EFAULT are possible for +* all the operations. +*/ +#define ARINC653_MAX_DOMAINS_PER_SCHEDULE 64/* * This structure is used to pass a new ARINC653 schedule from a
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH 3/3] xen: Document XEN_SYSCTL_CPUPOOL_OP_* error codes
Juergen Gross writes ("[PATCH 3/3] xen: Document XEN_SYSCTL_CPUPOOL_OP_* error codes"):
Quoted 2 lines
Requested-by Ian Jackson <[email protected]>Signed-off-by Juergen Gross <[email protected]>
Thanks this is very helpful. I think it should go in as soon as the actual hypervisor code side has the appropriate ack.
But I have some suggestions for enhancement:
Quoted 6 lines
+/*
+ * Error return values of cpupool operations:
+ *
+ *-EADDRINUSE:
+ *XEN_SYSCTL_CPUPOOL_OP_RMCPU: A vcpu is temporarily pinned to the cpu
+ * which is to be removed from a cpupool.
I think this ought to mention the anomalous state the pcpu is left in, and advise what should be done about it. I think it would be helpful to crib from my earlier xxx-ful text. How about:
In this case RMCPU may have been partially carried out and the pcpu is left in an anomalous state. In this state the pcpu may be used by some not readily predictable subset of the vcpus (domains) whose vcpus are in the old cpupool.
Quoted 2 lines
The anomalous situation can be recovered by adding the pcpu back to the cpupool it came from, and then retrying the RMCPU.
But I notice that the code you propose for libxc doesn't do the
re-add: it just retries the remove. So either the text above (which you and Dario seemed to agree with) is wrong, or the libxc code is wrong.
And, perhaps we ought to mention here that this temporary pinning can only be done by the hardware domain ? Or at least refer to the temporary pin operation.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 3/3] xen: Document XEN_SYSCTL_CPUPOOL_OP_* error codes
Quoted 27 lines · Ian Jackson
Juergen Gross writes ("[PATCH 3/3] xen: Document XEN_SYSCTL_CPUPOOL_OP_* error codes"):
Quoted 2 lines
Requested-by Ian Jackson <[email protected]>Signed-off-by Juergen Gross <[email protected]>Acked-by Ian Jackson <[email protected]>Thanks this is very helpful. I think it should go in as soon as the actual hypervisor code side has the appropriate ack.
But I have some suggestions for enhancement:
Quoted 6 lines
+/*
+ * Error return values of cpupool operations:
+ *
+ *-EADDRINUSE:
+ *XEN_SYSCTL_CPUPOOL_OP_RMCPU: A vcpu is temporarily pinned to the cpu
+ * which is to be removed from a cpupool.I think this ought to mention the anomalous state the pcpu is left in, and advise what should be done about it. I think it would be helpful to crib from my earlier xxx-ful text. How about:
In this case RMCPU may have been partially carried out and the pcpu is left in an anomalous state. In this state the pcpu may be used by some not readily predictable subset of the vcpus (domains) whose vcpus are in the old cpupool.
Quoted 7 lines
Quoted 2 lines
The anomalous situation can be recovered by adding the pcpu back to the cpupool it came from, and then retrying the RMCPU.
But I notice that the code you propose for libxc doesn't do the
re-add: it just retries the remove. So either the text above (which you and Dario seemed to agree with) is wrong, or the libxc code is wrong.
Re-adding it not necessary. A retry is all that is needed. In case retries don't succeed for a long time either re-adding the cpu to it's original pool or doing a "xl vcpu-pin -f ..." and a retry should clean up the situation.
Quoted 3 lines
And, perhaps we ought to mention here that this temporary pinning can only be done by the hardware domain ? Or at least refer to the temporary pin operation.
Yes, together with the vcpu-pin -f hint.
I think this can wait until next week.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 11 lines · Juergen Gross
Some cpupool operations return the same error value for multiple situations. This makes it hard for the tools to react accordingly e.g. by issuing a suitable error message.
Return appropriate error values and document them.
Juergen Gross (3):
xen: return different error values for cpupool operations
libxc: adjust retry loop inxc_cpupool_removecpu()
xen: Document XEN_SYSCTL_CPUPOOL_OP_* error codes
Quoted 6 lines
tools/libxc/xc_cpupool.c | 6 ++---- xen/common/cpupool.c | 10 +++++----- xen/common/schedule.c | 2 +- xen/include/public/sysctl.h | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 10 deletions(-)
In principle I agree we need better semantics and documentation of this hypercall, and because this is new code so it's risk free, so:
I will leave this series for Ian to review.
Quoted 3 lines
Signature · 1 line
2.6.6
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel