From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?B?5p2o56GV?= Subject: why does there need to lock? Date: Mon, 22 Mar 2010 08:41:04 +0800 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 To: netdev@vger.kernel.org Return-path: Received: from mail-wy0-f174.google.com ([74.125.82.174]:45910 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753404Ab0CVAlH (ORCPT ); Sun, 21 Mar 2010 20:41:07 -0400 Received: by wyb38 with SMTP id 38so2248616wyb.19 for ; Sun, 21 Mar 2010 17:41:04 -0700 (PDT) Sender: netdev-owner@vger.kernel.org List-ID: Hi, i'm confused about why does "rcu_assign_pointer(dev->ip_ptr, in_dev);" need to rcu lock? TIA :) static struct in_device *inetdev_init(struct net_device *dev) { struct in_device *in_dev; ASSERT_RTNL(); in_dev = kzalloc(sizeof(*in_dev), GFP_KERNEL); if (!in_dev) goto out; memcpy(&in_dev->cnf, dev_net(dev)->ipv4.devconf_dflt, sizeof(in_dev->cnf)); in_dev->cnf.sysctl = NULL; in_dev->dev = dev; if ((in_dev->arp_parms = neigh_parms_alloc(dev, &arp_tbl)) == NULL) goto out_kfree; if (IPV4_DEVCONF(in_dev->cnf, FORWARDING)) dev_disable_lro(dev); /* Reference in_dev->dev */ dev_hold(dev); /* Account for reference dev->ip_ptr (below) */ in_dev_hold(in_dev); devinet_sysctl_register(in_dev); ip_mc_init_dev(in_dev); if (dev->flags & IFF_UP) ip_mc_up(in_dev); /* we can receive as soon as ip_ptr is set -- do this last */ rcu_assign_pointer(dev->ip_ptr, in_dev); out: return in_dev; out_kfree: kfree(in_dev); in_dev = NULL; goto out; }