From: "Luck, Tony" <tony.luck@intel.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>,
linux-kernel@vger.kernel.org, Boris Petkov <bp@suse.de>,
Fenghua Yu <fenghua.yu@intel.com>,
Reinette Chatre <reinette.chatre@intel.com>,
Steven Rostedt <rostedt@goodmis.org>,
Vikas Shivappa <vikas.shivappa@intel.com>
Subject: [PATCH v2 3/6] x86/intel_rdt: Add diagnostics when writing the tasks file
Date: Mon, 25 Sep 2017 16:39:35 -0700 [thread overview]
Message-ID: <f1841cce6a242aed37cb926dee8942727331bf78.1506382469.git.tony.luck@intel.com> (raw)
In-Reply-To: <cover.1506382469.git.tony.luck@intel.com>
In-Reply-To: <cover.1506382469.git.tony.luck@intel.com>
From: Tony Luck <tony.luck@intel.com>
About the only tricky case is trying to move a task into a monitor
group that is a subdirectory of a different control group. But cover
the simple cases too.
Signed-off-by: Tony Luck <tony.luck@intel.com>
---
arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c | 4 +---
arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 15 +++++++++++----
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c b/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c
index f29b4c21e7d4..30aeb267cbd2 100644
--- a/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c
+++ b/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c
@@ -232,10 +232,8 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
int closid, ret = 0;
/* Valid input requires a trailing newline */
- if (nbytes == 0 || buf[nbytes - 1] != '\n') {
- seq_buf_puts(&last_cmd_status, "no trailing newline\n");
+ if (nbytes == 0 || buf[nbytes - 1] != '\n')
return -EINVAL;
- }
buf[nbytes - 1] = '\0';
rdtgrp = rdtgroup_kn_lock_live(of->kn);
diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
index 9268122eb149..df6373680a59 100644
--- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
+++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
@@ -478,6 +478,7 @@ static int __rdtgroup_move_task(struct task_struct *tsk,
*/
atomic_dec(&rdtgrp->waitcount);
kfree(callback);
+ rdt_last_cmd_puts("task exited\n");
} else {
/*
* For ctrl_mon groups move both closid and rmid.
@@ -488,10 +489,12 @@ static int __rdtgroup_move_task(struct task_struct *tsk,
tsk->closid = rdtgrp->closid;
tsk->rmid = rdtgrp->mon.rmid;
} else if (rdtgrp->type == RDTMON_GROUP) {
- if (rdtgrp->mon.parent->closid == tsk->closid)
+ if (rdtgrp->mon.parent->closid == tsk->closid) {
tsk->rmid = rdtgrp->mon.rmid;
- else
+ } else {
+ rdt_last_cmd_puts("Can't move task to different control group\n");
ret = -EINVAL;
+ }
}
}
return ret;
@@ -510,8 +513,10 @@ static int rdtgroup_task_write_permission(struct task_struct *task,
*/
if (!uid_eq(cred->euid, GLOBAL_ROOT_UID) &&
!uid_eq(cred->euid, tcred->uid) &&
- !uid_eq(cred->euid, tcred->suid))
+ !uid_eq(cred->euid, tcred->suid)) {
+ rdt_last_cmd_printf("No permission to move task %d\n", task->pid);
ret = -EPERM;
+ }
put_cred(tcred);
return ret;
@@ -528,6 +533,7 @@ static int rdtgroup_move_task(pid_t pid, struct rdtgroup *rdtgrp,
tsk = find_task_by_vpid(pid);
if (!tsk) {
rcu_read_unlock();
+ rdt_last_cmd_printf("No task %d\n", pid);
return -ESRCH;
}
} else {
@@ -555,6 +561,7 @@ static ssize_t rdtgroup_tasks_write(struct kernfs_open_file *of,
if (kstrtoint(strstrip(buf), 0, &pid) || pid < 0)
return -EINVAL;
rdtgrp = rdtgroup_kn_lock_live(of->kn);
+ rdt_last_cmd_clear();
if (rdtgrp)
ret = rdtgroup_move_task(pid, rdtgrp, of);
@@ -1208,7 +1215,7 @@ static struct dentry *rdt_mount(struct file_system_type *fs_type,
out_cdp:
cdp_disable();
out:
- seq_buf_clear(&last_cmd_status);
+ rdt_last_cmd_clear();
mutex_unlock(&rdtgroup_mutex);
return dentry;
--
2.11.0
next prev parent reply other threads:[~2017-09-25 23:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-25 23:39 [PATCH v2 0/6] x86/intel_rdt: Better diagnostics Luck, Tony
2017-09-25 23:39 ` [PATCH v2 1/6] x86/intel_rdt: Add framework for better RDT UI diagnostics Luck, Tony
2017-09-25 23:39 ` [PATCH v2 2/6] x86/intel_rdt: Add diagnostics when writing the schemata file Luck, Tony
2017-09-25 23:39 ` Luck, Tony [this message]
2017-09-25 23:39 ` [PATCH v2 4/6] x86/intel_rdt: Add diagnostics when writing the cpus file Luck, Tony
2017-09-25 23:39 ` [PATCH v2 5/6] x86/intel_rdt: Add diagnostics when making directories Luck, Tony
2017-09-25 23:39 ` [PATCH v2 6/6] x86/intel_rdt: Add documentation for "info/last_cmd_status" Luck, Tony
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=f1841cce6a242aed37cb926dee8942727331bf78.1506382469.git.tony.luck@intel.com \
--to=tony.luck@intel.com \
--cc=bp@suse.de \
--cc=fenghua.yu@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=reinette.chatre@intel.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=vikas.shivappa@intel.com \
/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
all inboxes | Powered by JetHome®