lkml.org 
[lkml]   [2016]   [Jun]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] locking/osq: Drop the overload of osq lock
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_resched() || vpc != vcpu_preempt_count())
> >
> > So on PPC, we have lppaca::yield_count to detect when an vcpu is
>
> Which sounds like just the value we want.. And I suspect that on x86 KVM
> and Xen have similar numbers stashed away someplace.
>
> > 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
> >
> > if (need_resched() || vcpu_is_preempted(old))
> >
> > here, and implement vcpu_is_preempted() on PPC as
> >
> > bool vcpu_is_preempted(int cpu)
> > {
> > return !!(be32_to_cpu(lppaca_of(cpu).yield_count) & 1)
> > }
> >
> > Thoughts?
>
> 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 cumbersome, is more widely
> applicable than just the one OSQ case where we happen to have a cpu
> number.
>

But if we don't have a cpu number, which vcpu's preemption are we
trying to detect? I think the logic here is that if _this_ vcpu sees the
_owner_ vcpu is preempted, it should just stop spinning. Therefore, we
need to know the owner cpu number.

Am I missing something here?

Regards,
Boqun

[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2016-06-25 19:01    [W:0.105 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site