Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1195496

Re: [PATCH v3 2/7] locking/pvqspinlock: Add pending bit support

From Waiman Long <waiman.long@hp.com>
Newsgroups linux.kernel
Subject Re: [PATCH v3 2/7] locking/pvqspinlock: Add pending bit support
Date 2015-07-29 23:00 +0200
Message-ID <pRGCe-2tK-23@gated-at.bofh.it> (permalink)
References <pP8EG-1AI-7@gated-at.bofh.it> <pP8EH-1AI-33@gated-at.bofh.it> <pQEVQ-2Fu-3@gated-at.bofh.it> <pQUxA-i7-21@gated-at.bofh.it> <pQWpJ-329-49@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 07/27/2015 03:39 PM, Davidlohr Bueso wrote:
> On Mon, 2015-07-27 at 13:30 -0400, Waiman Long wrote:
>> The pending bit acts as a 1-slot waiting queue. So if the vCPU needs to
>> fall back to regular queuing, it needs to clear the bit.
> Right, that's what I thought. So you would also need to call
> clear_pending() as soon as the trylock/pending loop hits zero. Or am I
> missing something?
>
> /*
>   * trylock || pending
>   */
> for (;;) {
> 	...
> 	if (loop--<= 0) {
> 		clear_pending(lock);
> 		goto queue;
> 	}
> }
>
> Also, no need to check for negative loop, zero should be enough to
> breakout.

The while loop below can potentially make the loop variable become negative:


         /*
          * wait for in-progress pending->locked hand-overs
          */
         if (val == _Q_PENDING_VAL) {
                 while (((val = atomic_read(&lock->val)) == 
_Q_PENDING_VAL) &&
                         loop--)
                         cpu_relax();
         }

Cheers,
Longman
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: [PATCH v3 2/7] locking/pvqspinlock: Add pending bit support Davidlohr Bueso <dave@stgolabs.net> - 2015-07-27 03:00 +0200
  Re: [PATCH v3 2/7] locking/pvqspinlock: Add pending bit support Waiman Long <waiman.long@hp.com> - 2015-07-29 23:00 +0200

csiph-web