All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Ingo Molnar <mingo@kernel.org>,
	Mike Galbraith <umgwanakikbuti@gmail.com>,
	Jason Wang <jasowang@redhat.com>,
	davem@davemloft.net, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>
Subject: Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable
Date: Thu, 14 Apr 2016 02:58:35 +0200	[thread overview]
Message-ID: <20160414005835.GB2975@worktop.cust.blueprintrf.com> (raw)
In-Reply-To: <20160413163940-mutt-send-email-mst@redhat.com>

On Wed, Apr 13, 2016 at 04:51:36PM +0300, Michael S. Tsirkin wrote:
> On Wed, Apr 13, 2016 at 03:28:03PM +0200, Peter Zijlstra wrote:

> > Nope, not true. Current isn't actually in the tree, and any other task
> > is subject to being moved at any time.
> > Even if current was in the tree, there is no guarantee it is
> > ->rb_leftmost; imagine a task being migrated in that has a smaller
> > vruntime.
> > 
> > So this really cannot work without locks :/
> > 
> > I've not thought about the actual problem you're trying to solve; but I
> > figured I'd let you know this before you continue down this path.

> static bool expected_to_run_fair(struct cfs_rq *cfs_rq, struct task_struct *task, s64 t)
> {
>        struct sched_entity *left;
>        struct sched_entity *curr = &task->se;
>        if (!curr || !curr->on_rq)
>               return false;
> 
>        left = __pick_first_entity(cfs_rq);
>        if (!left)
>                return true;
> 
>        return (s64)(curr->vruntime + calc_delta_fair(t, curr) -
>                     left->vruntime) < 0;
> }
> 
> Left here is on tree so it's not going away, right?

No, left is the leftmost entry on the tree, it can go away at any time.
You cannot touch the tree without locks.

Someone can come an migrate the task to another CPU, start executing it
and it can die between you finding the left pointer and dereferencing
it.

  reply	other threads:[~2016-04-14 15:28 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-21  8:05 [PATCH net-next 1/2] sched: introduce nr_running_this_cpu() Jason Wang
2014-08-21  8:05 ` [PATCH net-next 2/2] net: exit busy loop when another process is runnable Jason Wang
2014-08-21  8:11   ` Michael S. Tsirkin
2014-08-22  2:53     ` Jason Wang
2014-08-21 19:03   ` Amos Kong
2014-08-22  5:01   ` Mike Galbraith
2014-08-22  7:29     ` Jason Wang
2014-08-22  7:42       ` Ingo Molnar
2014-08-29  3:08         ` Jason Wang
2014-09-01  6:39           ` Eliezer Tamir
2014-09-02  3:29             ` Jason Wang
2014-09-02  6:15               ` Eliezer Tamir
2014-09-02  7:37                 ` Jason Wang
2014-09-02  8:31                 ` Michael S. Tsirkin
2014-09-03  6:49                   ` Eliezer Tamir
2014-09-03  7:33                     ` Jason Wang
2014-09-03  9:36                       ` Peter Zijlstra
2014-09-03  9:59                         ` Michael S. Tsirkin
2014-09-03  7:51                     ` Michael S. Tsirkin
2014-09-04  6:51                       ` Eliezer Tamir
2014-09-04  8:25                         ` Michael S. Tsirkin
2014-08-22  7:36     ` Ingo Molnar
2014-08-22  9:08       ` Jason Wang
2014-08-22 14:16         ` Eric Dumazet
2014-08-25  2:54           ` Jason Wang
2014-08-25 13:16           ` Eliezer Tamir
2014-08-26  7:16             ` Jason Wang
2014-09-01  6:55               ` Eliezer Tamir
2014-09-02  3:35                 ` Jason Wang
2014-09-02  6:03                   ` Eliezer Tamir
2014-09-02  6:31                     ` Jason Wang
2014-09-03  6:21                       ` Eliezer Tamir
2014-09-03  6:59                         ` Jason Wang
2016-04-14  0:55                       ` Peter Zijlstra
2014-09-03  8:09       ` Michael S. Tsirkin
2016-04-11 16:31       ` Michael S. Tsirkin
2016-04-13  7:20         ` Ingo Molnar
2016-04-13 13:28         ` Peter Zijlstra
2016-04-13 13:51           ` Michael S. Tsirkin
2016-04-14  0:58             ` Peter Zijlstra [this message]
2014-09-01  9:31     ` Peter Zijlstra
2014-09-01  9:52       ` Michael S. Tsirkin
2014-09-01 10:04         ` Peter Zijlstra
2014-09-01 10:19           ` Peter Zijlstra
2014-09-02  4:03             ` Jason Wang
2014-09-02 10:24               ` Peter Zijlstra
2014-09-03  6:58                 ` Jason Wang
2014-09-03  9:30                   ` Peter Zijlstra
2014-09-01 10:22           ` Michael S. Tsirkin
2014-09-02  3:38           ` Jason Wang
2014-09-02  6:12             ` Peter Zijlstra
2014-09-02  7:19               ` Jason Wang
2014-08-21 13:52 ` [PATCH net-next 1/2] sched: introduce nr_running_this_cpu() Ingo Molnar
2014-08-22  7:27   ` Jason Wang

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=20160414005835.GB2975@worktop.cust.blueprintrf.com \
    --to=peterz@infradead.org \
    --cc=davem@davemloft.net \
    --cc=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mingo@kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=umgwanakikbuti@gmail.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.