[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 8/9] qspinlock: Generic paravirt support



On Thu, Mar 19, 2015 at 01:25:36PM +0100, Peter Zijlstra wrote:
> +static struct qspinlock **pv_hash(struct qspinlock *lock)
> +{
> +     u32 hash = hash_ptr(lock, PV_LOCK_HASH_BITS);
> +     struct pv_hash_bucket *hb, *end;
> +
> +     if (!hash)
> +             hash = 1;
> +
> +     hb = &__pv_lock_hash[hash_align(hash)];
> +     for (;;) {
> +             for (end = hb + PV_HB_PER_LINE; hb < end; hb++) {
> +                     if (cmpxchg(&hb->lock, NULL, HB_RESERVED)) {

That should be: !cmpxchg(), bit disturbing that that booted.

> +                             WRITE_ONCE(hb->cpu, smp_processor_id());
> +                             /*
> +                              * Since we must read lock first and cpu
> +                              * second, we must write cpu first and lock
> +                              * second, therefore use HB_RESERVE to mark an
> +                              * entry in use before writing the values.
> +                              *
> +                              * This can cause hb_hash_find() to not find a
> +                              * cpu even though _Q_SLOW_VAL, this is not a
> +                              * problem since we re-check l->locked before
> +                              * going to sleep and the unlock will have
> +                              * cleared l->locked already.
> +                              */
> +                             smp_wmb(); /* matches rmb from pv_hash_find */
> +                             WRITE_ONCE(hb->lock, lock);
> +                             goto done;
> +                     }
> +             }
> +
> +             hash = lfsr(hash, PV_LOCK_HASH_BITS);
> +             hb = &__pv_lock_hash[hash_align(hash)];
> +     }
> +
> +done:
> +     return &hb->lock;
> +}

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.