Skip to contentSkip to conversation

Several PSR fixes in libxl

PATCH Superseded Chao Peng 3 participants 27 messages Sep 28, 2015 – Sep 29, 2015

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Chao Peng

author
#0 lore raw

cover Several PSR fixes in libxl

The patch basically contains several PSR fixes in libxl.

patch1-3: fix the socket display error in certain hotplug case.
patch4:   fix a minor range check.
patch5:   improve the PSR document.

Detailed problem and fix please see commit message.

Chao Peng (5):
tools/libxl: introduce libxl_socket_bitmap_fill tools/libxl: fix socket display error for CMT tools/libxl: return socket id from libxl_psr_cat_get_l3_info tools/libxl: fix range check in main_psr_cat_cbm_set
docs: make xl-psr.markdown more precise

 docs/misc/xl-psr.markdown   |  8 ++---
 tools/libxl/libxl.h         |  7 ++--
 tools/libxl/libxl_psr.c     | 21 +++++++++---
 tools/libxl/libxl_types.idl |  1 +
 tools/libxl/libxl_utils.c   | 21 ++++++++++++
 tools/libxl/libxl_utils.h   |  2 ++
 tools/libxl/xl_cmdimpl.c    | 81 +++++++++++++++++++++++----------------------
 7 files changed, 90 insertions(+), 51 deletions(-)
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 1/5 tools/libxl: introduce libxl_socket_bitmap_fill

It sets the bit on the given bitmap if the corresponding socket is available and clears the bit when the corresponding socket is not available.

---
 tools/libxl/libxl.h       |  7 ++++---
 tools/libxl/libxl_utils.c | 21 +++++++++++++++++++++
 tools/libxl/libxl_utils.h |  2 ++
 3 files changed, 27 insertions(+), 3 deletions(-)
tools/libxl/libxl.h +4 -3
index 5f9047c..5a91687 100644
@@ -807,11 +807,12 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, libxl_mac *src);
 #define LIBXL_HAVE_PCITOPOLOGY 1
 
 /*
- * LIBXL_HAVE_SOCKET_BITMAP_ALLOC
+ * LIBXL_HAVE_SOCKET_BITMAP
  *
- * If this is defined, then libxl_socket_bitmap_alloc exists.
+ * If this is defined, then libxl_socket_bitmap_alloc and
+ * libxl_socket_bitmap_Fill exist.
  */
-#define LIBXL_HAVE_SOCKET_BITMAP_ALLOC 1
+#define LIBXL_HAVE_SOCKET_BITMAP 1
 
 /*
  * LIBXL_HAVE_SRM_V2
tools/libxl/libxl_utils.c +21 -0
index bfc9699..557f279 100644
@@ -886,6 +886,27 @@ int libxl_socket_bitmap_alloc(libxl_ctx *ctx, libxl_bitmap *socketmap,
 
 }
 
+int libxl_socket_bitmap_fill(libxl_ctx *ctx, libxl_bitmap *socketmap)
+{
+    libxl_cputopology *tinfo = NULL;
+    int nr_cpus = 0, i, rc = 0;
+
+    tinfo = libxl_get_cpu_topology(ctx, &nr_cpus);
+    if (tinfo == NULL) {
+        rc = ERROR_FAIL;
+        goto out;
+    }
+
+    libxl_bitmap_set_none(socketmap);
+    for (i = 0; i < nr_cpus; i++)
+        if (tinfo[i].socket != XEN_INVALID_SOCKET_ID
+            && !libxl_bitmap_test(socketmap, tinfo[i].socket))
+            libxl_bitmap_set(socketmap, tinfo[i].socket);
+ out:
+    libxl_cputopology_list_free(tinfo, nr_cpus);
+    return rc;
+
+}
 int libxl_nodemap_to_cpumap(libxl_ctx *ctx,
                             const libxl_bitmap *nodemap,
                             libxl_bitmap *cpumap)
tools/libxl/libxl_utils.h +2 -0
index 1e5ca8a..b55099a 100644
@@ -143,6 +143,8 @@ int libxl_node_bitmap_alloc(libxl_ctx *ctx, libxl_bitmap *nodemap,
                             int max_nodes);
 int libxl_socket_bitmap_alloc(libxl_ctx *ctx, libxl_bitmap *socketmap,
                               int max_sockets);
+/* Fill socketmap with the CPU topology information on the system. */
+int libxl_socket_bitmap_fill(libxl_ctx *ctx, libxl_bitmap *socketmap);
 
 /* Populate cpumap with the cpus spanned by the nodes in nodemap */
 int libxl_nodemap_to_cpumap(libxl_ctx *ctx,
Signature · 1 line
1.9.1
author
#7 lore raw

PATCH 2/5 tools/libxl: fix socket display error for CMT

In reply to Chao Peng

When displaying the CMT information for all the sockets, we assume socket number is continuous. This is not true in the hotplug case. For instance, when the 3rd socket is plugged out on a 4-socket system, the available sockets numbers are 1,2,4 but current we will display the CMT information for socket 1,2,3.

The fix is getting the socket bitmap for all the sockets on the system first and then displaying CMT information for_each_set_bit in that bitmap.

---
 tools/libxl/xl_cmdimpl.c | 42 ++++++++++++++++++++++--------------------
 1 file changed, 22 insertions(+), 20 deletions(-)
tools/libxl/xl_cmdimpl.c +22 -20
index 2706759..c72d3df 100644
@@ -8192,7 +8192,7 @@ static int psr_cmt_get_mem_bandwidth(uint32_t domid,
 
 static void psr_cmt_print_domain_info(libxl_dominfo *dominfo,
                                       libxl_psr_cmt_type type,
-                                      uint32_t nr_sockets)
+                                      libxl_bitmap *socketmap)
 {
     char *domain_name;
     uint32_t socketid;
@@ -8205,7 +8205,7 @@ static void psr_cmt_print_domain_info(libxl_dominfo *dominfo,
     printf("%-40s %5d", domain_name, dominfo->domid);
     free(domain_name);
 
-    for (socketid = 0; socketid < nr_sockets; socketid++) {
+    libxl_for_each_set_bit(socketid, *socketmap) {
         switch (type) {
         case LIBXL_PSR_CMT_TYPE_CACHE_OCCUPANCY:
             if (!libxl_psr_cmt_get_sample(ctx, dominfo->domid, type, socketid,
@@ -8228,9 +8228,9 @@ static void psr_cmt_print_domain_info(libxl_dominfo *dominfo,
 
 static int psr_cmt_show(libxl_psr_cmt_type type, uint32_t domid)
 {
-    uint32_t i, socketid, nr_sockets, total_rmid;
+    uint32_t i, socketid, total_rmid;
     uint32_t l3_cache_size;
-    libxl_physinfo info;
+    libxl_bitmap socketmap;
     int rc, nr_domains;
 
     if (!libxl_psr_cmt_enabled(ctx)) {
@@ -8244,41 +8244,38 @@ static int psr_cmt_show(libxl_psr_cmt_type type, uint32_t domid)
         return -1;
     }
 
-    libxl_physinfo_init(&info);
-    rc = libxl_get_physinfo(ctx, &info);
+    libxl_socket_bitmap_alloc(ctx, &socketmap, 0);
+    rc = libxl_socket_bitmap_fill(ctx, &socketmap);
     if (rc < 0) {
-        fprintf(stderr, "Failed getting physinfo, rc: %d\n", rc);
-        libxl_physinfo_dispose(&info);
-        return -1;
+        fprintf(stderr, "Failed getting available sockets, rc: %d\n", rc);
+        goto out;
     }
-    nr_sockets = info.nr_cpus / info.threads_per_core / info.cores_per_socket;
-    libxl_physinfo_dispose(&info);
 
     rc = libxl_psr_cmt_get_total_rmid(ctx, &total_rmid);
     if (rc < 0) {
         fprintf(stderr, "Failed to get max RMID value\n");
-        return -1;
+        goto out;
     }
 
     printf("Total RMID: %d\n", total_rmid);
 
     /* Header */
     printf("%-40s %5s", "Name", "ID");
-    for (socketid = 0; socketid < nr_sockets; socketid++)
+    libxl_for_each_set_bit(socketid, socketmap)
         printf("%14s %d", "Socket", socketid);
     printf("\n");
 
     if (type == LIBXL_PSR_CMT_TYPE_CACHE_OCCUPANCY) {
             /* Total L3 cache size */
             printf("%-46s", "Total L3 Cache Size");
-            for (socketid = 0; socketid < nr_sockets; socketid++) {
+            libxl_for_each_set_bit(socketid, socketmap) {
                 rc = libxl_psr_cmt_get_l3_cache_size(ctx, socketid,
                                                      &l3_cache_size);
                 if (rc < 0) {
                     fprintf(stderr,
                             "Failed to get system l3 cache size for socket:%d\n",
                             socketid);
-                    return -1;
+                    goto out;
                 }
                 printf("%13u KB", l3_cache_size);
             }
@@ -8292,9 +8289,10 @@ static int psr_cmt_show(libxl_psr_cmt_type type, uint32_t domid)
         libxl_dominfo_init(&dominfo);
         if (libxl_domain_info(ctx, &dominfo, domid)) {
             fprintf(stderr, "Failed to get domain info for %d\n", domid);
-            return -1;
+            rc = -1;
+            goto out;
         }
-        psr_cmt_print_domain_info(&dominfo, type, nr_sockets);
+        psr_cmt_print_domain_info(&dominfo, type, &socketmap);
         libxl_dominfo_dispose(&dominfo);
     }
     else
@@ -8302,13 +8300,17 @@ static int psr_cmt_show(libxl_psr_cmt_type type, uint32_t domid)
         libxl_dominfo *list;
         if (!(list = libxl_list_domain(ctx, &nr_domains))) {
             fprintf(stderr, "Failed to get domain info for domain list.\n");
-            return -1;
+            rc = -1;
+            goto out;
         }
         for (i = 0; i < nr_domains; i++)
-            psr_cmt_print_domain_info(list + i, type, nr_sockets);
+            psr_cmt_print_domain_info(list + i, type, &socketmap);
         libxl_dominfo_list_free(list, nr_domains);
     }
-    return 0;
+
+out:
+    libxl_bitmap_dispose(&socketmap);
+    return rc;
 }
 
 int main_psr_cmt_attach(int argc, char **argv)
Signature · 1 line
1.9.1
author
#12 lore raw

PATCH 3/5 tools/libxl: return socket id from libxl_psr_cat_get_l3_info

In reply to Chao Peng

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.

---
 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(-)
tools/libxl/libxl_psr.c +16 -5
index 3378239..10e1113 100644
@@ -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;
     }
 
+    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;
 }
tools/libxl/libxl_types.idl +1 -0
index 9f6ec00..c7bd425 100644
@@ -792,6 +792,7 @@ libxl_psr_cbm_type = Enumeration("psr_cbm_type", [
     ])
 
 libxl_psr_cat_info = Struct("psr_cat_info", [
+    ("target_id", uint32),
     ("cos_max", uint32),
     ("cbm_len", uint32),
     ])
tools/libxl/xl_cmdimpl.c +19 -18
index c72d3df..cec0d2c 100644
@@ -8383,35 +8383,37 @@ int main_psr_cmt_show(int argc, char **argv)
 static int psr_cat_hwinfo(void)
 {
     int rc;
-    int socketid, nr_sockets;
+    int i, nr;
     uint32_t l3_cache_size;
     libxl_psr_cat_info *info;
 
     printf("Cache Allocation Technology (CAT):\n");
 
-    rc = libxl_psr_cat_get_l3_info(ctx, &info, &nr_sockets);
+    rc = libxl_psr_cat_get_l3_info(ctx, &info, &nr);
     if (rc) {
         fprintf(stderr, "Failed to get cat info\n");
         return rc;
     }
 
-    for (socketid = 0; socketid < nr_sockets; socketid++) {
-        rc = libxl_psr_cmt_get_l3_cache_size(ctx, socketid, &l3_cache_size);
+    for (i = 0; i < nr; i++) {
+        rc = libxl_psr_cmt_get_l3_cache_size(ctx, info->target_id,
+                                             &l3_cache_size);
         if (rc) {
             fprintf(stderr, "Failed to get l3 cache size for socket:%d\n",
-                    socketid);
+                    info->target_id);
             goto out;
         }
-        printf("%-16s: %u\n", "Socket ID", socketid);
+        printf("%-16s: %u\n", "Socket ID", info->target_id);
         printf("%-16s: %uKB\n", "L3 Cache", l3_cache_size);
         printf("%-16s: %u\n", "Maximum COS", info->cos_max);
         printf("%-16s: %u\n", "CBM length", info->cbm_len);
         printf("%-16s: %#llx\n", "Default CBM",
                (1ull << info->cbm_len) - 1);
+        info++;
     }
 
 out:
-    libxl_psr_cat_info_list_free(info, nr_sockets);
+    libxl_psr_cat_info_list_free(info, nr);
     return rc;
 }
 
@@ -8453,47 +8455,46 @@ static int psr_cat_print_domain_cbm(uint32_t domid, uint32_t socketid)
     return 0;
 }
 
-static int psr_cat_print_socket(uint32_t domid, uint32_t socketid,
-                                libxl_psr_cat_info *info)
+static int psr_cat_print_socket(uint32_t domid, libxl_psr_cat_info *info)
 {
     int rc;
     uint32_t l3_cache_size;
 
-    rc = libxl_psr_cmt_get_l3_cache_size(ctx, socketid, &l3_cache_size);
+    rc = libxl_psr_cmt_get_l3_cache_size(ctx, info->target_id, &l3_cache_size);
     if (rc) {
         fprintf(stderr, "Failed to get l3 cache size for socket:%d\n",
-                socketid);
+                info->target_id);
         return -1;
     }
 
-    printf("%-16s: %u\n", "Socket ID", socketid);
+    printf("%-16s: %u\n", "Socket ID", info->target_id);
     printf("%-16s: %uKB\n", "L3 Cache", l3_cache_size);
     printf("%-16s: %#llx\n", "Default CBM", (1ull << info->cbm_len) - 1);
     printf("%5s%25s%16s\n", "ID", "NAME", "CBM");
 
-    return psr_cat_print_domain_cbm(domid, socketid);
+    return psr_cat_print_domain_cbm(domid, info->target_id);
 }
 
 static int psr_cat_show(uint32_t domid)
 {
-    int socketid, nr_sockets;
+    int i, nr;
     int rc;
     libxl_psr_cat_info *info;
 
-    rc = libxl_psr_cat_get_l3_info(ctx, &info, &nr_sockets);
+    rc = libxl_psr_cat_get_l3_info(ctx, &info, &nr);
     if (rc) {
         fprintf(stderr, "Failed to get cat info\n");
         return rc;
     }
 
-    for (socketid = 0; socketid < nr_sockets; socketid++) {
-        rc = psr_cat_print_socket(domid, socketid, info + socketid);
+    for (i = 0; i < nr; i++) {
+        rc = psr_cat_print_socket(domid, info + i);
         if (rc)
             goto out;
     }
 
 out:
-    libxl_psr_cat_info_list_free(info, nr_sockets);
+    libxl_psr_cat_info_list_free(info, nr);
     return rc;
 }
 
Signature · 1 line
1.9.1
author
#18 lore raw

PATCH 4/5 tools/libxl: fix range check in main_psr_cat_cbm_set

In reply to Chao Peng

The 'end' should be inclusive.

---
 tools/libxl/xl_cmdimpl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxl/xl_cmdimpl.c +1 -1
index cec0d2c..045b70e 100644
@@ -8525,7 +8525,7 @@ int main_psr_cat_cbm_set(int argc, char **argv)
         len = libxl_string_list_length(&socket_list);
         for (i = 0; i < len; i++) {
             parse_range(socket_list[i], &start, &end);
-            for (j = start; j < end; j++)
+            for (j = start; j <= end; j++)
                 libxl_bitmap_set(&target_map, j);
         }
 
Signature · 1 line
1.9.1
author
#21 lore raw

PATCH 5/5 docs: make xl-psr.markdown more precise

In reply to Chao Peng

Make the chapter name and reference url more precise. The chapter number is dropped as it can be confusing when it gets changed in the referred document.

---
 docs/misc/xl-psr.markdown | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
docs/misc/xl-psr.markdown +4 -4
index 3545912..737f0f7 100644
@@ -14,7 +14,7 @@ tracks cache utilization of memory accesses according to the RMID and reports
 monitored data via a counter register.
 
 For more detailed information please refer to Intel SDM chapter
-"17.14 - Platform Shared Resource Monitoring: Cache Monitoring Technology".
+"Platform Shared Resource Monitoring: Cache Monitoring Technology".
 
 In Xen's implementation, each domain in the system can be assigned a RMID
 independently, while RMID=0 is reserved for monitoring domains that don't
@@ -52,7 +52,7 @@ event type to monitor system total/local memory bandwidth. The same RMID can
 be used to monitor both cache usage and memory bandwidth at the same time.
 
 For more detailed information please refer to Intel SDM chapter
-"17.14 - Platform Shared Resource Monitoring: Cache Monitoring Technology".
+"Overview of Cache Monitoring Technology and Memory Bandwidth Monitoring".
 
 In Xen's implementation, MBM shares the same set of underlying monitoring
 service with CMT and can be used to monitor memory bandwidth on a per domain
@@ -92,7 +92,7 @@ For example, assuming a system with 8 portions and 3 domains:
    access to one quarter each.
 
 For more detailed information please refer to Intel SDM chapter
-"17.15 - Platform Shared Resource Control: Cache Allocation Technology".
+"Platform Shared Resource Control: Cache Allocation Technology".
 
 In Xen's implementation, CBM can be configured with libxl/xl interfaces but
 COS is maintained in hypervisor only. The cache partition granularity is per
@@ -130,4 +130,4 @@ Per domain CBM settings can be shown by:
 ## Reference
 
 [1] Intel SDM
-(http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html).
+(http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-system-programming-manual-325384.pdf).
Signature · 1 line
1.9.1
#2 lore raw

Re: [PATCH for Xen 4.6 1/5] tools/libxl: introduce libxl_socket_bitmap_fill

In reply to Chao Peng
Quoted 16 lines · Chao Peng

It sets the bit on the given bitmap if the corresponding socket is available and clears the bit when the corresponding socket is not available.

---
 tools/libxl/libxl.h       |  7 ++++---
 tools/libxl/libxl_utils.c | 21 +++++++++++++++++++++
 tools/libxl/libxl_utils.h |  2 ++
 3 files changed, 27 insertions(+), 3 deletions(-)
tools/libxl/libxl.h +0 -0
index 5f9047c..5a91687 100644

tools/libxl/libxl.h void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, libxl_mac *src); · line 813

Quoted 9 lines
tools/libxl/libxl.h +3 -2
@@ -807,11 +807,12 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, libxl_mac *src);
 #define LIBXL_HAVE_PCITOPOLOGY 1
 
 /*
- * LIBXL_HAVE_SOCKET_BITMAP_ALLOC
+ * LIBXL_HAVE_SOCKET_BITMAP
  *
- * If this is defined, then libxl_socket_bitmap_alloc exists.
+ * If this is defined, then libxl_socket_bitmap_alloc and
+ * libxl_socket_bitmap_Fill exist.

_Fill -> _fill.

tools/libxl/libxl.h void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, libxl_mac *src); · line 816

Quoted 4 lines
tools/libxl/libxl.h +1 -1
  */
-#define LIBXL_HAVE_SOCKET_BITMAP_ALLOC 1
+#define LIBXL_HAVE_SOCKET_BITMAP 1
 

Normally we don't / can't delete existing macros. However this macro was introduced in this cycle, so we have the liberty to change it before releasing.

If for any reason this series doesn't make it in 4.6, you would need to come up with a different macro name.

Quoted 21 lines
tools/libxl/libxl.h +0 -0
 /*
  * LIBXL_HAVE_SRM_V2
tools/libxl/libxl_utils.c +11 -0
index bfc9699..557f279 100644
@@ -886,6 +886,27 @@ int libxl_socket_bitmap_alloc(libxl_ctx *ctx, libxl_bitmap *socketmap,
 
 }
 
+int libxl_socket_bitmap_fill(libxl_ctx *ctx, libxl_bitmap *socketmap)
+{
+    libxl_cputopology *tinfo = NULL;
+    int nr_cpus = 0, i, rc = 0;
+
+    tinfo = libxl_get_cpu_topology(ctx, &nr_cpus);
+    if (tinfo == NULL) {
+        rc = ERROR_FAIL;
+        goto out;
+    }
+

tools/libxl/libxl_utils.c int libxl_socket_bitmap_alloc(libxl_ctx *ctx, libxl_bitmap *socketmap, · line 909

Quoted 10 lines
tools/libxl/libxl_utils.c +10 -0
+    libxl_bitmap_set_none(socketmap);
+    for (i = 0; i < nr_cpus; i++)
+        if (tinfo[i].socket != XEN_INVALID_SOCKET_ID
+            && !libxl_bitmap_test(socketmap, tinfo[i].socket))
+            libxl_bitmap_set(socketmap, tinfo[i].socket);
+ out:
+    libxl_cputopology_list_free(tinfo, nr_cpus);
+    return rc;
+
+}

Need extra blank line.

Quoted 18 lines
tools/libxl/libxl_utils.c +0 -0
 int libxl_nodemap_to_cpumap(libxl_ctx *ctx,
                             const libxl_bitmap *nodemap,
                             libxl_bitmap *cpumap)
tools/libxl/libxl_utils.h +2 -0
index 1e5ca8a..b55099a 100644
@@ -143,6 +143,8 @@ int libxl_node_bitmap_alloc(libxl_ctx *ctx, libxl_bitmap *nodemap,
                             int max_nodes);
 int libxl_socket_bitmap_alloc(libxl_ctx *ctx, libxl_bitmap *socketmap,
                               int max_sockets);
+/* Fill socketmap with the CPU topology information on the system. */
+int libxl_socket_bitmap_fill(libxl_ctx *ctx, libxl_bitmap *socketmap);
 
 /* Populate cpumap with the cpus spanned by the nodes in nodemap */
 int libxl_nodemap_to_cpumap(libxl_ctx *ctx,
Signature · 1 line
1.9.1
Acked-by on v1 2/5
#8 lore raw

Re: [PATCH for Xen 4.6 2/5] tools/libxl: fix socket display error for CMT

In reply to Chao Peng
Quoted 10 lines · Chao Peng

When displaying the CMT information for all the sockets, we assume socket number is continuous. This is not true in the hotplug case. For instance, when the 3rd socket is plugged out on a 4-socket system, the available sockets numbers are 1,2,4 but current we will display the CMT information for socket 1,2,3.

The fix is getting the socket bitmap for all the sockets on the system first and then displaying CMT information for_each_set_bit in that bitmap.

#13 lore raw

Re: [PATCH for Xen 4.6 3/5] tools/libxl: return socket id from libxl_psr_cat_get_l3_info

In reply to Chao Peng
Quoted 31 lines · Chao Peng

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.

---
 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(-)
tools/libxl/libxl_psr.c +2 -1
index 3378239..10e1113 100644
@@ -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);

tools/libxl/libxl_psr.c int libxl_psr_cat_get_l3_info(libxl_ctx *ctx, libxl_psr_cat_info **info, · line 350

Quoted 2 lines
tools/libxl/libxl_psr.c +0 -0
@@ -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.

Quoted 23 lines
tools/libxl/libxl_psr.c +12 -3
+    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++;

tools/libxl/libxl_psr.c int libxl_psr_cat_get_l3_info(libxl_ctx *ctx, libxl_psr_cat_info **info, · line 379

Quoted 10 lines
tools/libxl/libxl_psr.c +2 -1
     }
 
     *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.

tools/libxl/libxl_types.idl libxl_psr_cbm_type = Enumeration("psr_cbm_type", [ · line 795

Quoted 9 lines
tools/libxl/libxl_types.idl +1 -0
index 9f6ec00..c7bd425 100644
@@ -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.

Acked-by on v1 4/5
#19 lore raw

Re: [PATCH for Xen 4.6 4/5] tools/libxl: fix range check in main_psr_cat_cbm_set

In reply to Chao Peng
Quoted 3 lines · Chao Peng

The 'end' should be inclusive.

Quoted 19 lines
---
 tools/libxl/xl_cmdimpl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxl/xl_cmdimpl.c +1 -1
index cec0d2c..045b70e 100644
@@ -8525,7 +8525,7 @@ int main_psr_cat_cbm_set(int argc, char **argv)
         len = libxl_string_list_length(&socket_list);
         for (i = 0; i < len; i++) {
             parse_range(socket_list[i], &start, &end);
-            for (j = start; j < end; j++)
+            for (j = start; j <= end; j++)
                 libxl_bitmap_set(&target_map, j);
         }
 
Signature · 1 line
1.9.1
#24 lore raw
In reply to Chao Peng
Quoted 7 lines · Chao Peng

The patch basically contains several PSR fixes in libxl.

patch1-3: fix the socket display error in certain hotplug case.
patch4:   fix a minor range check.
patch5:   improve the PSR document.

Detailed problem and fix please see commit message.

I've gone through all patches. This series looks sensible to me. And I see the point of getting in it for 4.6 to avoid releasing APIs that are deemed buggy.

I would still like some more proof reading from someone who have played with this feature. I've CCed Dario and Meng.

Wei.

#3 lore raw

Re: [PATCH for Xen 4.6 1/5] tools/libxl: introduce libxl_socket_bitmap_fill

In reply to Wei Liu
Quoted 7 lines · Wei Liu
Quoted 5 lines · Chao Peng
tools/libxl/libxl.h +0 -0
index 5f9047c..5a91687 100644
Quoted 10 lines
Quoted 7 lines

/*
- * LIBXL_HAVE_SOCKET_BITMAP_ALLOC
+ * LIBXL_HAVE_SOCKET_BITMAP
*
- * If this is defined, then libxl_socket_bitmap_alloc exists.
+ * If this is defined, then libxl_socket_bitmap_alloc and
+ * libxl_socket_bitmap_Fill exist.

_Fill -> _fill.

Right.

However, it seems to me that the function would be better named libxl_get_online_sockets() or something like that.

I see that you want the actual map. For CPUs and NUMA nodes, we do have libxl_get_online_{cpus,nodes}(), but they return the number of online CPUs and nodes, so for consistency, libxl_get_online_sockets() would better (if necessary at some point) behave similarly.

What about libxl_get_online_socketmap() ? This is still a nice (IMO) name for what you're after here, and it leaves us room to implement libxl_get_online_cpumap() and libxl_get_online_nodemap(), if we'll ever need those.

Thoughs?

Quoted 10 lines

tools/libxl/libxl.h void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, libxl_mac *src); · line 815

Quoted 4 lines

*/

tools/libxl/libxl.h +1 -1
-#define LIBXL_HAVE_SOCKET_BITMAP_ALLOC 1
+#define LIBXL_HAVE_SOCKET_BITMAP 1

Normally we don't / can't delete existing macros. However this macro was
introduced in this cycle, so we have the liberty to change it before releasing.

I was about to say exactly the same thing.

Quoted 21 lines
Quoted 21 lines
tools/libxl/libxl_utils.c +1 -0
index bfc9699..557f279 100644
 
+int libxl_socket_bitmap_fill(libxl_ctx *ctx, libxl_bitmap

*socketmap)

tools/libxl/libxl_utils.c +14 -0
+{
+    libxl_cputopology *tinfo = NULL;
+    int nr_cpus = 0, i, rc = 0;
+
+    tinfo = libxl_get_cpu_topology(ctx, &nr_cpus);
+    if (tinfo == NULL) {
+        rc = ERROR_FAIL;
+        goto out;
+    }
+
+    libxl_bitmap_set_none(socketmap);
+    for (i = 0; i < nr_cpus; i++)
+        if (tinfo[i].socket != XEN_INVALID_SOCKET_ID
+            && !libxl_bitmap_test(socketmap, tinfo[i].socket))
Quoted 9 lines

tools/libxl/libxl_utils.c int libxl_socket_bitmap_alloc(libxl_ctx *ctx, libxl_bitmap *socketmap, · line 909

Quoted 6 lines
tools/libxl/libxl_utils.c +6 -0
+            libxl_bitmap_set(socketmap, tinfo[i].socket);
+ out:
+    libxl_cputopology_list_free(tinfo, nr_cpus);
+    return rc;
+
+}

Need extra blank line.

And, at the same time, the blank line between 'return rc;' and the '{' is not needed. IOW, we want this:

...
libxl_cputopology_list_free(tinfo, nr_cpus);
return rc;
}

int libxl_nodemap_to_cpumap(...
...

Regards,
Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#4 lore raw

Re: [PATCH for Xen 4.6 1/5] tools/libxl: introduce libxl_socket_bitmap_fill

Quoted 28 lines · Dario Faggioli
Quoted 7 lines · Wei Liu
Quoted 5 lines · Chao Peng
tools/libxl/libxl.h +0 -0
index 5f9047c..5a91687 100644
Quoted 10 lines
Quoted 7 lines

/*
- * LIBXL_HAVE_SOCKET_BITMAP_ALLOC
+ * LIBXL_HAVE_SOCKET_BITMAP
*
- * If this is defined, then libxl_socket_bitmap_alloc exists.
+ * If this is defined, then libxl_socket_bitmap_alloc and
+ * libxl_socket_bitmap_Fill exist.

_Fill -> _fill.

Right.

However, it seems to me that the function would be better named libxl_get_online_sockets() or something like that.

I see that you want the actual map. For CPUs and NUMA nodes, we do have libxl_get_online_{cpus,nodes}(), but they return the number of online CPUs and nodes, so for consistency, libxl_get_online_sockets() would better (if necessary at some point) behave similarly.

Quoted 7 lines

What about libxl_get_online_socketmap() ? This is still a nice (IMO) name for what you're after here, and it leaves us room to implement libxl_get_online_cpumap() and libxl_get_online_nodemap(), if we'll ever need those.

Thoughs?

I think this is sensible suggestion. But then I'm bad at naming things so I will leave it up to you guys to decide.

Wei.

#9 lore raw

Re: [PATCH for Xen 4.6 2/5] tools/libxl: fix socket display error for CMT

In reply to Chao Peng
Quoted 17 lines · Chao Peng
tools/libxl/xl_cmdimpl.c +2 -2
index 2706759..c72d3df 100644
@@ -8228,9 +8228,9 @@ static void
 psr_cmt_print_domain_info(libxl_dominfo *dominfo,
 
 static int psr_cmt_show(libxl_psr_cmt_type type, uint32_t domid)
 {
-    uint32_t i, socketid, nr_sockets, total_rmid;
+    uint32_t i, socketid, total_rmid;
     uint32_t l3_cache_size;
-    libxl_physinfo info;
+    libxl_bitmap socketmap;
     int rc, nr_domains;
 
     if (!libxl_psr_cmt_enabled(ctx)) {

tools/libxl/xl_cmdimpl.c static int psr_cmt_show(libxl_psr_cmt_type · line 8250

Quoted 9 lines
tools/libxl/xl_cmdimpl.c +2 -2
@@ -8244,41 +8244,38 @@ static int psr_cmt_show(libxl_psr_cmt_type
 type, uint32_t domid)
         return -1;
     }
 
-    libxl_physinfo_init(&info);
-    rc = libxl_get_physinfo(ctx, &info);
+    libxl_socket_bitmap_alloc(ctx, &socketmap, 0);
+    rc = libxl_socket_bitmap_fill(ctx, &socketmap);
 

Shouldn't socketmap be initied with libxl_bitmap_init() before being allocated and used?

Not doing so is certainly not an issue, in this case, but AFAIR, we always require that for libxl types, don't we?

Regards,
Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Reviewed-by on v1 5/5
#23 lore raw

Re: [PATCH for Xen 4.6 5/5] docs: make xl-psr.markdown more precise

In reply to Chao Peng
Quoted 2 lines · Chao Peng

Make the chapter name and reference url more precise.

This is pretty much the title of the changeset already, so I don't think it's worth repeating it here. I think you can well kill it, and just start with "Drop the chapter number as it can..." or "by dropping the chapter number as it can..."

Quoted 7 lines

The chapter number
is dropped as it can be confusing when it gets changed in the referred
document.

In any case:

Regards,
Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Reviewed-by
#20 lore raw

Re: [PATCH for Xen 4.6 4/5] tools/libxl: fix range check in main_psr_cat_cbm_set

In reply to Wei Liu
Quoted 7 lines · Wei Liu
Quoted 3 lines · Chao Peng

The 'end' should be inclusive.

Regards,
Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#14 lore raw

Re: [PATCH for Xen 4.6 3/5] tools/libxl: return socket id from libxl_psr_cat_get_l3_info

In reply to Wei Liu
Quoted 15 lines · Wei Liu
Quoted 13 lines · Chao Peng
tools/libxl/libxl_psr.c +2 -1
index 3378239..10e1113 100644
@@ -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;
 
Quoted 9 lines

tools/libxl/libxl_psr.c int libxl_psr_cat_get_l3_info(libxl_ctx *ctx, · line 351

Quoted 5 lines
     rc = libxl__count_physical_sockets(gc, &nr_sockets);
tools/libxl/libxl_psr.c +0 -0
@@ -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.

Yep.

However, do we still need to go through libxl__count_physical_sockets() explicitly? AFAICS, you need it for allocating ptr, and for returning it back.

But since now you're building the full bitmap, we can use libxl_bitmap_count_set(), for that.

This may not be a bit deal, but if I'm not wrong, it saves us an hypercall (the PHYSINFO that libxl__count_physical_socket() issues).

Quoted 6 lines
Quoted 6 lines
tools/libxl/libxl_types.idl +0 -0
@@ -792,6 +792,7 @@ libxl_psr_cbm_type =

Enumeration("psr_cbm_type", [

     ])
Quoted 6 lines
Quoted 2 lines

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?

Yeah, we discussed this already, AFAICR. I think the point is that, at least in theory, these features may be extended to become more fine -grained than per-socket, hence the point of not binding the interface to sockets.

That being said, FWIW, I'm fine either way.

Regards,
Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#10 lore raw

Re: [PATCH for Xen 4.6 2/5] tools/libxl: fix socket display error for CMT

In reply to Dario Faggioli
Quoted 23 lines · Dario Faggioli
Quoted 21 lines · Chao Peng
tools/libxl/xl_cmdimpl.c +2 -2
index 2706759..c72d3df 100644
@@ -8228,9 +8228,9 @@ static void
 psr_cmt_print_domain_info(libxl_dominfo *dominfo,
 
 static int psr_cmt_show(libxl_psr_cmt_type type, uint32_t domid)
 {
-    uint32_t i, socketid, nr_sockets, total_rmid;
+    uint32_t i, socketid, total_rmid;
     uint32_t l3_cache_size;
-    libxl_physinfo info;
+    libxl_bitmap socketmap;
     int rc, nr_domains;
 
     if (!libxl_psr_cmt_enabled(ctx)) {
tools/libxl/xl_cmdimpl.c +0 -0
@@ -8244,41 +8244,38 @@ static int psr_cmt_show(libxl_psr_cmt_type
 type, uint32_t domid)
         return -1;
     }
 
Quoted 8 lines

tools/libxl/xl_cmdimpl.c static int psr_cmt_show(libxl_psr_cmt_type type, uint32_t domid) · line 8253

Quoted 5 lines
tools/libxl/xl_cmdimpl.c +2 -2
-    libxl_physinfo_init(&info);
-    rc = libxl_get_physinfo(ctx, &info);
+    libxl_socket_bitmap_alloc(ctx, &socketmap, 0);
+    rc = libxl_socket_bitmap_fill(ctx, &socketmap);
 

Shouldn't socketmap be initied with libxl_bitmap_init() before being allocated and used?

Yes.

Quoted 1 line

Not doing so is certainly not an issue, in this case, but AFAIR, we

That's my thought when I first saw this patch.

Quoted 2 lines

always require that for libxl types, don't we?

But let's stick with convention.

Thanks for your careful review.

Wei.

Quoted 8 lines

Regards,
Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
#25 lore raw
In reply to Wei Liu
Quoted 6 lines · Wei Liu
Quoted 5 lines · Chao Peng

The patch basically contains several PSR fixes in libxl.

patch1-3: fix the socket display error in certain hotplug case.
patch4:   fix a minor range check.
patch5:   improve the PSR document.
Quoted 9 lines
Quoted 2 lines

Detailed problem and fix please see commit message.

I've gone through all patches. This series looks sensible to me. And I
see the point of getting in it for 4.6 to avoid releasing APIs that are
deemed buggy.

FWIW, I totally agree.

The patch looks sensible to me too, I've only found a couple of minor issues.

Quoted 4 lines

I would still like some more proof reading from someone who have played
with this feature. I've CCed Dario and Meng.

Thanks for pinging... I've done my best. :-)

About the suggestions I provided, the more important thing, IMO, is the name of the new function for retrieving the available sockets bitmap, which I really think it should be called libxl_get_online_socketmap().

The others are indeed minor things, which don't affect public APIs and hence --although I'd prefer to see them addressed-- we can fix/change them post 4.6 too.

Regards,
Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#15 lore raw

Re: [PATCH for Xen 4.6 3/5] tools/libxl: return socket id from libxl_psr_cat_get_l3_info

In reply to Dario Faggioli
Quoted 31 lines · Dario Faggioli
Quoted 15 lines · Wei Liu
Quoted 13 lines · Chao Peng
tools/libxl/libxl_psr.c +2 -1
index 3378239..10e1113 100644
@@ -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;
 
Quoted 9 lines

tools/libxl/libxl_psr.c int libxl_psr_cat_get_l3_info(libxl_ctx *ctx, · line 351

Quoted 5 lines
     rc = libxl__count_physical_sockets(gc, &nr_sockets);
tools/libxl/libxl_psr.c +0 -0
@@ -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.

Yep.

However, do we still need to go through libxl__count_physical_sockets() explicitly? AFAICS, you need it for allocating ptr, and for returning it back.

Quoted 6 lines

But since now you're building the full bitmap, we can use libxl_bitmap_count_set(), for that.

This may not be a bit deal, but if I'm not wrong, it saves us an hypercall (the PHYSINFO that libxl__count_physical_socket() issues).

Right, this is optimisation. I'm not too fussed either way as long as this function is functionally correct. :-)

Quoted 12 lines
Quoted 6 lines
Quoted 6 lines
tools/libxl/libxl_types.idl +0 -0
@@ -792,6 +792,7 @@ libxl_psr_cbm_type =

Enumeration("psr_cbm_type", [

     ])
Quoted 6 lines
Quoted 2 lines

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?

Quoted 7 lines

Yeah, we discussed this already, AFAICR. I think the point is that, at least in theory, these features may be extended to become more fine -grained than per-socket, hence the point of not binding the interface to sockets.

That being said, FWIW, I'm fine either way.

The thing that bugs me a little is that "target_id" doesn't seem very meaningful. I would just go for "id" if it is not bound to socket.

Chao, what do you think?

Wei.

Quoted 8 lines

Regards,
Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
author
#5 lore raw

Re: [PATCH for Xen 4.6 1/5] tools/libxl: introduce libxl_socket_bitmap_fill

In reply to Dario Faggioli
Quoted 20 lines · Dario Faggioli
Quoted 7 lines · Wei Liu
Quoted 5 lines · Chao Peng
tools/libxl/libxl.h +0 -0
index 5f9047c..5a91687 100644
Quoted 10 lines
Quoted 7 lines

/*
- * LIBXL_HAVE_SOCKET_BITMAP_ALLOC
+ * LIBXL_HAVE_SOCKET_BITMAP
*
- * If this is defined, then libxl_socket_bitmap_alloc exists.
+ * If this is defined, then libxl_socket_bitmap_alloc and
+ * libxl_socket_bitmap_Fill exist.

_Fill -> _fill.

Right.

Quoted 7 lines

However, it seems to me that the function would be better named libxl_get_online_sockets() or something like that.

I see that you want the actual map. For CPUs and NUMA nodes, we do have libxl_get_online_{cpus,nodes}(), but they return the number of online CPUs and nodes, so for consistency, libxl_get_online_sockets() would better (if necessary at some point) behave similarly.

Actually for the similar purpose of libxl_get_online_{cpus,nodes}, we have libxl__count_physical_sockets() already, which would ideally be called libxl_get_online_sockets(). Since it's not public so we have liberty to change it in the future, if everyone agrees.

Quoted 7 lines

What about libxl_get_online_socketmap() ? This is still a nice (IMO) name for what you're after here, and it leaves us room to implement libxl_get_online_cpumap() and libxl_get_online_nodemap(), if we'll ever need those.

Thoughs?

I have been strugging with the naming, but libxl_get_online_socketmap() looks right for me. Thanks for suggestion.

Chao

author
#6 lore raw

Re: [PATCH for Xen 4.6 1/5] tools/libxl: introduce libxl_socket_bitmap_fill

In reply to Wei Liu
Quoted 38 lines · Wei Liu
Quoted 16 lines · Chao Peng

It sets the bit on the given bitmap if the corresponding socket is available and clears the bit when the corresponding socket is not available.

---
 tools/libxl/libxl.h       |  7 ++++---
 tools/libxl/libxl_utils.c | 21 +++++++++++++++++++++
 tools/libxl/libxl_utils.h |  2 ++
 3 files changed, 27 insertions(+), 3 deletions(-)
tools/libxl/libxl.h +0 -0
index 5f9047c..5a91687 100644

tools/libxl/libxl.h void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, libxl_mac *src); · line 813

Quoted 9 lines
tools/libxl/libxl.h +3 -2
@@ -807,11 +807,12 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, libxl_mac *src);
 #define LIBXL_HAVE_PCITOPOLOGY 1
 
 /*
- * LIBXL_HAVE_SOCKET_BITMAP_ALLOC
+ * LIBXL_HAVE_SOCKET_BITMAP
  *
- * If this is defined, then libxl_socket_bitmap_alloc exists.
+ * If this is defined, then libxl_socket_bitmap_alloc and
+ * libxl_socket_bitmap_Fill exist.

_Fill -> _fill.

tools/libxl/libxl.h void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, libxl_mac *src); · line 816

Quoted 4 lines
tools/libxl/libxl.h +1 -1
  */
-#define LIBXL_HAVE_SOCKET_BITMAP_ALLOC 1
+#define LIBXL_HAVE_SOCKET_BITMAP 1
 

Normally we don't / can't delete existing macros. However this macro was introduced in this cycle, so we have the liberty to change it before releasing.

Quoted 2 lines

If for any reason this series doesn't make it in 4.6, you would need to come up with a different macro name.

Agreed, if it misses 4.6, I will use another name. Thanks :)

Chao

author
#11 lore raw

Re: [PATCH for Xen 4.6 2/5] tools/libxl: fix socket display error for CMT

In reply to Wei Liu
Quoted 35 lines · Wei Liu
Quoted 23 lines · Dario Faggioli
Quoted 21 lines · Chao Peng
tools/libxl/xl_cmdimpl.c +2 -2
index 2706759..c72d3df 100644
@@ -8228,9 +8228,9 @@ static void
 psr_cmt_print_domain_info(libxl_dominfo *dominfo,
 
 static int psr_cmt_show(libxl_psr_cmt_type type, uint32_t domid)
 {
-    uint32_t i, socketid, nr_sockets, total_rmid;
+    uint32_t i, socketid, total_rmid;
     uint32_t l3_cache_size;
-    libxl_physinfo info;
+    libxl_bitmap socketmap;
     int rc, nr_domains;
 
     if (!libxl_psr_cmt_enabled(ctx)) {
tools/libxl/xl_cmdimpl.c +0 -0
@@ -8244,41 +8244,38 @@ static int psr_cmt_show(libxl_psr_cmt_type
 type, uint32_t domid)
         return -1;
     }
 
Quoted 8 lines

tools/libxl/xl_cmdimpl.c static int psr_cmt_show(libxl_psr_cmt_type type, uint32_t domid) · line 8253

Quoted 5 lines
tools/libxl/xl_cmdimpl.c +2 -2
-    libxl_physinfo_init(&info);
-    rc = libxl_get_physinfo(ctx, &info);
+    libxl_socket_bitmap_alloc(ctx, &socketmap, 0);
+    rc = libxl_socket_bitmap_fill(ctx, &socketmap);
 

Shouldn't socketmap be initied with libxl_bitmap_init() before being allocated and used?

Yes.

Quoted 8 lines
Quoted 1 line

Not doing so is certainly not an issue, in this case, but AFAIR, we

That's my thought when I first saw this patch.

Quoted 2 lines

always require that for libxl types, don't we?

But let's stick with convention.

Sure, let's stick with it.

Chao

author
#16 lore raw

Re: [PATCH for Xen 4.6 3/5] tools/libxl: return socket id from libxl_psr_cat_get_l3_info

In reply to Wei Liu
Quoted 26 lines · Wei Liu
Quoted 25 lines · Dario Faggioli
Quoted 24 lines · Wei Liu
Quoted 15 lines · Chao Peng
tools/libxl/libxl_psr.c +2 -1
index 3378239..10e1113 100644
@@ -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);

tools/libxl/libxl_psr.c int libxl_psr_cat_get_l3_info(libxl_ctx *ctx, · line 351

Quoted 3 lines
tools/libxl/libxl_psr.c +0 -0
@@ -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.

Quoted 5 lines
Quoted 5 lines

Yep.

However, do we still need to go through libxl__count_physical_sockets() explicitly? AFAICS, you need it for allocating ptr, and for returning it back.

Not just for allocating ptr only, but also for allocating socketmap.

Quoted 7 lines
Quoted 7 lines

But since now you're building the full bitmap, we can use libxl_bitmap_count_set(), for that.

This may not be a bit deal, but if I'm not wrong, it saves us an hypercall (the PHYSINFO that libxl__count_physical_socket() issues).

I can pass 0 to libxl_socket_bitmap_alloc() but it will call hypercall internally. We need the size for the socketmap anyway before we allocating it.

Quoted 21 lines

Right, this is optimisation. I'm not too fussed either way as long as this function is functionally correct. :-)

Quoted 17 lines
Quoted 6 lines
Quoted 6 lines
tools/libxl/libxl_types.idl +0 -0
@@ -792,6 +792,7 @@ libxl_psr_cbm_type =

Enumeration("psr_cbm_type", [

     ])
Quoted 6 lines
Quoted 2 lines

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?

Yeah, we discussed this already, AFAICR. I think the point is that, at least in theory, these features may be extended to become more fine -grained than per-socket, hence the point of not binding the interface to sockets.

Quoted 7 lines
Quoted 2 lines

That being said, FWIW, I'm fine either way.

The thing that bugs me a little is that "target_id" doesn't seem very meaningful. I would just go for "id" if it is not bound to socket.

Chao, what do you think?

"id" looks right for me. I don't like "target_id" as well but just can't find out a better name :)

Chao

author
#26 lore raw
In reply to Dario Faggioli
Quoted 27 lines · Dario Faggioli
Quoted 6 lines · Wei Liu
Quoted 5 lines · Chao Peng

The patch basically contains several PSR fixes in libxl.

patch1-3: fix the socket display error in certain hotplug case.
patch4:   fix a minor range check.
patch5:   improve the PSR document.
Quoted 9 lines
Quoted 2 lines

Detailed problem and fix please see commit message.

I've gone through all patches. This series looks sensible to me. And I
see the point of getting in it for 4.6 to avoid releasing APIs that are
deemed buggy.

FWIW, I totally agree.

The patch looks sensible to me too, I've only found a couple of minor issues.

Quoted 4 lines

I would still like some more proof reading from someone who have played
with this feature. I've CCed Dario and Meng.

Thanks for pinging... I've done my best. :-)

Quoted 7 lines

About the suggestions I provided, the more important thing, IMO, is the name of the new function for retrieving the available sockets bitmap, which I really think it should be called libxl_get_online_socketmap().

The others are indeed minor things, which don't affect public APIs and hence --although I'd prefer to see them addressed-- we can fix/change them post 4.6 too.

Thanks for the quick followup from you guys. I will send another version to address these comments.

Chao

#17 lore raw

Re: [PATCH for Xen 4.6 3/5] tools/libxl: return socket id from libxl_psr_cat_get_l3_info

In reply to Chao Peng
Quoted 11 lines · Chao Peng
Quoted 9 lines · Wei Liu
Quoted 7 lines · Dario Faggioli

But since now you're building the full bitmap, we can use libxl_bitmap_count_set(), for that.

This may not be a bit deal, but if I'm not wrong, it saves us an hypercall (the PHYSINFO that libxl__count_physical_socket() issues).

Quoted 5 lines

I can pass 0 to libxl_socket_bitmap_alloc() but it will call hypercall
internally. We need the size for the socketmap anyway before we allocating it.

Yes, looking better, the number of hypercall we need seems the same in both cases. Furthermore, as Wei said, this is an internal detail / optimization that we can always look into in future, so nevermind, do as you like best.

Regards,
Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel