]> xenbits.xensource.com Git - people/sstabellini/xen-unstable.git/.git/commitdiff
tools: add support for cache coloring configuration
authorLuca Miccio <206497@studenti.unimore.it>
Wed, 21 Aug 2019 17:10:06 +0000 (19:10 +0200)
committerLuca Miccio <206497@studenti.unimore.it>
Mon, 6 Jan 2020 13:59:41 +0000 (14:59 +0100)
Add a new "colors" parameter that defines the color assignment for a
domain. The user can specify one or more color ranges using the same
syntax as the command line color selection (e.g. 0-4).
The parameter is defined as a list of strings that represent the
color ranges.

Signed-off-by: Luca Miccio <206497@studenti.unimore.it>
Signed-off-by: Marco Solieri <marco.solieri@unimore.it>
tools/libxl/libxl_arm.c
tools/libxl/libxl_types.idl
tools/xl/xl_parse.c

index c7ea493f1b8a6f7daf84a905739f010dd7d3d8ef..b6c9ab070683e412b811c8f63da97d391ff67faa 100644 (file)
@@ -102,6 +102,10 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,
         return ERROR_FAIL;
     }
 
+    xc_config->colors.max_colors = d_config->b_info.num_colors;
+    set_xen_guest_handle_raw(xc_config->colors.colors, d_config->b_info.colors);
+    LOG(DEBUG, "Setup domain colors");
+
     return 0;
 }
 
index 51f63162e87de71a6831037f62bec8bfda88b194..d236d54f231f04179ed7dea96e3b51f30fbf829a 100644 (file)
@@ -541,6 +541,7 @@ libxl_domain_build_info = Struct("domain_build_info",[
     ("ioports",          Array(libxl_ioport_range, "num_ioports")),
     ("irqs",             Array(uint32, "num_irqs")),
     ("iomem",            Array(libxl_iomem_range, "num_iomem")),
+    ("colors",           Array(uint32, "num_colors")),
     ("claim_mode",          libxl_defbool),
     ("event_channels",   uint32),
     ("kernel",           string),
index 90d709bb4cc4a6b6ef81cce9743fb9252c26a980..d0a227c678d03577f0a0fc983483e91b1b4d3f13 100644 (file)
@@ -1215,8 +1215,9 @@ void parse_config_data(const char *config_source,
                    *usbctrls, *usbdevs, *p9devs, *vdispls, *pvcallsifs_devs,
                    *sshms;
     XLU_ConfigList *channels, *ioports, *irqs, *iomem, *viridian, *dtdevs,
-                   *mca_caps;
-    int num_ioports, num_irqs, num_iomem, num_cpus, num_viridian, num_mca_caps;
+                   *mca_caps, *colors;
+    int num_ioports, num_irqs, num_iomem, num_cpus, num_viridian, num_mca_caps,
+                    num_colors;
     int pci_power_mgmt = 0;
     int pci_msitranslate = 0;
     int pci_permissive = 0;
@@ -1365,6 +1366,59 @@ void parse_config_data(const char *config_source,
     if (!xlu_cfg_get_long (config, "maxmem", &l, 0))
         b_info->max_memkb = l * 1024;
 
+    if (!xlu_cfg_get_list(config, "colors", &colors, &num_colors, 0)) {
+        int ret, k, p, cur_index;
+
+        b_info->num_colors = 0;
+        /* Get number of colors based on ranges */
+        for (i = 0; i < num_colors; i++) {
+            uint32_t start, end;
+
+            buf = xlu_cfg_get_listitem (colors, i);
+            if (!buf) {
+                fprintf(stderr,
+                    "xl: Unable to get element %d in colors range list\n", i);
+                exit(1);
+            }
+
+            ret = sscanf(buf, "%u-%u", &start, &end);
+            if (ret < 2) {
+                fprintf(stderr,
+                    "xl: Invalid argument parsing colors range: %s\n", buf);
+                exit(1);
+            }
+
+            if (start > end) {
+                fprintf(stderr,
+                    "xl: invalid range: S:%u > E:%u \n", start,end);
+                exit(1);
+            }
+
+            /*
+             * Alloc a first array and then increase its size with realloc based
+             * on the number of ranges
+             */
+
+            /* Check for overlaps */
+            for (k = start; k <= end; k++) {
+                 for (p = 0; p < b_info->num_colors; p++)
+                    if(b_info->colors[p] == k) {
+                        fprintf(stderr,
+                            "xl: overlapped ranges not allowed\n");
+                        exit(1);
+                    }
+            }
+
+            b_info->num_colors += (end - start) + 1;
+            b_info->colors = (uint32_t*)realloc(b_info->colors,
+                sizeof(*b_info->colors) * b_info->num_colors);
+
+            for (k = start, cur_index = 0; cur_index < b_info->num_colors;
+                cur_index++, k++)
+                b_info->colors[cur_index] = k;
+        }
+    }
+
     if (!xlu_cfg_get_long (config, "vcpus", &l, 0)) {
         vcpus = l;
         if (libxl_cpu_bitmap_alloc(ctx, &b_info->avail_vcpus, l)) {