Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754918AbbBJKs0 (ORCPT ); Tue, 10 Feb 2015 05:48:26 -0500 Received: from mail7.hitachi.co.jp ([133.145.228.42]:46924 "EHLO mail7.hitachi.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750835AbbBJKsY (ORCPT ); Tue, 10 Feb 2015 05:48:24 -0500 Message-ID: <54D9E1F1.5040604@hitachi.com> Date: Tue, 10 Feb 2015 19:48:17 +0900 From: Masami Hiramatsu Organization: Hitachi, Ltd., Japan User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: Josh Poimboeuf Cc: Seth Jennings , Jiri Kosina , Vojtech Pavlik , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 5/9] sched: move task rq locking functions to sched.h References: <3f90fabd487411e694209447cf097fb0fbcce412.1423499826.git.jpoimboe@redhat.com> In-Reply-To: <3f90fabd487411e694209447cf097fb0fbcce412.1423499826.git.jpoimboe@redhat.com> Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3638 Lines: 124 (2015/02/10 2:31), Josh Poimboeuf wrote: > Move task_rq_lock/unlock() to sched.h so they can be used elsewhere. > The livepatch code needs to lock each task's rq in order to safely > examine its stack and switch it to a new patch universe. Hmm, why don't you just expose (extern in sched.h) those? Thank you, > > Signed-off-by: Josh Poimboeuf > --- > kernel/sched/core.c | 32 -------------------------------- > kernel/sched/sched.h | 33 +++++++++++++++++++++++++++++++++ > 2 files changed, 33 insertions(+), 32 deletions(-) > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index b5797b7..78d91e6 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -326,44 +326,12 @@ static inline struct rq *__task_rq_lock(struct task_struct *p) > } > } > > -/* > - * task_rq_lock - lock p->pi_lock and lock the rq @p resides on. > - */ > -static struct rq *task_rq_lock(struct task_struct *p, unsigned long *flags) > - __acquires(p->pi_lock) > - __acquires(rq->lock) > -{ > - struct rq *rq; > - > - for (;;) { > - raw_spin_lock_irqsave(&p->pi_lock, *flags); > - rq = task_rq(p); > - raw_spin_lock(&rq->lock); > - if (likely(rq == task_rq(p) && !task_on_rq_migrating(p))) > - return rq; > - raw_spin_unlock(&rq->lock); > - raw_spin_unlock_irqrestore(&p->pi_lock, *flags); > - > - while (unlikely(task_on_rq_migrating(p))) > - cpu_relax(); > - } > -} > - > static void __task_rq_unlock(struct rq *rq) > __releases(rq->lock) > { > raw_spin_unlock(&rq->lock); > } > > -static inline void > -task_rq_unlock(struct rq *rq, struct task_struct *p, unsigned long *flags) > - __releases(rq->lock) > - __releases(p->pi_lock) > -{ > - raw_spin_unlock(&rq->lock); > - raw_spin_unlock_irqrestore(&p->pi_lock, *flags); > -} > - > /* > * this_rq_lock - lock this runqueue and disable interrupts. > */ > diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h > index 9a2a45c..ae514c9 100644 > --- a/kernel/sched/sched.h > +++ b/kernel/sched/sched.h > @@ -1542,6 +1542,39 @@ static inline void double_rq_unlock(struct rq *rq1, struct rq *rq2) > > #endif > > +/* > + * task_rq_lock - lock p->pi_lock and lock the rq @p resides on. > + */ > +static inline struct rq *task_rq_lock(struct task_struct *p, > + unsigned long *flags) > + __acquires(p->pi_lock) > + __acquires(rq->lock) > +{ > + struct rq *rq; > + > + for (;;) { > + raw_spin_lock_irqsave(&p->pi_lock, *flags); > + rq = task_rq(p); > + raw_spin_lock(&rq->lock); > + if (likely(rq == task_rq(p) && !task_on_rq_migrating(p))) > + return rq; > + raw_spin_unlock(&rq->lock); > + raw_spin_unlock_irqrestore(&p->pi_lock, *flags); > + > + while (unlikely(task_on_rq_migrating(p))) > + cpu_relax(); > + } > +} > + > +static inline void task_rq_unlock(struct rq *rq, struct task_struct *p, > + unsigned long *flags) > + __releases(rq->lock) > + __releases(p->pi_lock) > +{ > + raw_spin_unlock(&rq->lock); > + raw_spin_unlock_irqrestore(&p->pi_lock, *flags); > +} > + > extern struct sched_entity *__pick_first_entity(struct cfs_rq *cfs_rq); > extern struct sched_entity *__pick_last_entity(struct cfs_rq *cfs_rq); > extern void print_cfs_stats(struct seq_file *m, int cpu); > -- Masami HIRAMATSU Software Platform Research Dept. Linux Technology Research Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: masami.hiramatsu.pt@hitachi.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/