From: Peter Zijlstra <peterz@infradead.org>
To: Gregory Haskins <ghaskins@novell.com>
Cc: linux-kernel@vger.kernel.org, rostedt@goodmis.org, mingo@elte.hu,
akpm@linux-foundation.org, tglx@linutronix.de
Subject: Re: [PATCH] sched: enhance the pre/post scheduling logic
Date: Thu, 30 Jul 2009 09:36:25 +0200 [thread overview]
Message-ID: <1248939385.6391.7.camel@twins> (raw)
In-Reply-To: <20090729150422.17691.55590.stgit@dev.haskins.net>
On Wed, 2009-07-29 at 11:08 -0400, Gregory Haskins wrote:
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index 3ab08e4..df14cae 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -1045,7 +1045,6 @@ struct sched_class {
> struct rq *busiest, struct sched_domain *sd,
> enum cpu_idle_type idle);
> void (*pre_schedule) (struct rq *this_rq, struct task_struct *task);
> - int (*needs_post_schedule) (struct rq *this_rq);
> void (*post_schedule) (struct rq *this_rq);
> void (*task_wake_up) (struct rq *this_rq, struct task_struct *task);
awesome, one method less ;-)
> +#ifdef CONFIG_SMP
> +
> +/* assumes rq->lock is held */
> +static inline void pre_schedule(struct rq *rq, struct task_struct *prev)
> +{
> + if (prev->sched_class->pre_schedule)
> + prev->sched_class->pre_schedule(rq, prev);
> +}
> +
> +/* rq->lock is NOT held, but preemption is disabled */
> +static inline void post_schedule(struct rq *rq)
> +{
> + if (rq->post_schedule) {
> + unsigned long flags;
> +
> + spin_lock_irqsave(&rq->lock, flags);
> + if (rq->curr->sched_class->post_schedule)
> + rq->curr->sched_class->post_schedule(rq);
> + spin_unlock_irqrestore(&rq->lock, flags);
> +
> + rq->post_schedule = 0;
> + }
> +}
> +
> +#else
>
> - return post_schedule;
> +static inline void pre_schedule(struct rq *rq, struct task_struct *p)
> +{
> +}
> +
> +static inline void post_schedule(struct rq *rq)
> +{
> }
>
> +#endif
Wouldn't you sleep much safer at night if both versions were to check
those assumptions under SCHED_DEBUG? :-)
> @@ -2844,14 +2873,14 @@ asmlinkage void schedule_tail(struct task_struct *prev)
> __releases(rq->lock)
> {
> struct rq *rq = this_rq();
> - int post_schedule;
>
> - post_schedule = finish_task_switch(rq, prev);
> + finish_task_switch(rq, prev);
>
> -#ifdef CONFIG_SMP
> - if (post_schedule)
> - current->sched_class->post_schedule(rq);
> -#endif
> + /*
> + * FIXME: do we need to worry about rq being invalidated by the
> + * task_switch?
> + */
> + post_schedule(rq);
>
> #ifdef __ARCH_WANT_UNLOCKED_CTXSW
> /* In this case, finish_task_switch does not reenable preemption */
You know I really can't take patches with FIXME's in ;-)
I think only switch_to() messes with your stacks, finish_task_switch()
should be safe, but double check me.
OK, so I stuck the patch in anyway..
next prev parent reply other threads:[~2009-07-30 7:33 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-29 4:21 [PATCH 0/2] [GIT PULL] sched: fixes for rt-migration-test failures Steven Rostedt
2009-07-29 4:21 ` [PATCH 1/2] sched: check for pushing rt tasks after all scheduling Steven Rostedt
2009-07-29 8:41 ` Peter Zijlstra
2009-07-29 13:14 ` Gregory Haskins
2009-07-29 15:08 ` [PATCH] sched: enhance the pre/post scheduling logic Gregory Haskins
2009-07-30 7:36 ` Peter Zijlstra [this message]
2009-08-02 13:13 ` [tip:sched/core] sched: Enhance " tip-bot for Gregory Haskins
2009-08-02 13:12 ` [tip:sched/core] sched: Check for pushing rt tasks after all scheduling tip-bot for Steven Rostedt
2009-07-29 4:21 ` [PATCH 2/2] sched: add new prio to cpupri before removing old prio Steven Rostedt
2009-08-02 13:13 ` [tip:sched/core] sched: Add " tip-bot for Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1248939385.6391.7.camel@twins \
--to=peterz@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=ghaskins@novell.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox