Re: sort of ... spinlock_softirq()

Andi Kleen (ak@muc.de)
15 Aug 1998 01:24:25 +0200


In article <19980814204643.B17095@impsat1.com.ar>,
Juanjo Ciarlante <irriga@impsat1.com.ar> writes:
> I need some locking stuff in ip_masq to allow user-space masq tunnel
> creation (eg. for FTP,IRC,etc transparent proxies) and thought about
> the following locking sequence
> start_bh_atomic(); /* instead of write_lock_irqsave() */
> write_lock(&l);
> critical_section(); /* To be accessed ONLY from U and BH context */
> write_unlock(&l);
> end_bh_atomic();

write_lock_irqsave() is faster than start_bh_atomic(), because
start_bh_atomic calls synchronize_bh currently which can be costly. Also
start_bh_atomic is a global locking algorithm, while write_lock_irqsave
works local which is faster - when irqs are disabled on the current CPU
then other CPUs can still process them. In a start_bh_atomic you block
out all BHs on all CPUs.

> If critical_section() is ``short enough'' (eg. change a bound variable),
> is HARD irq stuff faster than SOFT xx_bh_atomic()?

If it is only a variable setting or increase/decrease/test then you can
use the atomic_set/atomic_inc/atomic_dec/atomic_dec_and_test functions too.
xchg() may also do what you want.

-Andi

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html