lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Fri, 3 Nov 2017 13:04:43 -0400 From: Chris Metcalf <cmetcalf@...lanox.com> To: Davidlohr Bueso <dave@...olabs.net>, Oleg Nesterov <oleg@...hat.com>, Steven Rostedt <rostedt@...dmis.org>, Ingo Molnar <mingo@...nel.org>, Peter Zijlstra <peterz@...radead.org>, Andrew Morton <akpm@...ux-foundation.org>, Rik van Riel <riel@...hat.com>, Tejun Heo <tj@...nel.org>, Frederic Weisbecker <fweisbec@...il.com>, Thomas Gleixner <tglx@...utronix.de>, "Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>, Christoph Lameter <cl@...ux.com>, Viresh Kumar <viresh.kumar@...aro.org>, Catalin Marinas <catalin.marinas@....com>, Will Deacon <will.deacon@....com>, Andy Lutomirski <luto@...capital.net>, Michal Hocko <mhocko@...e.com>, linux-kernel@...r.kernel.org Cc: Chris Metcalf <cmetcalf@...lanox.com> Subject: [PATCH v16 04/13] Add try_get_task_struct_on_cpu() to scheduler for task isolation Task isolation wants to be able to verify that a remote core is running an isolated task to determine if it should generate a diagnostic, and also possibly interrupt it. This API returns a pointer to the task_struct of the task that was running on the specified core at the moment of the request; it uses try_get_task_struct() to increment the ref count on the returned task_struct so that the caller can examine it even if the actual remote task has already exited by that point. Signed-off-by: Chris Metcalf <cmetcalf@...lanox.com> --- include/linux/sched/task.h | 1 + kernel/sched/core.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/linux/sched/task.h b/include/linux/sched/task.h index 270ff76d43d9..6785db926857 100644 --- a/include/linux/sched/task.h +++ b/include/linux/sched/task.h @@ -97,6 +97,7 @@ static inline void put_task_struct(struct task_struct *t) struct task_struct *task_rcu_dereference(struct task_struct **ptask); struct task_struct *try_get_task_struct(struct task_struct **ptask); +struct task_struct *try_get_task_struct_on_cpu(int cpu); #ifdef CONFIG_ARCH_WANTS_DYNAMIC_TASK_STRUCT diff --git a/kernel/sched/core.c b/kernel/sched/core.c index d17c5da523a0..2728154057ae 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -670,6 +670,17 @@ bool sched_can_stop_tick(struct rq *rq) } #endif /* CONFIG_NO_HZ_FULL */ +/* + * Return a pointer to the task_struct for the task that is running on + * the specified cpu at the time of the call (note that the task may have + * exited by the time the caller inspects the resulting task_struct). + * Caller must put_task_struct() with the pointer when finished with it. + */ +struct task_struct *try_get_task_struct_on_cpu(int cpu) +{ + return try_get_task_struct(&cpu_rq(cpu)->curr); +} + void sched_avg_update(struct rq *rq) { s64 period = sched_avg_period(); -- 2.1.2
Powered by blists - more mailing lists