Prev: [PATCH 5/6] Add a dummy printk function for the maintenance of unused printks
Next: [RFC] the right way to use gpiolib hooks to automate power management?
From: Tony Luck on 13 Aug 2010 19:40 Aha!. I think I found it. This embarrassing declaration in ia64's asm/atomic.h: static __inline__ int ia64_atomic64_add (__s64 i, atomic64_t *v) looks to be the key. Obviously it would be better to return all 64 bits of the answer using "long" rather than just 32 bits with "int". The critical change in the rwsem code that exposed this silliness is: - (rwsem_atomic_update(0, sem) & RWSEM_ACTIVE_MASK)) - /* Someone grabbed the sem already */ + rwsem_atomic_update(0, sem) < RWSEM_WAITING_BIAS) + /* Someone grabbed the sem for write already */ i.e. the old code only looked at the low 32-bits of the return value (RWSEM_ACTIVE_MASK is 0xffffffff) - so the truncation didn't matter. ia64_atomic64_add() has been broken like this since before the dawn of git time in 2.6.12. Obviously we haven't been using atomic64_t much. Running a new test now. 12 iterations so far (which is slightly further than this test usually gets ... but I'll let it run for a few more hours before declaring victory). -Tony -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Michel Lespinasse on 13 Aug 2010 19:50
On Fri, Aug 13, 2010 at 4:38 PM, Tony Luck <tony.luck(a)gmail.com> wrote: > Aha!. I think I found it. > > This embarrassing declaration in ia64's asm/atomic.h: > > static __inline__ int > ia64_atomic64_add (__s64 i, atomic64_t *v) > > looks to be the key. �Obviously it would be better to return all > 64 bits of the answer using "long" rather than just 32 bits with "int". Aha, good catch. Thanks for going to the bottom of this, it would have taken me forever to figure it out (and I could not test this). BTW there seems to be the same issue in ia64_atomic64_sub() too (though I wonder if that ever gets used :) -- Michel "Walken" Lespinasse A program is never fully debugged until the last user dies. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ |