From: "Jan Beulich" Subject: [PATCH] sysctl: adjust XEN_SYSCTL_numainfo behavior Date: Tue, 14 Jul 2015 10:52:16 +0100 Message-ID: <55A4F7F002000078000908B4@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part82B67EC0.1__=" Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZEwsu-0001p0-4n for xen-devel@lists.xenproject.org; Tue, 14 Jul 2015 09:52:20 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Ian Campbell , Keir Fraser , Boris Ostrovsky , Ian Jackson , Tim Deegan List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part82B67EC0.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline ... 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 --- a/xen/common/sysctl.c +++ b/xen/common/sysctl.c @@ -285,15 +285,9 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xe { xen_sysctl_meminfo_t meminfo =3D { 0 }; =20 - if ( ni->num_nodes < num_nodes ) - { - ret =3D -ENOBUFS; - i =3D num_nodes; - } - else - i =3D 0; - - for ( ; i < num_nodes; i++ ) + if ( num_nodes > ni->num_nodes ) + num_nodes =3D ni->num_nodes; + for ( i =3D 0; i < num_nodes; ++i ) { static uint32_t distance[MAX_NUMNODES]; =20 @@ -335,7 +329,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xe else i =3D num_nodes; =20 - if ( (!ret || (ret =3D=3D -ENOBUFS)) && (ni->num_nodes !=3D i) ) + if ( !ret && (ni->num_nodes !=3D i) ) { ni->num_nodes =3D i; if ( __copy_field_to_guest(u_sysctl, op, --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -515,10 +515,11 @@ DEFINE_XEN_GUEST_HANDLE(xen_sysctl_memin * 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. */ =20 struct xen_sysctl_numainfo { --=__Part82B67EC0.1__= Content-Type: text/plain; name="sysctl-numainfo-partial.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="sysctl-numainfo-partial.patch" sysctl: adjust XEN_SYSCTL_numainfo behavior=0A=0A... to match XEN_SYSCTL_cp= utopoinfo, allowing the caller to get what it=0Aneeds (if e.g. it's after = the data for just one specific node) with=0Ajust one hypercall, without = caring about the total number of nodes in=0Athe system.=0A=0ASuggested-by: = Boris Ostrovsky =0ASigned-off-by: Jan Beulich = =0A=0A--- a/xen/common/sysctl.c=0A+++ b/xen/common/sysct= l.c=0A@@ -285,15 +285,9 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xe=0A = {=0A xen_sysctl_meminfo_t meminfo =3D { 0 };=0A =0A- = if ( ni->num_nodes < num_nodes )=0A- {=0A- = ret =3D -ENOBUFS;=0A- i =3D num_nodes;=0A- }=0A- = else=0A- i =3D 0;=0A-=0A- for ( ; i < = num_nodes; i++ )=0A+ if ( num_nodes > ni->num_nodes )=0A+ = num_nodes =3D ni->num_nodes;=0A+ for ( i =3D 0; i < = num_nodes; ++i )=0A {=0A static uint32_t = distance[MAX_NUMNODES];=0A =0A@@ -335,7 +329,7 @@ long do_sysctl(XEN_GUEST_= HANDLE_PARAM(xe=0A else=0A i =3D num_nodes;=0A =0A- = if ( (!ret || (ret =3D=3D -ENOBUFS)) && (ni->num_nodes !=3D i) )=0A+ = if ( !ret && (ni->num_nodes !=3D i) )=0A {=0A = ni->num_nodes =3D i;=0A if ( __copy_field_to_guest(u_sysctl, = op,=0A--- a/xen/include/public/sysctl.h=0A+++ b/xen/include/public/sysctl.h= =0A@@ -515,10 +515,11 @@ DEFINE_XEN_GUEST_HANDLE(xen_sysctl_memin=0A * = non-null)=0A *=0A * OUT:=0A- * - If 'num_nodes' is less than the number = Xen needs to write, -ENOBUFS shall=0A- * be returned and 'num_nodes' = updated to reflect the intended number.=0A- * - On success, 'num_nodes' = shall indicate the number of entries written, which=0A- * may be less = than the maximum.=0A+ * - If 'num_nodes' is less than the number Xen = wants to write but either=0A+ * handle is not a NULL one, partial data = gets returned and 'num_nodes'=0A+ * gets updated to reflect the = intended number.=0A+ * - Otherwise, 'num_nodes' shall indicate the number = of entries written, which=0A+ * may be less than the input value.=0A = */=0A =0A struct xen_sysctl_numainfo {=0A --=__Part82B67EC0.1__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part82B67EC0.1__=--