Skip to content

Commit 246b3b3

Browse files
hnaztorvalds
authored andcommitted
sched: introduce this_rq_lock_irq()
do_sched_yield() disables IRQs, looks up this_rq() and locks it. The next patch is adding another site with the same pattern, so provide a convenience function for it. Link: http://lkml.kernel.org/r/20180828172258.3185-8-hannes@cmpxchg.org Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Tested-by: Suren Baghdasaryan <surenb@google.com> Tested-by: Daniel Drake <drake@endlessm.com> Cc: Christopher Lameter <cl@linux.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Johannes Weiner <jweiner@fb.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Enderborg <peter.enderborg@sony.com> Cc: Randy Dunlap <rdunlap@infradead.org> Cc: Shakeel Butt <shakeelb@google.com> Cc: Tejun Heo <tj@kernel.org> Cc: Vinayak Menon <vinmenon@codeaurora.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 1f351d7 commit 246b3b3

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

kernel/sched/core.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4933,9 +4933,7 @@ static void do_sched_yield(void)
49334933
struct rq_flags rf;
49344934
struct rq *rq;
49354935

4936-
local_irq_disable();
4937-
rq = this_rq();
4938-
rq_lock(rq, &rf);
4936+
rq = this_rq_lock_irq(&rf);
49394937

49404938
schedstat_inc(rq->yld_count);
49414939
current->sched_class->yield_task(rq);

kernel/sched/sched.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,18 @@ rq_unlock(struct rq *rq, struct rq_flags *rf)
11571157
raw_spin_unlock(&rq->lock);
11581158
}
11591159

1160+
static inline struct rq *
1161+
this_rq_lock_irq(struct rq_flags *rf)
1162+
__acquires(rq->lock)
1163+
{
1164+
struct rq *rq;
1165+
1166+
local_irq_disable();
1167+
rq = this_rq();
1168+
rq_lock(rq, rf);
1169+
return rq;
1170+
}
1171+
11601172
#ifdef CONFIG_NUMA
11611173
enum numa_topology_type {
11621174
NUMA_DIRECT,

0 commit comments

Comments
 (0)