免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3154 | 回复: 6
打印 上一主题 下一主题

RCU问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-07-17 16:50 |只看该作者 |倒序浏览
linux 2.6.18-3 函数:
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();  作用? 假设在SMP环境下.
        list_add_rcu(&p->list, last_perm);中 smp_wmb()---SMP下配置了CONFIG_X86_OOSTORE有效。include/asm-i386/system.h “处理机一致性”,所有的写操作是遵循程序序的,不会越过前面的读写操作。含义? 若其它代码中也有对&inetsw[p->type]读操作时如何?
        RCU的延迟写如何体现?

[ 本帖最后由 AIXHP 于 2007-7-17 16:51 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2007-07-18 16:03 |只看该作者
原帖由 AIXHP 于 2007-7-17 16:50 发表
linux 2.6.18-3 函数:
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;

...

清高人指点!

论坛徽章:
0
3 [报告]
发表于 2007-07-18 16:37 |只看该作者
不懂,但是帮你顶一把。

论坛徽章:
0
4 [报告]
发表于 2007-07-19 20:39 |只看该作者
rcu 是对 spin-lock 的补充,
但不能取代spin-lock,
2.6.20 above kernel 的要求,
效果也好。

论坛徽章:
0
5 [报告]
发表于 2007-07-20 15:25 |只看该作者
原帖由 sisi8408 于 2007-7-19 20:39 发表
rcu 是对 spin-lock 的补充,
但不能取代spin-lock,
2.6.20 above kernel 的要求,
效果也好。

希望是详细的说明,否则如此不起任何作用.

论坛徽章:
0
6 [报告]
发表于 2007-07-21 22:30 |只看该作者
pls read original code, specially its implementation,
not just its nice face, like sisi.

论坛徽章:
0
7 [报告]
发表于 2007-07-23 10:42 |只看该作者
原帖由 sisi8408 于 2007-7-21 22:30 发表
pls read original code, specially its implementation,
not just its nice face, like sisi.

要那样我还发帖子干吗?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP