All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-core] [patch] memory barriers in intr.c :: xnintr_lock/unlock()
@ 2006-11-11 23:59 Dmitry Adamushko
  2006-11-17 18:40 ` [Xenomai-core] " Jan Kiszka
  2006-12-06 23:03 ` Jan Kiszka
  0 siblings, 2 replies; 10+ messages in thread
From: Dmitry Adamushko @ 2006-11-11 23:59 UTC (permalink / raw)
  To: xenomai, Jan Kiszka


[-- Attachment #1.1: Type: text/plain, Size: 1291 bytes --]

Hello,

following the recent discussion with Jan, here is a patch that aims at
allowing xnintr_lock/unlock actually do what they were supposed to do in the
first instance.

in the shirq case and smp,

1) xnintr_lock/unlock()

we have to guarantee that any possible access to the shirq handlers' list is
taken inside the lock / unlock() section. To this goal, the shirq->counter's
modification have to be separated with a memory barrier from the mentioned
above access.

so the patch takes care of it.

2) now, (1) works as long as the 2nd part (xnintr_detach() ->
xnintr_irq_detach() -> deletion of the element from the list of shirq
handlers)
also respects the rules. Here, a modification of the list (element deletion)
has to be completed before the shirq->active counter being accessed. But the
deletion takes place inside the xnlock_get/put_irq* section
(xnintr_detach()) which always implies a memory barrier in place.

In case of linux, smp_mb__after_atomic_inc() and smp_mb__before_atomic_dec()
would do the job. But so far, I decided not to add something like
xnarch_memory_barrier__after_atomic_inc() :) , provided that both seem to
end up being either mb() or barrier() at the same time (have to check more
thoroughly) anyway.

Any suggestions?

-- 
Best regards,
Dmitry Adamushko

[-- Attachment #1.2: Type: text/html, Size: 1405 bytes --]

[-- Attachment #2: intr.c-mb.patch --]
[-- Type: text/x-patch, Size: 462 bytes --]

--- xenomai/ksrc/nucleus/intr-old.c	2006-11-12 00:17:56.000000000 +0100
+++ xenomai/ksrc/nucleus/intr.c	2006-11-12 00:22:15.000000000 +0100
@@ -135,12 +135,14 @@ static inline void xnintr_shirq_lock(xni
 {
 #ifdef CONFIG_SMP
 	xnarch_atomic_inc(&shirq->active);
+	xnarch_memory_barrier();
 #endif
 }
 
 static inline void xnintr_shirq_unlock(xnintr_shirq_t *shirq)
 {
 #ifdef CONFIG_SMP
+	xnarch_memory_barrier();
 	xnarch_atomic_dec(&shirq->active);
 #endif
 }

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2006-12-08 17:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-11 23:59 [Xenomai-core] [patch] memory barriers in intr.c :: xnintr_lock/unlock() Dmitry Adamushko
2006-11-17 18:40 ` [Xenomai-core] " Jan Kiszka
2006-11-19 10:55   ` Dmitry Adamushko
2006-11-20  9:13     ` Jan Kiszka
2006-11-20 20:09       ` Dmitry Adamushko
2006-11-20 23:40         ` Jan Kiszka
2006-11-21  9:32           ` Dmitry Adamushko
2006-11-21 11:28             ` Jan Kiszka
2006-12-06 23:03 ` Jan Kiszka
2006-12-08 17:54   ` Philippe Gerum

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.