PI mutex support on ARM

5 messages, 4 authors, 2007-07-09 · open the first message on its own page

PI mutex support on ARM

From: Remy Bohmer <hidden>
Date: 2007-07-08 08:25:10

Hello Thomas,

I have build an implementation for the routine
futex_atomic_cmpxchg_inatomic() to make PTHREAD_PRIO_INHERIT mutex
work on ARM.
Compared to other architectures where CPU specific assembler is used,
it is probably not the most optimal implementation possible, but I
tested it successfully on a Atmel AT91RM9200 core, and it could work
on other (UP) architectures as well.

What do you think of it?
Or do you know a better solution?

Kind Regards,

Remy

Re: PI mutex support on ARM

From: Ingo Molnar <hidden>
Date: 2007-07-08 09:58:56

* Remy Bohmer [off-list ref] wrote:
quoted hunk
--- linux-2.6.21.orig/include/asm/futex.h	2007-04-26 05:08:32.000000000 +0200
patch format problem: never diff the asm/ files, diff the asm-arm/ 
files.
quoted hunk
+	local_irq_save(flags);
+
+	err = get_user(uval, uaddr);
is it safe to do a get_user() with irqs off?
quoted hunk
+	if (err)
+	{
+		local_irq_restore(flags);
+		 return -EFAULT;
+	}
(style problems. Use scripts/checkpatch.pl to verify your patches.)
+	local_irq_restore(flags);
is this method of atomic ops SMP-safe?

	Ingo

Re: PI mutex support on ARM

From: Remy Bohmer <hidden>
Date: 2007-07-08 20:17:52

Hello Ingo,
patch format problem: never diff the asm/ files, diff the asm-arm/ files.
Yeah, of course, I know, I believe I made a real mess of this one ...
is it safe to do a get_user() with irqs off?
rhetorical question ;-))
I was wondering, Is it safe to use a normal spinlock here, like this?

------- 8-< -------------
	spin_lock(&futex_lock);

	err = get_user(uval, uaddr);
	if ((!err) && (uval == oldval))
		err = put_user(newval, uaddr);

	spin_unlock(&futex_lock);
------- 8-< -------------
is this method of atomic ops SMP-safe?
another rhetorical question ;-))
Nope, I already knew that, that why I mentioned that it probably only
worked on UP...

Remy

Re: PI mutex support on ARM

From: Matthieu CASTET <hidden>
Date: 2007-07-09 07:25:06

Hi,

Remy Bohmer <l.pinguin <at> gmail.com> writes:
Hello Thomas,

I have build an implementation for the routine
futex_atomic_cmpxchg_inatomic() to make PTHREAD_PRIO_INHERIT mutex
work on ARM.
Compared to other architectures where CPU specific assembler is used,
it is probably not the most optimal implementation possible, but I
tested it successfully on a Atmel AT91RM9200 core, and it could work
on other (UP) architectures as well.

What do you think of it?
Or do you know a better solution?
May be you could have a look at __kuser_cmpxchg (arch/arm/kernel/entry-armv.S).
There stuff for smp for armv6 and newer.
For armv5 and older, maybe masking interrupt is the best solution.


But I believe you should CC arm linux mailling list. You should find more arm
expert :)


Matthieu

Re: PI mutex support on ARM

From: Arjan van de Ven <hidden>
Date: 2007-07-09 14:46:44

On Sun, 2007-07-08 at 22:17 +0200, Remy Bohmer wrote:
Hello Ingo,
quoted
patch format problem: never diff the asm/ files, diff the asm-arm/ files.
Yeah, of course, I know, I believe I made a real mess of this one ...
quoted
is it safe to do a get_user() with irqs off?
rhetorical question ;-))
I was wondering, Is it safe to use a normal spinlock here, like this?
if get_user() isn't allowed with irq's off (and in general it's not,
maybe arm is special) then it also isn't allowed with spinlocks held..
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help