[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH for Xen 4.6 3/5] tools/libxl: return socket id from libxl_psr_cat_get_l3_info
On Mon, Sep 28, 2015 at 07:54:51PM +0800, Chao Peng wrote: > The entries returned from libxl_psr_cat_get_l3_info are assumed > to be socket-continuous. But this is not true in the hotplug case. > > This patch gets the socket bitmap for all the sockets on the system > first and stores the socket id in the structure libxl_psr_cat_info in > libxl_psr_cat_get_l3_info. The xl or similar consumers then can display > socket information correctly. For the sake of future extention, the > field added to libxl_psr_cat_info is named as target_id. > > Signed-off-by: Chao Peng <chao.p.peng@xxxxxxxxxxxxxxx> > --- > tools/libxl/libxl_psr.c | 21 ++++++++++++++++----- > tools/libxl/libxl_types.idl | 1 + > tools/libxl/xl_cmdimpl.c | 37 +++++++++++++++++++------------------ > 3 files changed, 36 insertions(+), 23 deletions(-) > > diff --git a/tools/libxl/libxl_psr.c b/tools/libxl/libxl_psr.c > index 3378239..10e1113 100644 > --- a/tools/libxl/libxl_psr.c > +++ b/tools/libxl/libxl_psr.c > @@ -339,7 +339,8 @@ int libxl_psr_cat_get_l3_info(libxl_ctx *ctx, > libxl_psr_cat_info **info, > { > GC_INIT(ctx); > int rc; > - int i, nr_sockets; > + int i = 0, socket, nr_sockets; > + libxl_bitmap socketmap; > libxl_psr_cat_info *ptr; > > rc = libxl__count_physical_sockets(gc, &nr_sockets); > @@ -348,21 +349,31 @@ int libxl_psr_cat_get_l3_info(libxl_ctx *ctx, > libxl_psr_cat_info **info, > goto out; > } This is a path that you call libxl_bitmap_dispose on an uninitialised socketmap. > > + libxl_socket_bitmap_alloc(ctx, &socketmap, nr_sockets); > + rc = libxl_socket_bitmap_fill(ctx, &socketmap); > + if (rc < 0) { > + LOGE(ERROR, "failed to get available sockets"); > + goto out; > + } > + > ptr = libxl__malloc(NOGC, nr_sockets * sizeof(libxl_psr_cat_info)); > > - for (i = 0; i < nr_sockets; i++) { > - if (xc_psr_cat_get_l3_info(ctx->xch, i, &ptr[i].cos_max, > - &ptr[i].cbm_len)) { > + libxl_for_each_set_bit(socket, socketmap) { > + ptr[i].target_id = socket; > + if (xc_psr_cat_get_l3_info(ctx->xch, socket, &ptr[i].cos_max, > + &ptr[i].cbm_len)) { > libxl__psr_cat_log_err_msg(gc, errno); > rc = ERROR_FAIL; > free(ptr); > goto out; > } > + i++; > } > > *info = ptr; > - *nr = nr_sockets; > + *nr = i; > out: > + libxl_bitmap_dispose(&socketmap); > GC_FREE; > return rc; > } Again, we get away with changing behaviour of API because this is not yet released. > diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl > index 9f6ec00..c7bd425 100644 > --- a/tools/libxl/libxl_types.idl > +++ b/tools/libxl/libxl_types.idl > @@ -792,6 +792,7 @@ libxl_psr_cbm_type = Enumeration("psr_cbm_type", [ > ]) > > libxl_psr_cat_info = Struct("psr_cat_info", [ > + ("target_id", uint32), Or just call it "socket_id"? Or even just "id" because you know this structure is for socket? Wei. _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |