Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1619995

[PATCHv4] x86/intel_rdt: Add cpus_list rdtgroup file

From Jiri Olsa <jolsa@redhat.com>
Newsgroups linux.kernel
Subject [PATCHv4] x86/intel_rdt: Add cpus_list rdtgroup file
Date 2017-04-10 17:00 +0200
Message-ID <tuIXn-21C-5@gated-at.bofh.it> (permalink)
References (3 earlier) <tr77X-6xs-7@gated-at.bofh.it> <tuoch-5nt-1@gated-at.bofh.it> <tuoYF-60j-1@gated-at.bofh.it> <tuCff-6dm-7@gated-at.bofh.it> <tuE7n-7nn-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


While playing with the resctrl interface I found it much
easier to deal with cpumask list rather than just regular
cpumask.

Adding cpus_list file to provide cpumask list interface
to define group's cpus.

  # 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

Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Shaohua Li <shli@fb.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 Documentation/x86/intel_rdt_ui.txt       |  3 +++
 arch/x86/include/asm/intel_rdt.h         |  5 +++++
 arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 29 +++++++++++++++++++++++++----
 3 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/Documentation/x86/intel_rdt_ui.txt b/Documentation/x86/intel_rdt_ui.txt
index 3ea198460469..7029071e2373 100644
--- a/Documentation/x86/intel_rdt_ui.txt
+++ b/Documentation/x86/intel_rdt_ui.txt
@@ -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": A bitmask *list* 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.
diff --git a/arch/x86/include/asm/intel_rdt.h b/arch/x86/include/asm/intel_rdt.h
index 3f313991c0b3..9069402f7497 100644
--- a/arch/x86/include/asm/intel_rdt.h
+++ b/arch/x86/include/asm/intel_rdt.h
@@ -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 @@ struct rdtgroup {
  * @name: file name
  * @mode: access mode
  * @kf_ops: operations
+ * flags: 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);
diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
index 9ac2a5cdd9c2..56b5bdaf98e1 100644
--- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
+++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
@@ -174,6 +174,13 @@ static ssize_t rdtgroup_file_write(struct kernfs_open_file *of, char *buf,
 	.seq_show		= rdtgroup_seqfile_show,
 };
 
+static bool is_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_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_list(of))
+		ret = cpulist_parse(buf, newmask);
+	else
+		ret = cpumask_parse(buf, newmask);
+
 	if (ret)
 		goto unlock;
 
@@ -473,6 +486,14 @@ static int rdtgroup_tasks_show(struct kernfs_open_file *of,
 		.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,
 		.kf_ops		= &rdtgroup_kf_single_ops,
-- 
1.8.3.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] x86/intel_rdt: Add cpus_list rdtgroup file Jiri Olsa <jolsa@kernel.org> - 2017-03-29 17:20 +0200
  Re: [PATCH] x86/intel_rdt: Add cpus_list rdtgroup file Fenghua Yu <fenghua.yu@intel.com> - 2017-03-29 18:10 +0200
    Re: [PATCH] x86/intel_rdt: Add cpus_list rdtgroup file Jiri Olsa <jolsa@redhat.com> - 2017-03-29 18:20 +0200
      Re: [PATCH] x86/intel_rdt: Add cpus_list rdtgroup file Jiri Olsa <jolsa@redhat.com> - 2017-03-30 17:10 +0200
        Re: [PATCH] x86/intel_rdt: Add cpus_list rdtgroup file Fenghua Yu <fenghua.yu@intel.com> - 2017-04-01 04:00 +0200
    Re: [PATCH] x86/intel_rdt: Add cpus_list rdtgroup file Thomas Gleixner <tglx@linutronix.de> - 2017-03-31 10:50 +0200
      Re: [PATCH] x86/intel_rdt: Add cpus_list rdtgroup file Fenghua Yu <fenghua.yu@intel.com> - 2017-03-31 18:00 +0200
    Re: [PATCH] x86/intel_rdt: Add cpus_list rdtgroup file Thomas Gleixner <tglx@linutronix.de> - 2017-03-31 11:20 +0200
      Re: [PATCH] x86/intel_rdt: Add cpus_list rdtgroup file Fenghua Yu <fenghua.yu@intel.com> - 2017-03-31 17:40 +0200
      Re: [PATCH] x86/intel_rdt: Add cpus_list rdtgroup file Jiri Olsa <jolsa@redhat.com> - 2017-03-31 18:00 +0200
        [PATCHv2] x86/intel_rdt: Add cpus_list rdtgroup file Jiri Olsa <jolsa@redhat.com> - 2017-04-09 18:50 +0200
          Re: [PATCHv2] x86/intel_rdt: Add cpus_list rdtgroup file Fenghua Yu <fenghua.yu@intel.com> - 2017-04-09 19:40 +0200
            [PATCHv3] x86/intel_rdt: Add cpus_list rdtgroup file Jiri Olsa <jolsa@redhat.com> - 2017-04-10 09:50 +0200
              Re: [PATCHv3] x86/intel_rdt: Add cpus_list rdtgroup file Thomas Gleixner <tglx@linutronix.de> - 2017-04-10 11:50 +0200
                [PATCHv4] x86/intel_rdt: Add cpus_list rdtgroup file Jiri Olsa <jolsa@redhat.com> - 2017-04-10 17:00 +0200
                [tip:x86/cpu] x86/intel_rdt: Add cpus_list rdtgroup file tip-bot for Jiri Olsa <tipbot@zytor.com> - 2017-04-10 19:30 +0200
            Re: [PATCHv2] x86/intel_rdt: Add cpus_list rdtgroup file Thomas Gleixner <tglx@linutronix.de> - 2017-04-10 11:20 +0200

csiph-web