Received: with ECARTIS (v1.0.0; list netdev); Fri, 02 May 2003 22:07:29 -0700 (PDT) Received: from pizda.ninka.net (IDENT:root@pizda.ninka.net [216.101.162.242]) by oss.sgi.com (8.12.9/8.12.9) with SMTP id h4357PFu004642 for ; Fri, 2 May 2003 22:07:25 -0700 Received: from localhost (IDENT:davem@localhost.localdomain [127.0.0.1]) by pizda.ninka.net (8.9.3/8.9.3) with ESMTP id VAA04998; Fri, 2 May 2003 21:00:00 -0700 Date: Fri, 02 May 2003 21:00:00 -0700 (PDT) Message-Id: <20030502.210000.35018302.davem@redhat.com> To: rusty@rustcorp.com.au Cc: kuznet@ms2.inr.ac.ru, shemminger@osdl.org, netdev@oss.sgi.com, acme@conectiva.com.br Subject: Re: dev->destructor From: "David S. Miller" In-Reply-To: <20030503040949.804182C003@lists.samba.org> References: <20030502.134804.78707298.davem@redhat.com> <20030503040949.804182C003@lists.samba.org> X-FalunGong: Information control. X-Mailer: Mew version 2.1 on Emacs 21.1 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-archive-position: 2416 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: davem@redhat.com Precedence: bulk X-list: netdev From: Rusty Russell Date: Sat, 03 May 2003 14:07:41 +1000 This argument applies to all objects. If you reference count everything which holds a reference to an object, you can infer the reference count of the object from the sum of reference counts of its referees. In practice, as you pointed out in an earlier mail (I think sockets were your example), doing this proves to be extremely painful. And we're feeling the pain now. Please ignore the example code I wrote in that email. Most of it is inconsistent and frankly garbage. :-) The "->can_unload()" check is actually simpler than we might initially suspect. Something like ipv6 might check: if (atomic_read(&inet6_sock_nr) == 0 && atomic_read(&inet6_dev_nr) == 0 && rt6_cache_empty()) return 1; return 0; Now, here is the important part! When this thing returns "1" the module.c code does this: call_rcu(&mod->rcu_head, mod->cleanup, NULL); This makes sure the guy who killed the last object has indeed left the module code.