提交 29e74f35 编写于 作者: T Tony Luck 提交者: Thomas Gleixner

x86/intel_rdt: Add diagnostics when writing the tasks file

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: NTony Luck <tony.luck@intel.com>
Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Vikas Shivappa <vikas.shivappa@intel.com>
Cc: Boris Petkov <bp@suse.de>
Cc: Reinette Chatre <reinette.chatre@intel.com>
Link: https://lkml.kernel.org/r/f1841cce6a242aed37cb926dee8942727331bf78.1506382469.git.tony.luck@intel.com
上级 c377dcfb
...@@ -232,10 +232,8 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of, ...@@ -232,10 +232,8 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
int closid, ret = 0; int closid, ret = 0;
/* Valid input requires a trailing newline */ /* Valid input requires a trailing newline */
if (nbytes == 0 || buf[nbytes - 1] != '\n') { if (nbytes == 0 || buf[nbytes - 1] != '\n')
seq_buf_puts(&last_cmd_status, "no trailing newline\n");
return -EINVAL; return -EINVAL;
}
buf[nbytes - 1] = '\0'; buf[nbytes - 1] = '\0';
rdtgrp = rdtgroup_kn_lock_live(of->kn); rdtgrp = rdtgroup_kn_lock_live(of->kn);
......
...@@ -478,6 +478,7 @@ static int __rdtgroup_move_task(struct task_struct *tsk, ...@@ -478,6 +478,7 @@ static int __rdtgroup_move_task(struct task_struct *tsk,
*/ */
atomic_dec(&rdtgrp->waitcount); atomic_dec(&rdtgrp->waitcount);
kfree(callback); kfree(callback);
rdt_last_cmd_puts("task exited\n");
} else { } else {
/* /*
* For ctrl_mon groups move both closid and rmid. * For ctrl_mon groups move both closid and rmid.
...@@ -488,10 +489,12 @@ static int __rdtgroup_move_task(struct task_struct *tsk, ...@@ -488,10 +489,12 @@ static int __rdtgroup_move_task(struct task_struct *tsk,
tsk->closid = rdtgrp->closid; tsk->closid = rdtgrp->closid;
tsk->rmid = rdtgrp->mon.rmid; tsk->rmid = rdtgrp->mon.rmid;
} else if (rdtgrp->type == RDTMON_GROUP) { } 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; tsk->rmid = rdtgrp->mon.rmid;
else } else {
rdt_last_cmd_puts("Can't move task to different control group\n");
ret = -EINVAL; ret = -EINVAL;
}
} }
} }
return ret; return ret;
...@@ -510,8 +513,10 @@ static int rdtgroup_task_write_permission(struct task_struct *task, ...@@ -510,8 +513,10 @@ static int rdtgroup_task_write_permission(struct task_struct *task,
*/ */
if (!uid_eq(cred->euid, GLOBAL_ROOT_UID) && if (!uid_eq(cred->euid, GLOBAL_ROOT_UID) &&
!uid_eq(cred->euid, tcred->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; ret = -EPERM;
}
put_cred(tcred); put_cred(tcred);
return ret; return ret;
...@@ -528,6 +533,7 @@ static int rdtgroup_move_task(pid_t pid, struct rdtgroup *rdtgrp, ...@@ -528,6 +533,7 @@ static int rdtgroup_move_task(pid_t pid, struct rdtgroup *rdtgrp,
tsk = find_task_by_vpid(pid); tsk = find_task_by_vpid(pid);
if (!tsk) { if (!tsk) {
rcu_read_unlock(); rcu_read_unlock();
rdt_last_cmd_printf("No task %d\n", pid);
return -ESRCH; return -ESRCH;
} }
} else { } else {
...@@ -555,6 +561,7 @@ static ssize_t rdtgroup_tasks_write(struct kernfs_open_file *of, ...@@ -555,6 +561,7 @@ static ssize_t rdtgroup_tasks_write(struct kernfs_open_file *of,
if (kstrtoint(strstrip(buf), 0, &pid) || pid < 0) if (kstrtoint(strstrip(buf), 0, &pid) || pid < 0)
return -EINVAL; return -EINVAL;
rdtgrp = rdtgroup_kn_lock_live(of->kn); rdtgrp = rdtgroup_kn_lock_live(of->kn);
rdt_last_cmd_clear();
if (rdtgrp) if (rdtgrp)
ret = rdtgroup_move_task(pid, rdtgrp, of); ret = rdtgroup_move_task(pid, rdtgrp, of);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册