netdev
[Top] [All Lists]

Re: dev->destructor

To: rusty@xxxxxxxxxxxxxxx
Subject: Re: dev->destructor
From: "David S. Miller" <davem@xxxxxxxxxx>
Date: Fri, 02 May 2003 21:00:00 -0700 (PDT)
Cc: kuznet@xxxxxxxxxxxxx, shemminger@xxxxxxxx, netdev@xxxxxxxxxxx, acme@xxxxxxxxxxxxxxxx
In-reply-to: <20030503040949.804182C003@xxxxxxxxxxxxxxx>
References: <20030502.134804.78707298.davem@xxxxxxxxxx> <20030503040949.804182C003@xxxxxxxxxxxxxxx>
Sender: netdev-bounce@xxxxxxxxxxx
   From: Rusty Russell <rusty@xxxxxxxxxxxxxxx>
   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.

<Prev in Thread] Current Thread [Next in Thread>