- 论坛徽章:
- 0
|
10可用积分
spin_lock_bh通常用在进程中,用来禁止抢断和禁止软中断。
而软中断本身不可嵌套,所以,在软中断中就不需要bh版本的spin_lock_bh。
Linux的timer是通过软中断TIMER_SOFTIRQ实现的,所以timer的超时处理函数应该也不需要bh版本的spin_lock_bh。
但kernel中br_fdb.c中的br_fdb_cleanup()为什么用spin_lock_bh?
void br_fdb_cleanup(unsigned long _data)
{
struct net_bridge *br = (struct net_bridge *)_data;
unsigned long delay = hold_time(br);
int i;
spin_lock_bh(&br->hash_lock);
for (i = 0; i < BR_HASH_SIZE; i++) {
struct net_bridge_fdb_entry *f;
struct hlist_node *h, *n;
hlist_for_each_entry_safe(f, h, n, &br->hash, hlist) {
if (!f->is_static &&
time_before_eq(f->ageing_timer + delay, jiffies))
fdb_delete(f);
}
}
spin_unlock_bh(&br->hash_lock);
mod_timer(&br->gc_timer, jiffies + HZ/10);
}
恳请大家来讨论下。 |
|