From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dario Faggioli Subject: Re: [PATCH RESEND 09/12] libxc: numa-sched: enable getting/specifying per-vcpu node-affinity Date: Wed, 13 Nov 2013 11:57:34 +0100 Message-ID: <1384340254.16918.39.camel@Solace> References: <20131105142844.30446.78671.stgit@Solace> <20131105143542.30446.5398.stgit@Solace> <20131112160144.GB11354@phenom.dumpdata.com> <1384281624.16918.26.camel@Solace> <20131112191310.GA12345@phenom.dumpdata.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2887540728894022837==" Return-path: In-Reply-To: <20131112191310.GA12345@phenom.dumpdata.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Konrad Rzeszutek Wilk Cc: Marcus Granado , Keir Fraser , Ian Campbell , Li Yechen , George Dunlap , Andrew Cooper , Juergen Gross , Ian Jackson , xen-devel@lists.xen.org, Jan Beulich , Justin Weaver , Daniel De Graaf , Matt Wilson , Elena Ufimtseva List-Id: xen-devel@lists.xenproject.org --===============2887540728894022837== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-M2MKWCHyiaECGOvWR7vR" --=-M2MKWCHyiaECGOvWR7vR Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On mar, 2013-11-12 at 14:13 -0500, Konrad Rzeszutek Wilk wrote: > On Tue, Nov 12, 2013 at 07:40:24PM +0100, Dario Faggioli wrote: > > > > +int xc_vcpu_getnodeaffinity(xc_interface *xch, > > > > + uint32_t domid, > > > > + int vcpu, > > > > + xc_nodemap_t nodemap) > > > > +{ > > > > + DECLARE_DOMCTL; > > > > + DECLARE_HYPERCALL_BUFFER(uint8_t, local); > > > > + int ret =3D -1; > > > > + int nodesize; > > > > + > > > > + nodesize =3D xc_get_nodemap_size(xch); > > > > + if (!nodesize) > > > > + { > > > > + PERROR("Could not get number of nodes"); > > > > + goto out; > > > > + } > > > > + > > > > + local =3D xc_hypercall_buffer_alloc(xch, local, nodesize); > > > > + if (local =3D=3D NULL) > > > > + { > > > > + PERROR("Could not allocate memory for getvcpunodeaffinity = domctl hypercall"); > > > > + goto out; > > > > + } > > > > + > > > > + domctl.cmd =3D XEN_DOMCTL_getvcpunodeaffinity; > > > > + domctl.domain =3D (domid_t)domid; > > > > + domctl.u.vcpuaffinity.vcpu =3D vcpu; > > > > + > > > > + set_xen_guest_handle(domctl.u.vcpuaffinity.map.bitmap, local); > > > > + domctl.u.vcpuaffinity.map.nr_bits =3D nodesize * 8; > > >=20 > > > Could the 8 be replaced by a sizeof? > > > > > I guess it could... What was it that you had in mind in particular? > >=20 > > Personally, I consider the names 'bitmap' and 'nr_bits' talking enough > > to feel comfortable with the 8... To the point that I think the > > following would be even less readable: > >=20 > > domctl.u.vcpuaffinity.map.nr_bits =3D nodesize *=20 > > sizeof(domctl.u.vcpuaffinity.cpumap.bitmap); >=20 > Eww. That is worst. Somehow I assumed you could just do 'sizeof(unsigned = long long)' > or such. or some #define for this magic number. > I did think more about this and (re)did the math. After that, I don't think there is much we can do to make it more clear than it already is with the 8, assuming that we all are cool with the fact that there are 8 bits in a byte, because that's what the 8 means there. In fact, both the passed xc_nodemap_t (nodemap, in this case) and the hypercall buffer (local) are allocated to be nodesize (i.e., the result of xc_get_nodemap_size()) _bytes_. Since what we want to store in nr_bits is the number of actual bit available in the resulting bitmap, given how large it is in bytes, there is nothing much else I can think of to get there than multiplying such number of byte by the number of bits in a byte. Therefore, either we find a suitable sizeof() for "nr_of_bits_in_a_byte", or I "#define BITS_PER_BYTE 8" (:-P), or we stick with the 8, which again I think it's the best option. Regards, Dario --=20 <> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK) --=-M2MKWCHyiaECGOvWR7vR Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.15 (GNU/Linux) iEYEABECAAYFAlKDWyAACgkQk4XaBE3IOsRK9QCgnrQWZieJsww+B1A5gza7RBhQ T3QAn1Fg3PqpKrBAOBeyv1zMFh2bsuxc =41TN -----END PGP SIGNATURE----- --=-M2MKWCHyiaECGOvWR7vR-- --===============2887540728894022837== 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 --===============2887540728894022837==--