All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Rik van Riel <riel@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Avi Kiviti <avi@redhat.com>,
	Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com>,
	Mike Galbraith <efault@gmx.de>,
	Chris Wright <chrisw@sous-sol.org>,
	ttracy@redhat.com, "Nakajima, Jun" <jun.nakajima@intel.com>
Subject: Re: [RFC -v7 PATCH 4/7] Add yield_to(task, preempt) functionality.
Date: Mon, 31 Jan 2011 12:49:02 +0100	[thread overview]
Message-ID: <1296474542.15234.394.camel@laptop> (raw)
In-Reply-To: <20110126172148.32d07561@annuminas.surriel.com>

On Wed, 2011-01-26 at 17:21 -0500, Rik van Riel wrote:
> +bool __sched yield_to(struct task_struct *p, bool preempt)
> +{
> +       struct task_struct *curr = current;
> +       struct rq *rq, *p_rq;
> +       unsigned long flags;
> +       bool yielded = 0;
> +
> +       local_irq_save(flags);
> +       rq = this_rq();
> +
> +again:
> +       p_rq = task_rq(p);
> +       double_rq_lock(rq, p_rq);
> +       while (task_rq(p) != p_rq) {
> +               double_rq_unlock(rq, p_rq);
> +               goto again;
> +       }
> +
> +       if (!curr->sched_class->yield_to_task)
> +               goto out;
> +
> +       if (curr->sched_class != p->sched_class)
> +               goto out;
> +
> +       if (task_running(p_rq, p) || p->state)
> +               goto out;
> +
> +       yielded = curr->sched_class->yield_to_task(rq, p, preempt);
> +
> +out:
> +       double_rq_unlock(rq, p_rq);
> +       local_irq_restore(flags);
> +
> +       if (yielded)
> +               yield();
> +
> +       return yielded;
> +}
> +EXPORT_SYMBOL_GPL(yield_to); 

yield() will again acquire rq->lock.. not not simply have
->yield_to_task() do everything required and make that an unconditional
schedule()?

  reply	other threads:[~2011-01-31 11:48 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-26 21:56 [RFC -v7 PATCH 0/7] directed yield for Pause Loop Exiting Rik van Riel
2011-01-26 22:19 ` [RFC -v7 PATCH 2/7] sched: limit the scope of clear_buddies Rik van Riel
2011-01-26 22:19 ` [RFC -v7 PATCH 1/7] sched: check the right ->nr_running in yield_task_fair Rik van Riel
2011-01-26 22:21 ` [RFC -v7 PATCH 3/7] sched: use a buddy to implement yield_task_fair Rik van Riel
2011-01-31 11:47   ` Peter Zijlstra
2011-01-31 15:02     ` Rik van Riel
2011-01-26 22:21 ` [RFC -v7 PATCH 4/7] Add yield_to(task, preempt) functionality Rik van Riel
2011-01-31 11:49   ` Peter Zijlstra [this message]
2011-01-31 18:11     ` Rik van Riel
2011-01-26 22:23 ` [RFC -v7 PATCH 5/7] export pid symbols needed for kvm_vcpu_on_spin Rik van Riel
2011-01-31 11:51   ` Peter Zijlstra
2011-01-31 13:26     ` Avi Kivity
2011-01-31 13:43       ` Peter Zijlstra
2011-01-31 13:45         ` Avi Kivity
2011-01-26 22:24 ` [RFC -v7 PATCH 6/7] kvm: keep track of which task is running a KVM vcpu Rik van Riel
2011-01-26 22:25 ` [RFC -v7 PATCH 7/7] kvm: use yield_to instead of sleep in kvm_vcpu_on_spin Rik van Riel
2011-01-27 13:20 ` [RFC -v7 PATCH 0/7] directed yield for Pause Loop Exiting Avi Kivity

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=1296474542.15234.394.camel@laptop \
    --to=a.p.zijlstra@chello.nl \
    --cc=avi@redhat.com \
    --cc=chrisw@sous-sol.org \
    --cc=efault@gmx.de \
    --cc=jun.nakajima@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=riel@redhat.com \
    --cc=ttracy@redhat.com \
    --cc=vatsa@linux.vnet.ibm.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.