2004-11-20 19:32:35

by Nikita V. Youshchenko

[permalink] [raw]
Subject: Strange in_atomic() definition in include/linux/hardirq.h

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello.

In linux 2.6.9, in include/linux/hardirq.h, if CONFIG_PREEMPT is set,
isw_atomic() is defines as

#define in_atomic()
((preempt_count() & ~PREEMPT_ACTIVE) != kernel_locked())

preempt_count (after PREEMPT_ACTIVE is cleared out) looks to be an integer
counter, increased in preempt_disable() and increased in preempt_enable().

kernel_locked() is defined in include/linux/smp_lock.h as
#define kernel_locked() (current->lock_depth >= 0)

So in in_atomic() definition, integer counter is compared with boolean
value. Looks like a bug.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBn5vOv3x5OskTLdsRAkr1AJ9lqX/U58rahDFAP7v9dIf30ZzPSACfcU4u
4JzBcBAuqdrghmgeRnWfBds=
=E9Hd
-----END PGP SIGNATURE-----