提交 d8369c52 编写于 作者: J Johannes Weiner 提交者: Joseph Qi

sched: introduce this_rq_lock_irq()

commit 246b3b3342c9b0a2e24cda2178be87bc36e1c874 upstream.

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.orgSigned-off-by: NJohannes Weiner <hannes@cmpxchg.org>
Acked-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: NSuren Baghdasaryan <surenb@google.com>
Tested-by: NDaniel 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: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
Acked-by: NCaspar Zhang <caspar@linux.alibaba.com>
上级 dc769c0e
...@@ -4933,9 +4933,7 @@ static void do_sched_yield(void) ...@@ -4933,9 +4933,7 @@ static void do_sched_yield(void)
struct rq_flags rf; struct rq_flags rf;
struct rq *rq; struct rq *rq;
local_irq_disable(); rq = this_rq_lock_irq(&rf);
rq = this_rq();
rq_lock(rq, &rf);
schedstat_inc(rq->yld_count); schedstat_inc(rq->yld_count);
current->sched_class->yield_task(rq); current->sched_class->yield_task(rq);
......
...@@ -1150,6 +1150,18 @@ rq_unlock(struct rq *rq, struct rq_flags *rf) ...@@ -1150,6 +1150,18 @@ rq_unlock(struct rq *rq, struct rq_flags *rf)
raw_spin_unlock(&rq->lock); raw_spin_unlock(&rq->lock);
} }
static inline struct rq *
this_rq_lock_irq(struct rq_flags *rf)
__acquires(rq->lock)
{
struct rq *rq;
local_irq_disable();
rq = this_rq();
rq_lock(rq, rf);
return rq;
}
#ifdef CONFIG_NUMA #ifdef CONFIG_NUMA
enum numa_topology_type { enum numa_topology_type {
NUMA_DIRECT, NUMA_DIRECT,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册