From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dario Faggioli Subject: Re: [PATCH v1][RFC] xen balloon driver numa support, libxl interface Date: Mon, 12 Aug 2013 19:07:17 +0200 Message-ID: <1376327237.15390.225.camel@Solace> References: <1376313528-16530-1-git-send-email-lccycc123@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0996621075266862486==" Return-path: In-Reply-To: <1376313528-16530-1-git-send-email-lccycc123@gmail.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: Yechen Li Cc: Ian Campbell , Ian Jackson , Elena Ufimtseva , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org --===============0996621075266862486== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-Ciombx19XGdur2XBGVDF" --=-Ciombx19XGdur2XBGVDF Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable [Adding potentially interested people in Cc: the Ian-s are the toolstack maintainers, Elena is there because her work on PV-NUMA is somewhat related, Konrad is there because of the Linux implications of this] On lun, 2013-08-12 at 21:18 +0800, Yechen Li wrote: > --- >=20 > This small patch implements a numa support of memory operation for libx= l > The command is: xl mem-set-numa [-e] vmid memorysize nodeid > To pass the parameters to balloon driver in kernel, I add a file of xen= -store > as /local/domain/(id)/memory/target_nid, hoping this is ok.... >=20 > It's my first time submitting a patch, please point out the problems so= that > I could work better in future, thanks very much! >=20 > tools/libxl/libxl.c | 14 ++++++++++++-- > tools/libxl/libxl.h | 1 + > tools/libxl/xl.h | 1 + > tools/libxl/xl_cmdimpl.c | 45 +++++++++++++++++++++++++++++++++++++++++= ++++ > tools/libxl/xl_cmdtable.c | 7 +++++++ > 5 files changed, 66 insertions(+), 2 deletions(-) >=20 > diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c > index 81785df..f027d59 100644 > --- a/tools/libxl/libxl.c > +++ b/tools/libxl/libxl.c > @@ -3642,10 +3642,17 @@ retry: > } > return 0; > } > - > int libxl_set_memory_target(libxl_ctx *ctx, uint32_t domid, > int32_t target_memkb, int relative, int enforce) > { > + return libxl_set_memory_target_numa(ctx, domid, target_memkb, relati= ve, > + enforce, -1, 0); > +} > + > +int libxl_set_memory_target_numa(libxl_ctx *ctx, uint32_t domid, > + int32_t target_memkb, int relative, int enforce, > + int node_specify, bool nodeexact) > +{ > GC_INIT(ctx); > int rc =3D 1, abort_transaction =3D 0; > uint32_t memorykb =3D 0, videoram =3D 0; > @@ -3754,7 +3761,10 @@ retry_transaction: > abort_transaction =3D 1; > goto out; > } > - > + //lcc: > + LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "target_nid =3D %d focus=3D %d", n= ode_specify, (int) nodeexact); > + libxl__xs_write(gc, t, libxl__sprintf(gc, "%s/memory/target_nid", > + dompath), "%"PRId32" %"PRId32, node_specify, (int)nodeex= act); > libxl__xs_write(gc, t, libxl__sprintf(gc, "%s/memory/target", > dompath), "%"PRIu32, new_target_memkb); > rc =3D xc_domain_getinfolist(ctx->xch, domid, 1, &info); > diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h > index be19bf5..e21d8c3 100644 > --- a/tools/libxl/libxl.h > +++ b/tools/libxl/libxl.h > @@ -628,6 +628,7 @@ int libxl_domain_core_dump(libxl_ctx *ctx, uint32_t d= omid, > =20 > int libxl_domain_setmaxmem(libxl_ctx *ctx, uint32_t domid, uint32_t targ= et_memkb); > int libxl_set_memory_target(libxl_ctx *ctx, uint32_t domid, int32_t targ= et_memkb, int relative, int enforce); > +int libxl_set_memory_target_numa(libxl_ctx *ctx, uint32_t domid, int32_t= target_memkb, int relative, int enforce, int node_specify, bool nodeexact)= ; > int libxl_get_memory_target(libxl_ctx *ctx, uint32_t domid, uint32_t *ou= t_target); > =20 >=20 > diff --git a/tools/libxl/xl.h b/tools/libxl/xl.h > index e72a7d2..6e5873d 100644 > --- a/tools/libxl/xl.h > +++ b/tools/libxl/xl.h > @@ -62,6 +62,7 @@ int main_vcpupin(int argc, char **argv); > int main_vcpuset(int argc, char **argv); > int main_memmax(int argc, char **argv); > int main_memset(int argc, char **argv); > +int main_memset_numa(int argc, char **argv); > int main_sched_credit(int argc, char **argv); > int main_sched_credit2(int argc, char **argv); > int main_sched_sedf(int argc, char **argv); > diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c > index 884f050..ddfb0d5 100644 > --- a/tools/libxl/xl_cmdimpl.c > +++ b/tools/libxl/xl_cmdimpl.c > @@ -2523,6 +2523,51 @@ int main_memset(int argc, char **argv) > return 0; > } > =20 > +static void set_memory_target_numa(uint32_t domid, const char *mem, int = mnid, bool nodeexact) > +{ > + long long int memorykb; > + > + memorykb =3D parse_mem_size_kb(mem); > + if (memorykb =3D=3D -1) { > + fprintf(stderr, "invalid memory size: %s\n", mem); > + exit(3); > + } > + > + libxl_set_memory_target_numa(ctx, domid, memorykb, 0, /* enforce */ = 1, mnid, nodeexact); > +} > + > +int main_memset_numa(int argc, char **argv) > +{ > + uint32_t domid; > + int opt =3D 0; > + int mnid =3D -1; > + const char *mem; > + bool nodeexact =3D false; > + static const struct option opts[] =3D { > + {"exact", 0, 0, 'e'}, > + COMMON_LONG_OPTS, > + {0, 0, 0, 0} > + }; > + > + SWITCH_FOREACH_OPT(opt, "e", opts, "mem-set-numa", 1) { > + case 'e': > + nodeexact =3D true; > + break; > + } > + if (argc < optind + 3){ > + help("mem-set-numa"); > + return 2; > + } > + domid =3D find_domain(argv[optind]); > + mem =3D argv[optind + 1]; > + if (sscanf(argv[optind + 2], "%d", &mnid) !=3D 1){ > + fprintf(stderr, "invalid node id"); > + } > + fprintf(stderr, "nodeexact =3D %d domid =3D %d mem =3D %s mnid =3D %= d\n", nodeexact, domid, mem, mnid); > + set_memory_target_numa(domid, mem, mnid, nodeexact); > + return 0; > +} > + > static int cd_insert(uint32_t domid, const char *virtdev, char *phys) > { > libxl_device_disk disk; /* we don't free disk's contents */ > diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c > index 326a660..ab918c0 100644 > --- a/tools/libxl/xl_cmdtable.c > +++ b/tools/libxl/xl_cmdtable.c > @@ -199,6 +199,13 @@ struct cmd_spec cmd_table[] =3D { > "Set the current memory usage for a domain", > " ", > }, > + { "mem-set-numa", > + &main_memset_numa, 0, 1, > + "Set the current memory usage for a domain, with numa node speci= fied", > + "[-e] ", > + "-e, --exact: operatrion will force on this node exactly" > + "nid: the machine(physical) node id\n" > + }, > { "button-press", > &main_button_press, 0, 1, > "Indicate an ACPI button press to the domain", --=20 <> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK) --=-Ciombx19XGdur2XBGVDF 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.14 (GNU/Linux) iEYEABECAAYFAlIJFkYACgkQk4XaBE3IOsSMywCcCpwLLHRnfFiBNB+Q5FYgnQzF t6IAoJ54v1GHzkhYQAXsR7P0ZSn/3x15 =EoAY -----END PGP SIGNATURE----- --=-Ciombx19XGdur2XBGVDF-- --===============0996621075266862486== 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 --===============0996621075266862486==--