- 論壇徽章:
- 0
|
linux 2.6.18-3 函數(shù):
void inet_register_protosw(struct inet_protosw *p)
{
struct list_head *lh;
struct inet_protosw *answer;
int protocol = p->protocol;
struct list_head *last_perm;
spin_lock_bh(&inetsw_lock);
if (p->type >= SOCK_MAX)
goto out_illegal;
/* If we are trying to override a permanent protocol, bail. */
answer = NULL;
last_perm = &inetsw[p->type];
list_for_each(lh, &inetsw[p->type]) {
answer = list_entry(lh, struct inet_protosw, list);
/* Check only the non-wild match. */
if (INET_PROTOSW_PERMANENT & answer->flags) {
if (protocol == answer->protocol)
break;
last_perm = lh;
}
answer = NULL;
}
if (answer)
goto out_permanent;
/* Add the new entry after the last permanent entry if any, so that
* the new entry does not override a permanent entry when matched with
* a wild-card protocol. But it is allowed to override any existing
* non-permanent entry. This means that when we remove this entry, the
* system automatically returns to the old behavior.
*/
list_add_rcu(&p->list, last_perm);
out:
spin_unlock_bh(&inetsw_lock);
synchronize_net();
return;
out_permanent:
printk(KERN_ERR "Attempt to override permanent protocol %d.\n",
protocol);
goto out;
out_illegal:
printk(KERN_ERR
"Ignoring attempt to register invalid socket type %d.\n",
p->type);
goto out;
}
問題: synchronize_net(); 作用? 假設(shè)在SMP環(huán)境下.
list_add_rcu(&p->list, last_perm);中 smp_wmb()---SMP下配置了CONFIG_X86_OOSTORE有效。include/asm-i386/system.h “處理機(jī)一致性”,所有的寫操作是遵循程序序的,不會(huì)越過前面的讀寫操作。含義? 若其它代碼中也有對(duì)&inetsw[p->type]讀操作時(shí)如何?
RCU的延遲寫如何體現(xiàn)?
[ 本帖最后由 AIXHP 于 2007-7-17 16:51 編輯 ] |
|