Re: [PATCH] module: kzalloc mod->ref

Richard Kennedy
2009-01-25T15:53:03Z

On Thu, 2009-01-15 at 13:03 +1030, Rusty Russell wrote:
>
>
> On Thursday 15 January 2009 04:47:48 Kyle McMartin wrote:
>
> > On Wed, Jan 14, 2009 at 05:51:27PM +0000, richard kennedy wrote:
>
> > > Aside from the code in socket does this reference count really get
> used
>
> > > that often? Atomic_t gets used for ref counts is lots of other
> places in
>
> > > the kernel, so why not turn module_ref into an atomic counter &
> drop the
>
> > > array entirely saving all of the memory & disk space?
>
> The code was originally written with the intent that networking would
> inc and dec a module count on every *packet*. It doesn't, however
> (though it would be interesting to instrument who does manip it, and
> how often).
>
> I suspect that we could get away with an atomic_t and noone would
> notice, but I'd like to see evidence one way or the other.
>
> Cheers,
>
> Rusty.
Hi Rusty,
I've been running module reference counts as atomic_t on my desktop
(x86_64 AMD X2) all week and haven't been able to measure any
significant performance differences. I guess more cpus & server
workloads could show up something, but I don't have access to that sort
of hardware.

The one issue I am seeing is with my simple test harness, which is just
a very basic socket client/server. With the existing ref counting code,
when running several copies of the client I sometimes get EADDRNOTAVAIL
(-99) errors on socket connect(). But I don't see any errors with the
atomic_t ref counting.
I'm still trying to debug this, but I haven't yet found where in the
network stack these errors are coming from.

regards
Richard