Re: [PATCH] locking/osq: Drop the overload of osq lock

2016-06-27 Thread Boqun Feng
On Mon, Jun 27, 2016 at 10:09:59AM +0200, Peter Zijlstra wrote: [snip] > > No, this is entirely insane, also broken. > > No vectors, no actual function calls, nothing like that. You want the > below to completely compile away and generate the exact 100% same code > it does today. > Point taken.

Re: [PATCH] locking/osq: Drop the overload of osq lock

2016-06-27 Thread xinhui
On 2016年06月27日 15:55, Peter Zijlstra wrote: On Sun, Jun 26, 2016 at 12:59:01PM +0800, panxinhui wrote: 在 2016年6月26日,03:12,Peter Zijlstra 写道: On Sun, Jun 26, 2016 at 01:27:51AM +0800, panxinhui wrote: by the way I still think mutex_unlock has a big overload too. Do you mean overhead?

Re: [PATCH] locking/osq: Drop the overload of osq lock

2016-06-27 Thread Peter Zijlstra
On Mon, Jun 27, 2016 at 02:45:06PM +0800, Boqun Feng wrote: > +++ b/include/linux/vcpu_preempt.h > @@ -0,0 +1,82 @@ > +/* > + * Primitives for checking the vcpu preemption from the guest. > + */ > + > +static long __vcpu_preempt_count(void) > +{ > + return 0; > +} > + > +static bool __vcpu_has_

Re: [PATCH] locking/osq: Drop the overload of osq lock

2016-06-27 Thread Peter Zijlstra
On Sun, Jun 26, 2016 at 12:59:01PM +0800, panxinhui wrote: > > > 在 2016年6月26日,03:12,Peter Zijlstra 写道: > > > > On Sun, Jun 26, 2016 at 01:27:51AM +0800, panxinhui wrote: > > > >> by the way I still think mutex_unlock has a big overload too. > > > > Do you mean overhead? > > > oh, maybe you a

Re: [PATCH] locking/osq: Drop the overload of osq lock

2016-06-27 Thread xinhui
On 2016年06月27日 14:45, Boqun Feng wrote: On Sun, Jun 26, 2016 at 02:59:26PM +0800, Boqun Feng wrote: [snip] This should be: extern struct vcpu_preempt_ops vcpu_preempt_ops; And I tested this one along with modified version of Xinhui's patch. The test showed that even in a not over-committed

Re: [PATCH] locking/osq: Drop the overload of osq lock

2016-06-26 Thread Boqun Feng
On Sun, Jun 26, 2016 at 02:59:26PM +0800, Boqun Feng wrote: [snip] > > This should be: > > extern struct vcpu_preempt_ops vcpu_preempt_ops; > > And I tested this one along with modified version of Xinhui's patch. > > The test showed that even in a not over-committed system, the overhead > of mu

Re: [PATCH] locking/osq: Drop the overload of osq lock

2016-06-26 Thread panxinhui
> 在 2016年6月26日,22:11,Boqun Feng 写道: > > On Sun, Jun 26, 2016 at 02:58:00PM +0800, panxinhui wrote: > [snip] >>> >>> Unfortunately, on PPC, we compile pseries code along with powernv code >>> in a kernel binary, therefore we need to wire the proper primitives at >>> runtime. >>> >> no, we

Re: [PATCH] locking/osq: Drop the overload of osq lock

2016-06-26 Thread panxinhui
> 在 2016年6月26日,22:29,Boqun Feng 写道: > > On Sun, Jun 26, 2016 at 03:08:20PM +0800, panxinhui wrote: > [snip] >>> @@ -106,6 +109,9 @@ bool osq_lock(struct optimistic_spin_queue *lock) >>> node->prev = prev; >>> WRITE_ONCE(prev->next, node); >>> >>> + old = old - 1; >>> + vpc = vcpu_pr

Re: [PATCH] locking/osq: Drop the overload of osq lock

2016-06-26 Thread Boqun Feng
On Sun, Jun 26, 2016 at 03:08:20PM +0800, panxinhui wrote: [snip] > > @@ -106,6 +109,9 @@ bool osq_lock(struct optimistic_spin_queue *lock) > > node->prev = prev; > > WRITE_ONCE(prev->next, node); > > > > + old = old - 1; > > + vpc = vcpu_preempt_count(); > > + > > /* > > * No

Re: [PATCH] locking/osq: Drop the overload of osq lock

2016-06-26 Thread Boqun Feng
On Sun, Jun 26, 2016 at 02:58:00PM +0800, panxinhui wrote: [snip] > >> > > > > Unfortunately, on PPC, we compile pseries code along with powernv code > > in a kernel binary, therefore we need to wire the proper primitives at > > runtime. > > > no, we can use same vcpu preempted check ops actuall

Re: [PATCH] locking/osq: Drop the overload of osq lock

2016-06-26 Thread panxinhui
> 在 2016年6月26日,14:59,Boqun Feng 写道: > > On Sun, Jun 26, 2016 at 02:10:57PM +0800, Boqun Feng wrote: >> On Sun, Jun 26, 2016 at 01:21:04PM +0800, panxinhui wrote: >>> 在 2016年6月26日,03:20,Peter Zijlstra 写道: On Sun, Jun 26, 2016 at 01:27:56AM +0800, panxinhui wrote: >>> Would t

Re: [PATCH] locking/osq: Drop the overload of osq lock

2016-06-25 Thread panxinhui
> 在 2016年6月26日,14:10,Boqun Feng 写道: > > On Sun, Jun 26, 2016 at 01:21:04PM +0800, panxinhui wrote: >> >>> 在 2016年6月26日,03:20,Peter Zijlstra 写道: >>> >>> On Sun, Jun 26, 2016 at 01:27:56AM +0800, panxinhui wrote: >> Would that not have issues where the owner cpu is kept running but the

Re: [PATCH] locking/osq: Drop the overload of osq lock

2016-06-25 Thread Boqun Feng
On Sun, Jun 26, 2016 at 02:10:57PM +0800, Boqun Feng wrote: > On Sun, Jun 26, 2016 at 01:21:04PM +0800, panxinhui wrote: > > > > > 在 2016年6月26日,03:20,Peter Zijlstra 写道: > > > > > > On Sun, Jun 26, 2016 at 01:27:56AM +0800, panxinhui wrote: > > Would that not have issues where the owner cpu

Re: [PATCH] locking/osq: Drop the overload of osq lock

2016-06-25 Thread Boqun Feng
On Sun, Jun 26, 2016 at 01:21:04PM +0800, panxinhui wrote: > > > 在 2016年6月26日,03:20,Peter Zijlstra 写道: > > > > On Sun, Jun 26, 2016 at 01:27:56AM +0800, panxinhui wrote: > Would that not have issues where the owner cpu is kept running but the > spinner (ie. _this_ vcpu) gets preempted?

Re: [PATCH] locking/osq: Drop the overload of osq lock

2016-06-25 Thread panxinhui
> 在 2016年6月26日,03:20,Peter Zijlstra 写道: > > On Sun, Jun 26, 2016 at 01:27:56AM +0800, panxinhui wrote: Would that not have issues where the owner cpu is kept running but the spinner (ie. _this_ vcpu) gets preempted? I would think that in that case we too want to stop spinning. >>>

Re: [PATCH] locking/osq: Drop the overload of osq lock

2016-06-25 Thread panxinhui
> 在 2016年6月26日,03:12,Peter Zijlstra 写道: > > On Sun, Jun 26, 2016 at 01:27:51AM +0800, panxinhui wrote: > >> by the way I still think mutex_unlock has a big overload too. > > Do you mean overhead? > oh, maybe you are right. mutex_unlock ’s implementation uses inc_return variant on ppc, and

Re: [PATCH] locking/osq: Drop the overload of osq lock

2016-06-25 Thread Boqun Feng
On Sat, Jun 25, 2016 at 09:20:25PM +0200, Peter Zijlstra wrote: > On Sun, Jun 26, 2016 at 01:27:56AM +0800, panxinhui wrote: > > >> Would that not have issues where the owner cpu is kept running but the > > >> spinner (ie. _this_ vcpu) gets preempted? I would think that in that > > >> case we too w

Re: [PATCH] locking/osq: Drop the overload of osq lock

2016-06-25 Thread Peter Zijlstra
On Sat, Jun 25, 2016 at 09:20:25PM +0200, Peter Zijlstra wrote: > On Sun, Jun 26, 2016 at 01:27:56AM +0800, panxinhui wrote: > > >> Would that not have issues where the owner cpu is kept running but the > > >> spinner (ie. _this_ vcpu) gets preempted? I would think that in that > > >> case we too w

Re: [PATCH] locking/osq: Drop the overload of osq lock

2016-06-25 Thread Peter Zijlstra
On Sun, Jun 26, 2016 at 01:27:56AM +0800, panxinhui wrote: > >> Would that not have issues where the owner cpu is kept running but the > >> spinner (ie. _this_ vcpu) gets preempted? I would think that in that > >> case we too want to stop spinning. > >> > > > do you mean that the spinner detect

Re: [PATCH] locking/osq: Drop the overload of osq lock

2016-06-25 Thread Peter Zijlstra
On Sun, Jun 26, 2016 at 01:27:51AM +0800, panxinhui wrote: > by the way I still think mutex_unlock has a big overload too. Do you mean overhead?

Re: [PATCH] locking/osq: Drop the overload of osq lock

2016-06-25 Thread Peter Zijlstra
On Sun, Jun 26, 2016 at 12:28:13AM +0800, Boqun Feng wrote: > On Sat, Jun 25, 2016 at 06:09:22PM +0200, Peter Zijlstra wrote: > > That works here, but it would not work for the need_resched() in > > mutex_spin_on_owner() and mutex_optimistic_spin() which need equal > > treatment. > > > > Because t

Re: [PATCH] locking/osq: Drop the overload of osq lock

2016-06-25 Thread panxinhui
> 在 2016年6月26日,00:45,Boqun Feng 写道: > > On Sat, Jun 25, 2016 at 06:15:40PM +0200, Peter Zijlstra wrote: >> On Sat, Jun 25, 2016 at 11:21:30PM +0800, Boqun Feng wrote: >>> So on PPC, we have lppaca::yield_count to detect when an vcpu is >>> preempted, if the yield_count is even, the vcpu is runni

Re: [PATCH] locking/osq: Drop the overload of osq lock

2016-06-25 Thread panxinhui
> 在 2016年6月26日,00:13,Peter Zijlstra 写道: > > On Sat, Jun 25, 2016 at 06:09:22PM +0200, Peter Zijlstra wrote: >> That works here, but it would not work for the need_resched() in >> mutex_spin_on_owner() and mutex_optimistic_spin() which need equal >> treatment. >> >> Because those too we want to

Re: [PATCH] locking/osq: Drop the overload of osq lock

2016-06-25 Thread Boqun Feng
On Sat, Jun 25, 2016 at 06:15:40PM +0200, Peter Zijlstra wrote: > On Sat, Jun 25, 2016 at 11:21:30PM +0800, Boqun Feng wrote: > > So on PPC, we have lppaca::yield_count to detect when an vcpu is > > preempted, if the yield_count is even, the vcpu is running, otherwise it > > is preempted(__spin_yie

Re: [PATCH] locking/osq: Drop the overload of osq lock

2016-06-25 Thread Boqun Feng
On Sat, Jun 25, 2016 at 06:09:22PM +0200, Peter Zijlstra wrote: > On Sat, Jun 25, 2016 at 11:21:30PM +0800, Boqun Feng wrote: > > > > > > int vpc = vcpu_preempt_count(); > > > > > > ... > > > > > > for (;;) { > > > > > > /* the big spin loop */ > > > > > > if (need_re

Re: [PATCH] locking/osq: Drop the overload of osq lock

2016-06-25 Thread Peter Zijlstra
On Sat, Jun 25, 2016 at 11:21:30PM +0800, Boqun Feng wrote: > So on PPC, we have lppaca::yield_count to detect when an vcpu is > preempted, if the yield_count is even, the vcpu is running, otherwise it > is preempted(__spin_yield() is a user of this). > > Therefore it makes more sense we > >

Re: [PATCH] locking/osq: Drop the overload of osq lock

2016-06-25 Thread Peter Zijlstra
On Sat, Jun 25, 2016 at 06:09:22PM +0200, Peter Zijlstra wrote: > That works here, but it would not work for the need_resched() in > mutex_spin_on_owner() and mutex_optimistic_spin() which need equal > treatment. > > Because those too we want to limit. > > The count thing, while a little more cum

Re: [PATCH] locking/osq: Drop the overload of osq lock

2016-06-25 Thread Peter Zijlstra
On Sat, Jun 25, 2016 at 11:21:30PM +0800, Boqun Feng wrote: > > > > int vpc = vcpu_preempt_count(); > > > > ... > > > > for (;;) { > > > > /* the big spin loop */ > > > > if (need_resched() || vpc != vcpu_preempt_count()) > > So on PPC, we have lppaca::yiel

Re: [PATCH] locking/osq: Drop the overload of osq lock

2016-06-25 Thread Boqun Feng
On Sat, Jun 25, 2016 at 04:24:47PM +0200, Peter Zijlstra wrote: > On Sat, Jun 25, 2016 at 01:42:03PM -0400, Pan Xinhui wrote: > > An over-committed guest with more vCPUs than pCPUs has a heavy overload > > in osq_lock(). > > > > This is because vCPU A hold the osq lock and yield out, vCPU B wait >

Re: [PATCH] locking/osq: Drop the overload of osq lock

2016-06-25 Thread Peter Zijlstra
On Sat, Jun 25, 2016 at 01:42:03PM -0400, Pan Xinhui wrote: > An over-committed guest with more vCPUs than pCPUs has a heavy overload > in osq_lock(). > > This is because vCPU A hold the osq lock and yield out, vCPU B wait > per_cpu node->locked to be set. IOW, vCPU B wait vCPU A to run and > unlo

[PATCH] locking/osq: Drop the overload of osq lock

2016-06-25 Thread Pan Xinhui
An over-committed guest with more vCPUs than pCPUs has a heavy overload in osq_lock(). This is because vCPU A hold the osq lock and yield out, vCPU B wait per_cpu node->locked to be set. IOW, vCPU B wait vCPU A to run and unlock the osq lock. Even there is need_resched(), it did not help on such s