[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20101216184229.GA15889@redhat.com>
Date: Thu, 16 Dec 2010 19:42:29 +0100
From: Oleg Nesterov <oleg@...hat.com>
To: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc: Chris Mason <chris.mason@...cle.com>,
Frank Rowand <frank.rowand@...sony.com>,
Ingo Molnar <mingo@...e.hu>,
Thomas Gleixner <tglx@...utronix.de>,
Mike Galbraith <efault@....de>, Paul Turner <pjt@...gle.com>,
Jens Axboe <axboe@...nel.dk>, linux-kernel@...r.kernel.org
Subject: Re: [RFC][PATCH 5/5] sched: Reduce ttwu rq->lock contention
On 12/16, Peter Zijlstra wrote:
>
> +static int ttwu_force(struct task_struct *p, int wake_flags)
> +{
> + struct rq *rq;
> + int ret = 0;
> +
> + /*
> + * Since we've already set TASK_WAKING this task's CPU cannot
> + * change from under us.
I think it can. Yes, we've set TASK_WAKING. But, at least the task
itself can change its state back to TASK_RUNNING without calling
schedule. Say, __wait_event()-like code.
> +static int
> +try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
> {
> - int cpu, orig_cpu, this_cpu, success = 0;
> + int cpu = task_cpu(p);
> unsigned long flags;
> - unsigned long en_flags = ENQUEUE_WAKEUP;
> - struct rq *rq;
> + int success = 0;
> + int load;
>
> - this_cpu = get_cpu();
> -
> - smp_wmb();
> - rq = task_rq_lock(p, &flags);
> - if (!(p->state & state))
> - goto out;
> + local_irq_save(flags);
> + for (;;) {
> + unsigned int task_state = p->state;
>
> - cpu = task_cpu(p);
> + if (!(task_state & state))
> + goto out;
Well, this surely breaks the code like
CONDITION = true;
wake_up_process(p);
At least we need mb() before we check task_state the first time.
Oleg.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists