Opened 12 years ago

Closed 11 years ago

#5331 closed Bugs (fixed)

usage of deprecated swp instruction on arm

Reported by: Boaz Ben-David <boaz.bd@…> Owned by: Peter Dimov
Milestone: To Be Determined Component: smart_ptr
Version: Boost 1.50.0 Severity: Problem
Keywords: arm deprecated Cc:

Description

Hi,

In smart_ptr/detail/spinlock_gcc_arm.hpp There is use of the deprecated swp instruction (for armv6 and above). This emits warning when compiling and also is supposed to have performance penalty on SMP platforms.

Can this be fixed using new instructions (ldrex etc..) ?

Thanks.

Boaz

Attachments (2)

arm_spinlock_fix.patch (1.2 KB ) - added by abel@… 11 years ago.
Proposed patch for strex and ldrex usage on AMR 6 and ARM7.
arm_spinlock_fix.2.patch (1.3 KB ) - added by abel@… 11 years ago.
[Fixed] Proposed patch for strex and ldrex usage on AMR 6 and ARM7.

Download all attachments as: .zip

Change History (8)

comment:1 by Peter Dimov, 12 years ago

I'm pretty sure that it can be fixed in principle using ldrex/strex; not only that, but it should be possible to implement sp_counted_base for armv6 using these, without resorting to a spinlock. However, I have neither the necessary experience with ARM assembly nor the resources to test the code.

comment:2 by abel@…, 11 years ago

Hi,

I'm not sure if this is still on the agenda or not. However, I had to fix this specific problem earlier this year. I followed the outline given at http://www.boost.org/support/bugs.html to produce the attached patch against the latest trunk.

The patch should take care of deprecation warnings.

The latest trunk introduced a memory barrier after the swp instructiopn. However, I think using a memory barrier is only ever necessary when the lock was actually acquired. Yet, the trunk codebase sets one up on each call of try_lock()... This might have some performance implications.

As of right now, try_lock() is called in lock() inside a loop which explicitly yields the thread if try_lock() failed. It might be better to have that loop in try_lock() instead and only do a dmb if the lock was acquired. However, this might change the API in more ways than most people would be comfortable with, I guess...

by abel@…, 11 years ago

Attachment: arm_spinlock_fix.patch added

Proposed patch for strex and ldrex usage on AMR 6 and ARM7.

by abel@…, 11 years ago

Attachment: arm_spinlock_fix.2.patch added

[Fixed] Proposed patch for strex and ldrex usage on AMR 6 and ARM7.

comment:3 by abel@…, 11 years ago

Argh, sorry, forgot a semicolon while pasting my fix in there...

comment:4 by abel@…, 11 years ago

Version: Boost 1.46.0Boost 1.50.0

bump

comment:5 by Peter Dimov, 11 years ago

(In [77315]) Apply patch from #5331. Refs #5331.

comment:6 by Peter Dimov, 11 years ago

Resolution: fixed
Status: newclosed

(In [77317]) Merge [77315] to release. Closes #5331.

Note: See TracTickets for help on using tickets.