Re: [PATCH 6/8] padata: Use a timer to handle the reorder queues

Previous thread: linux-next: build failure after merge of the staging-next tree by Stephen Rothwell on Thursday, April 29, 2010 - 10:52 pm. (9 messages)

Next thread: [PATCH -next] staging/cxt1e1: use netdev_priv to fix build by Randy Dunlap on Friday, April 30, 2010 - 10:07 am. (2 messages)
From: Andrew Morton
Date: Thursday, April 29, 2010 - 4:06 pm

On Thu, 29 Apr 2010 14:43:37 +0200



Under what circumstances would "noone else do it in appropriate time"? 

I'd feel more comfortable if the above was in the locked region.  Is
there a race whereby another CPU can set pd->reorder_objects, but we
forgot to arm the timer?


--

From: Steffen Klassert
Date: Friday, April 30, 2010 - 4:20 am

We need to ensure that only one cpu can work on dequeueing of the reorder
queue the time. Calculating in which percpu reorder queue the next object
will arrive takes some time. A spinlock would be highly contended. Also
it is not clear in which order the objects arrive to the reorder queues.
So a cpu could wait to get the lock just to notice that there is nothing to
do at the moment. Therefore we use a trylock and let the holder of the
lock care for all the objects enqueued during the holdtime of the lock.

The timer is to handle a race that appears with the trylock. If cpu1 queues
an object to the reorder queue while cpu2 holds the pd->lock but left the
while loop in padata_reorder already, cpu2 can't care for this object but cpu1
exits because it can't get the lock. Usually the next cpu that takes the
lock cares for this object too. We need the timer just if this object was the
last one that arrives to the reorder queues. The timer function sends it out


We could hit the race that the timer handles, if we move this into the lock.

cpu1                            cpu2

spin_trylock_bh()
      |
      |
      |
test pd->reorder_objects == 0
delete timer
      |
hardinterrupt
      |                         set pd->reorder_objects == 1
      |                         enqueue object
      |                         spin_trylock_bh() busy
      |                         exit
      |
spin_unlock_bh()
--

From: Herbert Xu
Date: Sunday, May 2, 2010 - 8:38 pm

I've picked up patches 1-5.

Thanks!
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--

Previous thread: linux-next: build failure after merge of the staging-next tree by Stephen Rothwell on Thursday, April 29, 2010 - 10:52 pm. (9 messages)

Next thread: [PATCH -next] staging/cxt1e1: use netdev_priv to fix build by Randy Dunlap on Friday, April 30, 2010 - 10:07 am. (2 messages)