Convert get_task_struct to return the task
Subsystems (5)
PATCH 1/1 Convert get_task_struct to return the task
From: "Matthew Wilcox (Oracle)" <[email protected]>
Returning the pointer that was passed in allows us to write slightly more idiomatic code. Convert a few users.
Signed-off-by Matthew Wilcox (Oracle) <[email protected]>
--- include/linux/sched/task.h | 6 +++++- kernel/events/core.c | 9 +++------ kernel/irq/manage.c | 3 +-- kernel/locking/rtmutex.c | 6 ++---- kernel/locking/rwsem-xadd.c | 3 +-- kernel/trace/trace_sched_wakeup.c | 3 +-- 6 files changed, 13 insertions(+), 17 deletions(-)
include/linux/sched/task.h +5 -1
@@ -89,7 +89,11 @@ extern void sched_exec(void);#define sched_exec () {}#endif -#define get_task_struct (tsk) do { refcount_inc(&(tsk)->usage); } while(0) +static inline struct task_struct *get_task_struct (struct task_struct *t) +{ +refcount_inc (&t->usage); +return t; +}extern void __put_task_struct (struct task_struct *t);
kernel/events/core.c +3 -6
@@ -4082,10 +4082,8 @@ alloc_perf_context(struct pmu *pmu, struct task_struct *task)return NULL ;__perf_event_init_context (ctx); -if (task) { - ctx->task = task; -get_task_struct (task); - } +if (task) + ctx->task =get_task_struct (task); ctx->pmu = pmu;return ctx;
@@ -10324,8 +10322,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,* and we cannot use the ctx information because we need the * pmu before we get a ctx. */ -get_task_struct (task); - event->hw.target = task; + event->hw.target =get_task_struct (task); } event->clock = &local_clock;
kernel/irq/manage.c +1 -2
@@ -1229,8 +1229,7 @@ setup_irq_thread(struct irqaction *new, unsigned int irq, bool secondary)* the thread dies to avoid that the interrupt code * references an already freed task_struct. */ -get_task_struct (t); - new->thread = t; + new->thread =get_task_struct (t);/* * Tell the thread to set its affinity. This is * important for shared interrupt handlers as we do
kernel/locking/rtmutex.c +2 -4
@@ -628,8 +628,7 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task, }/* [10] Grab the next task, i.e. owner of @lock */ - task =rt_mutex_owner (lock); -get_task_struct (task); + task =get_task_struct (rt_mutex_owner (lock));raw_spin_lock (&task->pi_lock);/*
@@ -709,8 +708,7 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task, }/* [10] Grab the next task, i.e. the owner of @lock */ - task =rt_mutex_owner (lock); -get_task_struct (task); + task =get_task_struct (rt_mutex_owner (lock));raw_spin_lock (&task->pi_lock);/* [11] requeue the pi waiters if necessary */
kernel/locking/rwsem-xadd.c +1 -2
@@ -223,8 +223,7 @@ static void __rwsem_mark_wake(struct rw_semaphore *sem,list_for_each_entry_safe (waiter, tmp, &wlist, list) {struct task_struct *tsk; - tsk = waiter->task; -get_task_struct (tsk); + tsk =get_task_struct (waiter->task);/* * Ensure calling get_task_struct() before setting the reader
kernel/trace/trace_sched_wakeup.c +1 -2
@@ -579,8 +579,7 @@ probe_wakeup(void *ignore, struct task_struct *p)else tracing_dl =0 ; - wakeup_task = p; -get_task_struct (wakeup_task); + wakeup_task =get_task_struct (p);local_save_flags (flags);
Signature · 1 line
2.20.1
Peter Zijlstra
maintainerQuoted 6 lines · Matthew Wilcox
From: "Matthew Wilcox (Oracle)" <[email protected]>
Returning the pointer that was passed in allows us to write slightly more idiomatic code. Convert a few users.
Signed-off-by Matthew Wilcox (Oracle) <[email protected]>
Sure, thanks!
tip-bot for Matthew Wilcox (Oracle)
merge bot[tip:sched/core] sched/core: Convert get_task_struct() to return the task
In reply to Matthew Wilcoxsched/core: Convert get_task_struct() to return the task
Commit-ID: 7b3c92b85a65c2db1f542265bc98e1f9e3056eba Gitweb: https://git.kernel.org/tip/7b3c92b85a65c2db1f542265bc98e1f9e3056eba Author: Matthew Wilcox (Oracle) <[email protected]> AuthorDate: Thu, 4 Jul 2019 15:13:23 -0700 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 25 Jul 2019 15:51:54 +0200
sched/core: Convert get_task_struct() to return the task
Returning the pointer that was passed in allows us to write slightly more idiomatic code. Convert a few users.
Signed-off-by Matthew Wilcox (Oracle) <[email protected]>
Signed-off-by Peter Zijlstra (Intel) <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
Signed-off-by Ingo Molnar <[email protected]>
--- include/linux/sched/task.h | 6 +++++- kernel/events/core.c | 9 +++------ kernel/irq/manage.c | 3 +-- kernel/locking/rtmutex.c | 6 ++---- kernel/trace/trace_sched_wakeup.c | 3 +-- 5 files changed, 12 insertions(+), 15 deletions(-)
include/linux/sched/task.h +5 -1
@@ -105,7 +105,11 @@ extern void sched_exec(void);#define sched_exec () {}#endif -#define get_task_struct (tsk) do { refcount_inc(&(tsk)->usage); } while(0) +static inline struct task_struct *get_task_struct (struct task_struct *t) +{ +refcount_inc (&t->usage); +return t; +}extern void __put_task_struct (struct task_struct *t);
kernel/events/core.c +3 -6
@@ -4089,10 +4089,8 @@ alloc_perf_context(struct pmu *pmu, struct task_struct *task)return NULL ;__perf_event_init_context (ctx); -if (task) { - ctx->task = task; -get_task_struct (task); - } +if (task) + ctx->task =get_task_struct (task); ctx->pmu = pmu;return ctx;
@@ -10355,8 +10353,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,* and we cannot use the ctx information because we need the * pmu before we get a ctx. */ -get_task_struct (task); - event->hw.target = task; + event->hw.target =get_task_struct (task); } event->clock = &local_clock;
kernel/irq/manage.c +1 -2
@@ -1255,8 +1255,7 @@ setup_irq_thread(struct irqaction *new, unsigned int irq, bool secondary)* the thread dies to avoid that the interrupt code * references an already freed task_struct. */ -get_task_struct (t); - new->thread = t; + new->thread =get_task_struct (t);/* * Tell the thread to set its affinity. This is * important for shared interrupt handlers as we do
kernel/locking/rtmutex.c +2 -4
@@ -628,8 +628,7 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task, }/* [10] Grab the next task, i.e. owner of @lock */ - task =rt_mutex_owner (lock); -get_task_struct (task); + task =get_task_struct (rt_mutex_owner (lock));raw_spin_lock (&task->pi_lock);/*
@@ -709,8 +708,7 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task, }/* [10] Grab the next task, i.e. the owner of @lock */ - task =rt_mutex_owner (lock); -get_task_struct (task); + task =get_task_struct (rt_mutex_owner (lock));raw_spin_lock (&task->pi_lock);/* [11] requeue the pi waiters if necessary */
kernel/trace/trace_sched_wakeup.c +1 -2
@@ -579,8 +579,7 @@ probe_wakeup(void *ignore, struct task_struct *p)else tracing_dl =0 ; - wakeup_task = p; -get_task_struct (wakeup_task); + wakeup_task =get_task_struct (p);local_save_flags (flags);