From: Jan Beulich Date: Wed, 15 Jul 2015 16:05:02 +0000 (+0200) Subject: sysctl: adjust XEN_SYSCTL_numainfo behavior X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~2772 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=e196ac7ab3f8fc690e9c91a6116136d33f41fee0;p=xen.git sysctl: adjust XEN_SYSCTL_numainfo behavior ... to match XEN_SYSCTL_cputopoinfo, allowing the caller to get what it needs (if e.g. it's after the data for just one specific node) with just one hypercall, without caring about the total number of nodes in the system. Suggested-by: Boris Ostrovsky Signed-off-by: Jan Beulich Reviewed-by: Dario Faggioli Acked-by: Ian Campbell --- diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c index 5f9af2b294..f1c0c76e79 100644 --- a/xen/common/sysctl.c +++ b/xen/common/sysctl.c @@ -285,15 +285,9 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) { xen_sysctl_meminfo_t meminfo = { 0 }; - if ( ni->num_nodes < num_nodes ) - { - ret = -ENOBUFS; - i = num_nodes; - } - else - i = 0; - - for ( ; i < num_nodes; i++ ) + if ( num_nodes > ni->num_nodes ) + num_nodes = ni->num_nodes; + for ( i = 0; i < num_nodes; ++i ) { static uint32_t distance[MAX_NUMNODES]; @@ -335,7 +329,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) else i = num_nodes; - if ( (!ret || (ret == -ENOBUFS)) && (ni->num_nodes != i) ) + if ( !ret && (ni->num_nodes != i) ) { ni->num_nodes = i; if ( __copy_field_to_guest(u_sysctl, op, diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index 86de43807a..58c9be254b 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -515,10 +515,11 @@ DEFINE_XEN_GUEST_HANDLE(xen_sysctl_meminfo_t); * non-null) * * OUT: - * - If 'num_nodes' is less than the number Xen needs to write, -ENOBUFS shall - * be returned and 'num_nodes' updated to reflect the intended number. - * - On success, 'num_nodes' shall indicate the number of entries written, which - * may be less than the maximum. + * - If 'num_nodes' is less than the number Xen wants to write but either + * handle is not a NULL one, partial data gets returned and 'num_nodes' + * gets updated to reflect the intended number. + * - Otherwise, 'num_nodes' shall indicate the number of entries written, which + * may be less than the input value. */ struct xen_sysctl_numainfo {