On Sunday 07 July 2002 12.51, Patrick Schaaf wrote:
> Just spotted one more thing, rediff appended. Now that I've saved
> some horizontal screen real estate, the drop error can be
> single-line again...

drop_next should most likely be made voilatile to protect from 
compiler optimization evilness, and you may need to care for 
alignment etc.... using atomic_t as proposed earlier feels like a 
good bet.

   static atomic_t drop_next = ATOMIC_INIT(0);
   int victim = atomic_read(&drop_next);
   int next = victim + 1;
   atomic_set(&drop_next, (next < ip_conntrack_htable_size) ? next : 
0);

To other readers: We do not need to SMP synchronize here.. only SMP 
criteria is that the value cannot be badly corrupted by concurrent 
read/write to produce a invalid reading. It does not matter if a few 
(or even many) iterations of drop_next is lost/forgotten/skipped.

Regards
Henrik

Reply via email to