Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2016-04-14 Thread Peter Zijlstra
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

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2016-04-14 Thread Peter Zijlstra
On Tue, Sep 02, 2014 at 02:31:53PM +0800, Jason Wang wrote: > Yes, but current code can not do this. In most of the cases, the new > woke up process have no chance to run if another process is busy loop in > the same cpu. That sounds weird; a process that slept will have an effective vruntime defi

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2016-04-13 Thread Michael S. Tsirkin
On Wed, Apr 13, 2016 at 03:28:03PM +0200, Peter Zijlstra wrote: > On Mon, Apr 11, 2016 at 07:31:57PM +0300, Michael S. Tsirkin wrote: > > +static bool expected_to_run_fair(struct cfs_rq *cfs_rq, s64 t) > > +{ > > + struct sched_entity *left; > > + struct sched_entity *curr = cfs_rq->cur

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2016-04-13 Thread Peter Zijlstra
On Mon, Apr 11, 2016 at 07:31:57PM +0300, Michael S. Tsirkin wrote: > +static bool expected_to_run_fair(struct cfs_rq *cfs_rq, s64 t) > +{ > + struct sched_entity *left; > + struct sched_entity *curr = cfs_rq->curr; > + > + if (!curr || !curr->on_rq) > + return false

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2016-04-13 Thread Ingo Molnar
* Michael S. Tsirkin wrote: > On Fri, Aug 22, 2014 at 09:36:53AM +0200, Ingo Molnar wrote: > > > > > > diff --git a/include/net/busy_poll.h b/include/net/busy_poll.h > > > > index 1d67fb6..8a33fb2 100644 > > > > --- a/include/net/busy_poll.h > > > > +++ b/include/net/busy_poll.h > > > > @@ -109

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2016-04-11 Thread Michael S. Tsirkin
On Fri, Aug 22, 2014 at 09:36:53AM +0200, Ingo Molnar wrote: > > > > diff --git a/include/net/busy_poll.h b/include/net/busy_poll.h > > > index 1d67fb6..8a33fb2 100644 > > > --- a/include/net/busy_poll.h > > > +++ b/include/net/busy_poll.h > > > @@ -109,7 +109,8 @@ static inline bool sk_busy_loop(

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-09-04 Thread Michael S. Tsirkin
On Thu, Sep 04, 2014 at 09:51:33AM +0300, Eliezer Tamir wrote: > On 03/09/2014 10:51, Michael S. Tsirkin wrote: > > On Wed, Sep 03, 2014 at 09:49:10AM +0300, Eliezer Tamir wrote: > >> On 02/09/2014 11:31, Michael S. Tsirkin wrote: > >>> On Tue, Sep 02, 2014 at 09:15:18AM +0300, Eliezer Tamir wrote:

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-09-03 Thread Eliezer Tamir
On 03/09/2014 10:51, Michael S. Tsirkin wrote: > On Wed, Sep 03, 2014 at 09:49:10AM +0300, Eliezer Tamir wrote: >> On 02/09/2014 11:31, Michael S. Tsirkin wrote: >>> On Tue, Sep 02, 2014 at 09:15:18AM +0300, Eliezer Tamir wrote: >> Busy polling is not a general purpose feature, it's not something

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-09-03 Thread Michael S. Tsirkin
On Wed, Sep 03, 2014 at 11:36:05AM +0200, Peter Zijlstra wrote: > On Wed, Sep 03, 2014 at 03:33:23PM +0800, Jason Wang wrote: > > A new issue is for virt users. I implement busy polling for virtio-net > > but we don't want one vcpu monopoly the cpu if there's some tasks on > > other vcpus. We may n

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-09-03 Thread Peter Zijlstra
On Wed, Sep 03, 2014 at 03:33:23PM +0800, Jason Wang wrote: > A new issue is for virt users. I implement busy polling for virtio-net > but we don't want one vcpu monopoly the cpu if there's some tasks on > other vcpus. We may need some hint from host to guest to let it exit the > loop if needed. A

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-09-03 Thread Peter Zijlstra
On Wed, Sep 03, 2014 at 02:58:33PM +0800, Jason Wang wrote: > On 09/02/2014 06:24 PM, Peter Zijlstra wrote: > The patch only try to improve the performance of busy read (and test > results shows impressive changes). It does not change anything for busy > poll. Considering there maybe two processes

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-09-03 Thread Michael S. Tsirkin
On Fri, Aug 22, 2014 at 09:36:53AM +0200, Ingo Molnar wrote: > > > > diff --git a/include/net/busy_poll.h b/include/net/busy_poll.h > > > index 1d67fb6..8a33fb2 100644 > > > --- a/include/net/busy_poll.h > > > +++ b/include/net/busy_poll.h > > > @@ -109,7 +109,8 @@ static inline bool sk_busy_loop(

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-09-03 Thread Michael S. Tsirkin
On Wed, Sep 03, 2014 at 09:49:10AM +0300, Eliezer Tamir wrote: > On 02/09/2014 11:31, Michael S. Tsirkin wrote: > > On Tue, Sep 02, 2014 at 09:15:18AM +0300, Eliezer Tamir wrote: > >> On 02/09/2014 06:29, Jason Wang wrote: > >>> On 09/01/2014 02:39 PM, Eliezer Tamir wrote: > On 29/08/2014 06:0

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-09-03 Thread Jason Wang
On 09/03/2014 02:49 PM, Eliezer Tamir wrote: > On 02/09/2014 11:31, Michael S. Tsirkin wrote: >> On Tue, Sep 02, 2014 at 09:15:18AM +0300, Eliezer Tamir wrote: >>> On 02/09/2014 06:29, Jason Wang wrote: On 09/01/2014 02:39 PM, Eliezer Tamir wrote: > On 29/08/2014 06:08, Jason Wang wrote: >

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-09-03 Thread Jason Wang
On 09/03/2014 02:21 PM, Eliezer Tamir wrote: > On 02/09/2014 09:31, Jason Wang wrote: >> On 09/02/2014 02:03 PM, Eliezer Tamir wrote: >>> On 02/09/2014 06:35, Jason Wang wrote: Not sure whether this method will scale considering thousands of sockets and processes. >>> There may be million

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-09-03 Thread Jason Wang
On 09/02/2014 06:24 PM, Peter Zijlstra wrote: > On Tue, Sep 02, 2014 at 12:03:42PM +0800, Jason Wang wrote: >> > On 09/01/2014 06:19 PM, Peter Zijlstra wrote: >>> > > OK I suppose that more or less makes sense, the contextual behaviour is >>> > > of course tedious in that it makes behaviour less pr

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-09-02 Thread Eliezer Tamir
On 02/09/2014 11:31, Michael S. Tsirkin wrote: > On Tue, Sep 02, 2014 at 09:15:18AM +0300, Eliezer Tamir wrote: >> On 02/09/2014 06:29, Jason Wang wrote: >>> On 09/01/2014 02:39 PM, Eliezer Tamir wrote: On 29/08/2014 06:08, Jason Wang wrote: >> Yes, but rx busy polling only works in proces

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-09-02 Thread Eliezer Tamir
On 02/09/2014 09:31, Jason Wang wrote: > On 09/02/2014 02:03 PM, Eliezer Tamir wrote: >> On 02/09/2014 06:35, Jason Wang wrote: >>> Not sure whether this method will scale considering thousands of sockets >>> and processes. >> There may be millions of sockets, but in most cases only a handful of >>

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-09-02 Thread Peter Zijlstra
On Tue, Sep 02, 2014 at 12:03:42PM +0800, Jason Wang wrote: > On 09/01/2014 06:19 PM, Peter Zijlstra wrote: > > OK I suppose that more or less makes sense, the contextual behaviour is > > of course tedious in that it makes behaviour less predictable. The > > 'other' tasks might not want to generate

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-09-02 Thread Michael S. Tsirkin
On Tue, Sep 02, 2014 at 09:15:18AM +0300, Eliezer Tamir wrote: > On 02/09/2014 06:29, Jason Wang wrote: > > On 09/01/2014 02:39 PM, Eliezer Tamir wrote: > >> On 29/08/2014 06:08, Jason Wang wrote: > Yes, but rx busy polling only works in process context and does not > disable bh, so it ma

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-09-02 Thread Jason Wang
On 09/02/2014 02:15 PM, Eliezer Tamir wrote: > On 02/09/2014 06:29, Jason Wang wrote: >> On 09/01/2014 02:39 PM, Eliezer Tamir wrote: >>> On 29/08/2014 06:08, Jason Wang wrote: > Yes, but rx busy polling only works in process context and does not > disable bh, so it may be not an issue. >>>

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-09-02 Thread Jason Wang
On 09/02/2014 02:12 PM, Peter Zijlstra wrote: > On Tue, Sep 02, 2014 at 11:38:40AM +0800, Jason Wang wrote: >> > I see, how about just exporting a boolean helper like >> > current_can_busy_loop() and take care all of the conditions (pending bhs >> > and rcu callbacks, runnable processes) in schedul

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-09-01 Thread Jason Wang
On 09/02/2014 02:03 PM, Eliezer Tamir wrote: > On 02/09/2014 06:35, Jason Wang wrote: >> On 09/01/2014 02:55 PM, Eliezer Tamir wrote: >>> On 26/08/2014 10:16, Jason Wang wrote: On 08/25/2014 09:16 PM, Eliezer Tamir wrote: >>> Think about the case where two processes are busy polling on the >>>

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-09-01 Thread Eliezer Tamir
On 02/09/2014 06:29, Jason Wang wrote: > On 09/01/2014 02:39 PM, Eliezer Tamir wrote: >> On 29/08/2014 06:08, Jason Wang wrote: Yes, but rx busy polling only works in process context and does not disable bh, so it may be not an issue. >> sk_busy_loop() uses rcu_read_lock_bh(), so it does

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-09-01 Thread Peter Zijlstra
On Tue, Sep 02, 2014 at 11:38:40AM +0800, Jason Wang wrote: > I see, how about just exporting a boolean helper like > current_can_busy_loop() and take care all of the conditions (pending bhs > and rcu callbacks, runnable processes) in scheduler code itself? How is that going to help the cases that

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-09-01 Thread Eliezer Tamir
On 02/09/2014 06:35, Jason Wang wrote: > On 09/01/2014 02:55 PM, Eliezer Tamir wrote: >> On 26/08/2014 10:16, Jason Wang wrote: >>> On 08/25/2014 09:16 PM, Eliezer Tamir wrote: >> Think about the case where two processes are busy polling on the >> same CPU and the same device queue. Since busy pol

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-09-01 Thread Jason Wang
On 09/01/2014 06:19 PM, Peter Zijlstra wrote: > On Mon, Sep 01, 2014 at 12:04:34PM +0200, Peter Zijlstra wrote: >> > On Mon, Sep 01, 2014 at 12:52:19PM +0300, Michael S. Tsirkin wrote: >>> > > On Mon, Sep 01, 2014 at 11:31:59AM +0200, Peter Zijlstra wrote: > > > On Fri, Aug 22, 2014 at 07:01:0

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-09-01 Thread Jason Wang
On 09/01/2014 06:04 PM, Peter Zijlstra wrote: > On Mon, Sep 01, 2014 at 12:52:19PM +0300, Michael S. Tsirkin wrote: >> On Mon, Sep 01, 2014 at 11:31:59AM +0200, Peter Zijlstra wrote: >>> On Fri, Aug 22, 2014 at 07:01:05AM +0200, Mike Galbraith wrote: > +++ b/include/net/busy_poll.h > @@ -10

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-09-01 Thread Jason Wang
On 09/01/2014 02:55 PM, Eliezer Tamir wrote: > On 26/08/2014 10:16, Jason Wang wrote: >> On 08/25/2014 09:16 PM, Eliezer Tamir wrote: >>> Here are my 2 cents: >>> I think Ingo's suggestion of only yielding to tasks with same or higher >>> priority makes sense. >> I'm not sure I get your meaning. Do

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-09-01 Thread Jason Wang
On 09/01/2014 02:39 PM, Eliezer Tamir wrote: > On 29/08/2014 06:08, Jason Wang wrote: >> > Yes, but rx busy polling only works in process context and does not >> > disable bh, so it may be not an issue. > sk_busy_loop() uses rcu_read_lock_bh(), so it does run with bh disabled. > > -Eliezer True, s

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-09-01 Thread Michael S. Tsirkin
On Mon, Sep 01, 2014 at 12:04:34PM +0200, Peter Zijlstra wrote: > On Mon, Sep 01, 2014 at 12:52:19PM +0300, Michael S. Tsirkin wrote: > > On Mon, Sep 01, 2014 at 11:31:59AM +0200, Peter Zijlstra wrote: > > > On Fri, Aug 22, 2014 at 07:01:05AM +0200, Mike Galbraith wrote: > > > > > +++ b/include/net

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-09-01 Thread Peter Zijlstra
On Mon, Sep 01, 2014 at 12:04:34PM +0200, Peter Zijlstra wrote: > On Mon, Sep 01, 2014 at 12:52:19PM +0300, Michael S. Tsirkin wrote: > > On Mon, Sep 01, 2014 at 11:31:59AM +0200, Peter Zijlstra wrote: > > > On Fri, Aug 22, 2014 at 07:01:05AM +0200, Mike Galbraith wrote: > > > > > +++ b/include/net

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-09-01 Thread Peter Zijlstra
On Mon, Sep 01, 2014 at 12:52:19PM +0300, Michael S. Tsirkin wrote: > On Mon, Sep 01, 2014 at 11:31:59AM +0200, Peter Zijlstra wrote: > > On Fri, Aug 22, 2014 at 07:01:05AM +0200, Mike Galbraith wrote: > > > > +++ b/include/net/busy_poll.h > > > > @@ -109,7 +109,8 @@ static inline bool sk_busy_loop

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-09-01 Thread Michael S. Tsirkin
On Mon, Sep 01, 2014 at 11:31:59AM +0200, Peter Zijlstra wrote: > On Fri, Aug 22, 2014 at 07:01:05AM +0200, Mike Galbraith wrote: > > > +++ b/include/net/busy_poll.h > > > @@ -109,7 +109,8 @@ static inline bool sk_busy_loop(struct sock *sk, int > > > nonblock) > > > cpu_relax(); > > >

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-09-01 Thread Peter Zijlstra
On Fri, Aug 22, 2014 at 07:01:05AM +0200, Mike Galbraith wrote: > > +++ b/include/net/busy_poll.h > > @@ -109,7 +109,8 @@ static inline bool sk_busy_loop(struct sock *sk, int > > nonblock) > > cpu_relax(); > > > > } while (!nonblock && skb_queue_empty(&sk->sk_receive_queue) && >

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-08-31 Thread Eliezer Tamir
On 26/08/2014 10:16, Jason Wang wrote: > On 08/25/2014 09:16 PM, Eliezer Tamir wrote: >> Here are my 2 cents: >> I think Ingo's suggestion of only yielding to tasks with same or higher >> priority makes sense. > > I'm not sure I get your meaning. Do you mean calling yield_to() directly > in sk_bus

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-08-31 Thread Eliezer Tamir
On 29/08/2014 06:08, Jason Wang wrote: > Yes, but rx busy polling only works in process context and does not > disable bh, so it may be not an issue. sk_busy_loop() uses rcu_read_lock_bh(), so it does run with bh disabled. -Eliezer -- To unsubscribe from this list: send the line "unsubscribe lin

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-08-28 Thread Jason Wang
On 08/22/2014 03:42 PM, Ingo Molnar wrote: > * Jason Wang wrote: > >> Polling could be done by either rx busy loop in process >> context or NAPI in softirq. [...] > Note that this shows another reason why it's a bad idea to > query nr_running directly: depending on the softirq processing > meth

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-08-26 Thread Jason Wang
On 08/25/2014 09:16 PM, Eliezer Tamir wrote: > On 22/08/2014 17:16, Eric Dumazet wrote: >> > On Fri, 2014-08-22 at 17:08 +0800, Jason Wang wrote: >> > >>> >> But this is just for current process. We want to determine whether or >>> >> not it was worth to loop busily in current process by checking

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-08-25 Thread Eliezer Tamir
On 22/08/2014 17:16, Eric Dumazet wrote: > On Fri, 2014-08-22 at 17:08 +0800, Jason Wang wrote: > >> But this is just for current process. We want to determine whether or >> not it was worth to loop busily in current process by checking if >> there's any another runnable processes or callbacks. An

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-08-24 Thread Jason Wang
On 08/22/2014 10:16 PM, Eric Dumazet wrote: > On Fri, 2014-08-22 at 17:08 +0800, Jason Wang wrote: > >> > But this is just for current process. We want to determine whether or >> > not it was worth to loop busily in current process by checking if >> > there's any another runnable processes or callb

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-08-22 Thread Eric Dumazet
On Fri, 2014-08-22 at 17:08 +0800, Jason Wang wrote: > But this is just for current process. We want to determine whether or > not it was worth to loop busily in current process by checking if > there's any another runnable processes or callbacks. And what we need > here is just a simple and lockl

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-08-22 Thread Jason Wang
On 08/22/2014 03:36 PM, Ingo Molnar wrote: >>> diff --git a/include/net/busy_poll.h b/include/net/busy_poll.h >>> index 1d67fb6..8a33fb2 100644 >>> --- a/include/net/busy_poll.h >>> +++ b/include/net/busy_poll.h >>> @@ -109,7 +109,8 @@ static inline bool sk_busy_loop(struct sock *sk, int >>> nonbl

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-08-22 Thread Ingo Molnar
* Jason Wang wrote: > Polling could be done by either rx busy loop in process > context or NAPI in softirq. [...] Note that this shows another reason why it's a bad idea to query nr_running directly: depending on the softirq processing method, a softirq might run: - directly in process con

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-08-22 Thread Ingo Molnar
> > diff --git a/include/net/busy_poll.h b/include/net/busy_poll.h > > index 1d67fb6..8a33fb2 100644 > > --- a/include/net/busy_poll.h > > +++ b/include/net/busy_poll.h > > @@ -109,7 +109,8 @@ static inline bool sk_busy_loop(struct sock *sk, int > > nonblock) > > cpu_relax(); > > >

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-08-22 Thread Jason Wang
On 08/22/2014 01:01 PM, Mike Galbraith wrote: > On Thu, 2014-08-21 at 16:05 +0800, Jason Wang wrote: >> > Rx busy loop does not scale well in the case when several parallel >> > sessions is active. This is because we keep looping even if there's >> > another process is runnable. For example, if th

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-08-21 Thread Mike Galbraith
On Thu, 2014-08-21 at 16:05 +0800, Jason Wang wrote: > Rx busy loop does not scale well in the case when several parallel > sessions is active. This is because we keep looping even if there's > another process is runnable. For example, if that process is about to > send packet, keep busy polling i

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-08-21 Thread Jason Wang
On 08/21/2014 04:11 PM, Michael S. Tsirkin wrote: > On Thu, Aug 21, 2014 at 04:05:10PM +0800, Jason Wang wrote: >> > Rx busy loop does not scale well in the case when several parallel >> > sessions is active. This is because we keep looping even if there's >> > another process is runnable. For exam

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-08-21 Thread Amos Kong
On Thu, Aug 21, 2014 at 04:05:10PM +0800, Jason Wang wrote: > Rx busy loop does not scale well in the case when several parallel > sessions is active. This is because we keep looping even if there's > another process is runnable. For example, if that process is about to > send packet, keep busy pol

Re: [PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-08-21 Thread Michael S. Tsirkin
On Thu, Aug 21, 2014 at 04:05:10PM +0800, Jason Wang wrote: > Rx busy loop does not scale well in the case when several parallel > sessions is active. This is because we keep looping even if there's > another process is runnable. For example, if that process is about to > send packet, keep busy pol

[PATCH net-next 2/2] net: exit busy loop when another process is runnable

2014-08-21 Thread Jason Wang
Rx busy loop does not scale well in the case when several parallel sessions is active. This is because we keep looping even if there's another process is runnable. For example, if that process is about to send packet, keep busy polling in current process will brings extra delay and damage the perfo