linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@kernel.org>
To: Fenghua Yu <fenghua.yu@intel.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Mike Galbraith <efault@gmx.de>, Shaohua Li <shli@fb.com>,
	lkml <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH] x86/intel_rdt: Add cpus_list rdtgroup file
Date: Wed, 29 Mar 2017 17:09:48 +0200	[thread overview]
Message-ID: <20170329150948.4981-1-jolsa@kernel.org> (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>
---
 arch/x86/include/asm/intel_rdt.h         | 16 +++++++++---
 arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 42 +++++++++++++++++++++++---------
 arch/x86/kernel/cpu/intel_rdt_schemata.c |  6 +++--
 3 files changed, 47 insertions(+), 17 deletions(-)

diff --git a/arch/x86/include/asm/intel_rdt.h b/arch/x86/include/asm/intel_rdt.h
index 0d64397cee58..0e74e58e1f23 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;
 
@@ -54,16 +57,19 @@ 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);
+			struct seq_file *sf, void *v,
+			unsigned long flags);
 	/*
 	 * write() is the generic write callback which maps directly to
 	 * kernfs write operation and overrides all other operations.
 	 * Maximum write size is determined by ->max_write_len.
 	 */
 	ssize_t (*write)(struct kernfs_open_file *of,
-			 char *buf, size_t nbytes, loff_t off);
+			 char *buf, size_t nbytes, loff_t off,
+			 unsigned long flags);
 };
 
 /**
@@ -179,9 +185,11 @@ void rdt_cbm_update(void *arg);
 struct rdtgroup *rdtgroup_kn_lock_live(struct kernfs_node *kn);
 void rdtgroup_kn_unlock(struct kernfs_node *kn);
 ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
-				char *buf, size_t nbytes, loff_t off);
+				char *buf, size_t nbytes, loff_t off,
+				unsigned long flags);
 int rdtgroup_schemata_show(struct kernfs_open_file *of,
-			   struct seq_file *s, void *v);
+			   struct seq_file *s, void *v,
+			   unsigned long flags);
 
 /*
  * intel_rdt_sched_in() - Writes the task's CLOSid to IA32_PQR_MSR
diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
index 9ac2a5cdd9c2..3a1dfb421dc5 100644
--- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
+++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
@@ -153,7 +153,7 @@ static int rdtgroup_seqfile_show(struct seq_file *m, void *arg)
 	struct rftype *rft = of->kn->priv;
 
 	if (rft->seq_show)
-		return rft->seq_show(of, m, arg);
+		return rft->seq_show(of, m, arg, rft->flags);
 	return 0;
 }
 
@@ -163,7 +163,7 @@ static ssize_t rdtgroup_file_write(struct kernfs_open_file *of, char *buf,
 	struct rftype *rft = of->kn->priv;
 
 	if (rft->write)
-		return rft->write(of, buf, nbytes, off);
+		return rft->write(of, buf, nbytes, off, rft->flags);
 
 	return -EINVAL;
 }
@@ -175,15 +175,17 @@ static struct kernfs_ops rdtgroup_kf_single_ops = {
 };
 
 static int rdtgroup_cpus_show(struct kernfs_open_file *of,
-			      struct seq_file *s, void *v)
+			      struct seq_file *s, void *v,
+			      unsigned long flags)
 {
+	const char *fmt = flags & RFTYPE_FLAGS_CPUS_LIST ? "%*pbl\n" : "%*pb\n";
 	struct rdtgroup *rdtgrp;
 	int ret = 0;
 
 	rdtgrp = rdtgroup_kn_lock_live(of->kn);
 
 	if (rdtgrp)
-		seq_printf(s, "%*pb\n", cpumask_pr_args(&rdtgrp->cpu_mask));
+		seq_printf(s, fmt, cpumask_pr_args(&rdtgrp->cpu_mask));
 	else
 		ret = -ENOENT;
 	rdtgroup_kn_unlock(of->kn);
@@ -230,7 +232,8 @@ rdt_update_closid(const struct cpumask *cpu_mask, int *closid)
 }
 
 static ssize_t rdtgroup_cpus_write(struct kernfs_open_file *of,
-				   char *buf, size_t nbytes, loff_t off)
+				   char *buf, size_t nbytes, loff_t off,
+				   unsigned long flags)
 {
 	cpumask_var_t tmpmask, newmask;
 	struct rdtgroup *rdtgrp, *r;
@@ -252,7 +255,11 @@ static ssize_t rdtgroup_cpus_write(struct kernfs_open_file *of,
 		goto unlock;
 	}
 
-	ret = cpumask_parse(buf, newmask);
+	if (flags & RFTYPE_FLAGS_CPUS_LIST)
+		ret = cpulist_parse(buf, newmask);
+	else
+		ret = cpumask_parse(buf, newmask);
+
 	if (ret)
 		goto unlock;
 
@@ -415,7 +422,8 @@ static int rdtgroup_move_task(pid_t pid, struct rdtgroup *rdtgrp,
 }
 
 static ssize_t rdtgroup_tasks_write(struct kernfs_open_file *of,
-				    char *buf, size_t nbytes, loff_t off)
+				    char *buf, size_t nbytes, loff_t off,
+				    unsigned long flags __maybe_unused)
 {
 	struct rdtgroup *rdtgrp;
 	int ret = 0;
@@ -448,7 +456,8 @@ static void show_rdt_tasks(struct rdtgroup *r, struct seq_file *s)
 }
 
 static int rdtgroup_tasks_show(struct kernfs_open_file *of,
-			       struct seq_file *s, void *v)
+			       struct seq_file *s, void *v,
+			       unsigned long flags)
 {
 	struct rdtgroup *rdtgrp;
 	int ret = 0;
@@ -473,6 +482,14 @@ static struct rftype rdtgroup_base_files[] = {
 		.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,
@@ -489,7 +506,8 @@ static struct rftype rdtgroup_base_files[] = {
 };
 
 static int rdt_num_closids_show(struct kernfs_open_file *of,
-				struct seq_file *seq, void *v)
+				struct seq_file *seq, void *v,
+				unsigned long flags __maybe_unused)
 {
 	struct rdt_resource *r = of->kn->parent->priv;
 
@@ -499,7 +517,8 @@ static int rdt_num_closids_show(struct kernfs_open_file *of,
 }
 
 static int rdt_cbm_mask_show(struct kernfs_open_file *of,
-			     struct seq_file *seq, void *v)
+			     struct seq_file *seq, void *v,
+			     unsigned long flags __maybe_unused)
 {
 	struct rdt_resource *r = of->kn->parent->priv;
 
@@ -509,7 +528,8 @@ static int rdt_cbm_mask_show(struct kernfs_open_file *of,
 }
 
 static int rdt_min_cbm_bits_show(struct kernfs_open_file *of,
-			     struct seq_file *seq, void *v)
+				 struct seq_file *seq, void *v,
+				 unsigned long flags __maybe_unused)
 {
 	struct rdt_resource *r = of->kn->parent->priv;
 
diff --git a/arch/x86/kernel/cpu/intel_rdt_schemata.c b/arch/x86/kernel/cpu/intel_rdt_schemata.c
index f369cb8db0d5..3780ebebf36c 100644
--- a/arch/x86/kernel/cpu/intel_rdt_schemata.c
+++ b/arch/x86/kernel/cpu/intel_rdt_schemata.c
@@ -132,7 +132,8 @@ static int update_domains(struct rdt_resource *r, int closid)
 }
 
 ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
-				char *buf, size_t nbytes, loff_t off)
+				char *buf, size_t nbytes, loff_t off,
+				unsigned long flags)
 {
 	struct rdtgroup *rdtgrp;
 	struct rdt_resource *r;
@@ -224,7 +225,8 @@ static void show_doms(struct seq_file *s, struct rdt_resource *r, int closid)
 }
 
 int rdtgroup_schemata_show(struct kernfs_open_file *of,
-			   struct seq_file *s, void *v)
+			   struct seq_file *s, void *v,
+			   unsigned long flags __maybe_unused)
 {
 	struct rdtgroup *rdtgrp;
 	struct rdt_resource *r;
-- 
2.9.3

             reply	other threads:[~2017-03-29 15:09 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-29 15:09 Jiri Olsa [this message]
2017-03-29 16:08 ` [PATCH] x86/intel_rdt: Add cpus_list rdtgroup file Fenghua Yu
2017-03-29 16:16   ` Jiri Olsa
2017-03-30 14:59     ` Jiri Olsa
2017-04-01  2:00       ` Fenghua Yu
2017-03-31  8:47   ` Thomas Gleixner
2017-03-31 15:53     ` Fenghua Yu
2017-03-31  9:15   ` Thomas Gleixner
2017-03-31 15:40     ` Fenghua Yu
2017-03-31 15:55     ` Jiri Olsa
2017-04-09 16:49       ` [PATCHv2] " Jiri Olsa
2017-04-09 17:38         ` Fenghua Yu
2017-04-10  7:40           ` [PATCHv3] " Jiri Olsa
2017-04-10  9:45             ` Thomas Gleixner
2017-04-10 14:52               ` [PATCHv4] " Jiri Olsa
2017-04-10 17:16                 ` [tip:x86/cpu] " tip-bot for Jiri Olsa
2017-04-10  9:14           ` [PATCHv2] " Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170329150948.4981-1-jolsa@kernel.org \
    --to=jolsa@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=efault@gmx.de \
    --cc=fenghua.yu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=shli@fb.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).