From: "Jan Beulich" Subject: [PATCH] sysctl: adjust XEN_SYSCTL_cputopoinfo behavior Date: Mon, 13 Jul 2015 16:53:21 +0100 Message-ID: <55A3FB110200007800090488@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartA1955AE1.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 1ZEg2o-0005wg-02 for xen-devel@lists.xenproject.org; Mon, 13 Jul 2015 15:53:26 +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 , 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. --=__PartA1955AE1.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline The new function's implementation, other than the original one of XEN_SYSCTL_topologyinfo, didn't allow the caller to get what it needs (if e.g. it's after the data for just one specific CPU) with just one hypercall, without caring about the total number of CPUs in the system. Signed-off-by: Jan Beulich --- a/xen/common/sysctl.c +++ b/xen/common/sysctl.c @@ -358,15 +358,9 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xe { xen_sysctl_cputopo_t cputopo =3D { 0 }; =20 - if ( ti->num_cpus < num_cpus ) - { - ret =3D -ENOBUFS; - i =3D num_cpus; - } - else - i =3D 0; - - for ( ; i < num_cpus; i++ ) + if ( num_cpus > ti->num_cpus ) + num_cpus =3D ti->num_cpus; + for ( i =3D 0; i < num_cpus; ++i ) { if ( cpu_present(i) ) { @@ -393,7 +387,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xe else i =3D num_cpus; =20 - if ( (!ret || (ret =3D=3D -ENOBUFS)) && (ti->num_cpus !=3D i) ) + if ( !ret && (ti->num_cpus !=3D i) ) { ti->num_cpus =3D i; if ( __copy_field_to_guest(u_sysctl, op, --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -482,10 +482,11 @@ DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cputo * - otherwise it's the number of entries in 'cputopo' * * OUT: - * - If 'num_cpus' is less than the number Xen needs to write, -ENOBUFS = shall - * be returned and 'num_cpus' updated to reflect the intended number. - * - On success, 'num_cpus' shall indicate the number of entries = written, which - * may be less than the maximum. + * - If 'num_cpus' is less than the number Xen wants to write but the = handle + * handle is not a NULL one, partial data gets returned and 'num_cpus' = gets + * updated to reflect the intended number. + * - Otherwise, 'num_cpus' shall indicate the number of entries written, = which + * may be less than the input value. */ struct xen_sysctl_cputopoinfo { uint32_t num_cpus; --=__PartA1955AE1.1__= Content-Type: text/plain; name="sysctl-cputopoinfo-partial.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="sysctl-cputopoinfo-partial.patch" sysctl: adjust XEN_SYSCTL_cputopoinfo behavior=0A=0AThe new function's = implementation, other than the original one of=0AXEN_SYSCTL_topologyinfo, = didn't allow the caller to get what it needs=0A(if e.g. it's after the = data for just one specific CPU) with just one=0Ahypercall, without caring = about the total number of CPUs in the system.=0A=0ASigned-off-by: Jan = Beulich =0A=0A--- a/xen/common/sysctl.c=0A+++ b/xen/comm= on/sysctl.c=0A@@ -358,15 +358,9 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xe= =0A {=0A xen_sysctl_cputopo_t cputopo =3D { 0 };=0A = =0A- if ( ti->num_cpus < num_cpus )=0A- {=0A- = ret =3D -ENOBUFS;=0A- i =3D num_cpus;=0A- = }=0A- else=0A- i =3D 0;=0A-=0A- for = ( ; i < num_cpus; i++ )=0A+ if ( num_cpus > ti->num_cpus )=0A+ = num_cpus =3D ti->num_cpus;=0A+ for ( i =3D 0; i < = num_cpus; ++i )=0A {=0A if ( cpu_present(i) = )=0A {=0A@@ -393,7 +387,7 @@ long do_sysctl(XEN_GUEST_HANDL= E_PARAM(xe=0A else=0A i =3D num_cpus;=0A =0A- = if ( (!ret || (ret =3D=3D -ENOBUFS)) && (ti->num_cpus !=3D i) )=0A+ = if ( !ret && (ti->num_cpus !=3D i) )=0A {=0A ti->num_cp= us =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@@ = -482,10 +482,11 @@ DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cputo=0A * - = otherwise it's the number of entries in 'cputopo'=0A *=0A * OUT:=0A- * = - If 'num_cpus' is less than the number Xen needs to write, -ENOBUFS = shall=0A- * be returned and 'num_cpus' updated to reflect the intended = number.=0A- * - On success, 'num_cpus' shall indicate the number of = entries written, which=0A- * may be less than the maximum.=0A+ * - If = 'num_cpus' is less than the number Xen wants to write but the handle=0A+ * = handle is not a NULL one, partial data gets returned and 'num_cpus' = gets=0A+ * updated to reflect the intended number.=0A+ * - Otherwise, = 'num_cpus' shall indicate the number of entries written, which=0A+ * = may be less than the input value.=0A */=0A struct xen_sysctl_cputopoinfo = {=0A uint32_t num_cpus;=0A --=__PartA1955AE1.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 --=__PartA1955AE1.1__=--