]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
x86/intel_rdt: Add cpus_list rdtgroup file
authorJiri Olsa <jolsa@redhat.com>
Mon, 10 Apr 2017 14:52:32 +0000 (16:52 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Mon, 10 Apr 2017 17:10:25 +0000 (19:10 +0200)
The resource control filesystem provides only a bitmask based cpus file for
assigning CPUs to a resource group. That's cumbersome with large cpumasks
and non-intuitive when modifying the file from the command line.

Range based cpu lists are commonly used along with bitmask based cpu files
in various subsystems throughout the kernel.

Add 'cpus_list' file which is CPU range based.

  # cd /sys/fs/resctrl/
  # echo 1-10 > krava/cpus_list
  # cat krava/cpus_list
  1-10
  # cat krava/cpus
  0007fe
  # cat cpus
  fffff9
  # cat cpus_list
  0,3-23

[ tglx: Massaged changelog and replaced "bitmask lists" by "CPU ranges" ]

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Shaohua Li <shli@fb.com>
Link: http://lkml.kernel.org/r/20170410145232.GF25354@krava
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Documentation/x86/intel_rdt_ui.txt
arch/x86/include/asm/intel_rdt.h
arch/x86/kernel/cpu/intel_rdt_rdtgroup.c

index 3ea1984604697fe594cb9ea843b4603a070e86b9..a1ace91c4b86ab1c91d8c306d556f8b700d0ced2 100644 (file)
@@ -59,6 +59,9 @@ There are three files associated with each group:
        given to the default (root) group. You cannot remove CPUs
        from the default group.
 
+"cpus_list": One or more CPU ranges of logical CPUs assigned to this
+            group. Same rules apply like for the "cpus" file.
+
 "schemata": A list of all the resources available to this group.
        Each resource has its own line and format - see below for
        details.
index 9030bcccb717297fcee8858a66a064c81b4dfb4b..611c82306fdf1eb410246a381df93941426dd06b 100644 (file)
@@ -37,6 +37,9 @@ struct rdtgroup {
 /* rdtgroup.flags */
 #define        RDT_DELETED             1
 
+/* rftype.flags */
+#define RFTYPE_FLAGS_CPUS_LIST 1
+
 /* List of all resource groups */
 extern struct list_head rdt_all_groups;
 
@@ -49,6 +52,7 @@ int __init rdtgroup_init(void);
  * @name:      File name
  * @mode:      Access mode
  * @kf_ops:    File operations
+ * @flags:     File specific RFTYPE_FLAGS_* flags
  * @seq_show:  Show content of the file
  * @write:     Write to the file
  */
@@ -56,6 +60,7 @@ struct rftype {
        char                    *name;
        umode_t                 mode;
        struct kernfs_ops       *kf_ops;
+       unsigned long           flags;
 
        int (*seq_show)(struct kernfs_open_file *of,
                        struct seq_file *sf, void *v);
index c05509d38b1f1e5ed0f63940dc2c8496b360b032..8401cf5cc239fe9e36669ff26e4306b20d1e0cdb 100644 (file)
@@ -174,6 +174,13 @@ static struct kernfs_ops rdtgroup_kf_single_ops = {
        .seq_show               = rdtgroup_seqfile_show,
 };
 
+static bool is_cpu_list(struct kernfs_open_file *of)
+{
+       struct rftype *rft = of->kn->priv;
+
+       return rft->flags & RFTYPE_FLAGS_CPUS_LIST;
+}
+
 static int rdtgroup_cpus_show(struct kernfs_open_file *of,
                              struct seq_file *s, void *v)
 {
@@ -182,10 +189,12 @@ static int rdtgroup_cpus_show(struct kernfs_open_file *of,
 
        rdtgrp = rdtgroup_kn_lock_live(of->kn);
 
-       if (rdtgrp)
-               seq_printf(s, "%*pb\n", cpumask_pr_args(&rdtgrp->cpu_mask));
-       else
+       if (rdtgrp) {
+               seq_printf(s, is_cpu_list(of) ? "%*pbl\n" : "%*pb\n",
+                          cpumask_pr_args(&rdtgrp->cpu_mask));
+       } else {
                ret = -ENOENT;
+       }
        rdtgroup_kn_unlock(of->kn);
 
        return ret;
@@ -252,7 +261,11 @@ static ssize_t rdtgroup_cpus_write(struct kernfs_open_file *of,
                goto unlock;
        }
 
-       ret = cpumask_parse(buf, newmask);
+       if (is_cpu_list(of))
+               ret = cpulist_parse(buf, newmask);
+       else
+               ret = cpumask_parse(buf, newmask);
+
        if (ret)
                goto unlock;
 
@@ -472,6 +485,14 @@ static struct rftype rdtgroup_base_files[] = {
                .write          = rdtgroup_cpus_write,
                .seq_show       = rdtgroup_cpus_show,
        },
+       {
+               .name           = "cpus_list",
+               .mode           = 0644,
+               .kf_ops         = &rdtgroup_kf_single_ops,
+               .write          = rdtgroup_cpus_write,
+               .seq_show       = rdtgroup_cpus_show,
+               .flags          = RFTYPE_FLAGS_CPUS_LIST,
+       },
        {
                .name           = "tasks",
                .mode           = 0644,