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) <willy@infradead.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: https://lkml.kernel.org/r/20190704221323.24290-1-willy@infradead.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
parent
3c29e651e1
commit
7b3c92b85a
|
@ -105,7 +105,11 @@ extern void sched_exec(void);
|
||||||
#define sched_exec() {}
|
#define sched_exec() {}
|
||||||
#endif
|
#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);
|
extern void __put_task_struct(struct task_struct *t);
|
||||||
|
|
||||||
|
|
|
@ -4089,10 +4089,8 @@ alloc_perf_context(struct pmu *pmu, struct task_struct *task)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
__perf_event_init_context(ctx);
|
__perf_event_init_context(ctx);
|
||||||
if (task) {
|
if (task)
|
||||||
ctx->task = task;
|
ctx->task = get_task_struct(task);
|
||||||
get_task_struct(task);
|
|
||||||
}
|
|
||||||
ctx->pmu = pmu;
|
ctx->pmu = pmu;
|
||||||
|
|
||||||
return ctx;
|
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
|
* and we cannot use the ctx information because we need the
|
||||||
* pmu before we get a ctx.
|
* pmu before we get a ctx.
|
||||||
*/
|
*/
|
||||||
get_task_struct(task);
|
event->hw.target = get_task_struct(task);
|
||||||
event->hw.target = task;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
event->clock = &local_clock;
|
event->clock = &local_clock;
|
||||||
|
|
|
@ -1255,8 +1255,7 @@ setup_irq_thread(struct irqaction *new, unsigned int irq, bool secondary)
|
||||||
* the thread dies to avoid that the interrupt code
|
* the thread dies to avoid that the interrupt code
|
||||||
* references an already freed task_struct.
|
* references an already freed task_struct.
|
||||||
*/
|
*/
|
||||||
get_task_struct(t);
|
new->thread = get_task_struct(t);
|
||||||
new->thread = t;
|
|
||||||
/*
|
/*
|
||||||
* Tell the thread to set its affinity. This is
|
* Tell the thread to set its affinity. This is
|
||||||
* important for shared interrupt handlers as we do
|
* important for shared interrupt handlers as we do
|
||||||
|
|
|
@ -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 */
|
/* [10] Grab the next task, i.e. owner of @lock */
|
||||||
task = rt_mutex_owner(lock);
|
task = get_task_struct(rt_mutex_owner(lock));
|
||||||
get_task_struct(task);
|
|
||||||
raw_spin_lock(&task->pi_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 */
|
/* [10] Grab the next task, i.e. the owner of @lock */
|
||||||
task = rt_mutex_owner(lock);
|
task = get_task_struct(rt_mutex_owner(lock));
|
||||||
get_task_struct(task);
|
|
||||||
raw_spin_lock(&task->pi_lock);
|
raw_spin_lock(&task->pi_lock);
|
||||||
|
|
||||||
/* [11] requeue the pi waiters if necessary */
|
/* [11] requeue the pi waiters if necessary */
|
||||||
|
|
|
@ -579,8 +579,7 @@ probe_wakeup(void *ignore, struct task_struct *p)
|
||||||
else
|
else
|
||||||
tracing_dl = 0;
|
tracing_dl = 0;
|
||||||
|
|
||||||
wakeup_task = p;
|
wakeup_task = get_task_struct(p);
|
||||||
get_task_struct(wakeup_task);
|
|
||||||
|
|
||||||
local_save_flags(flags);
|
local_save_flags(flags);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue