Subject: Re: [PATCH 12/30] mm: memory reserve management

From: Peter Zijlstra <[email-masked]>
Date: Mon, 28 Jul 2008 12:39:01 +0200

On Mon, 2008-07-28 at 13:29 +0300, Pekka Enberg wrote:

> > > > +	}
> > > > +
> > > > +	obj = __kmalloc_node_track_caller(size, flags, node, ip);
> > > > +	WARN_ON(!obj);
> > > 
> > > Why don't we discharge from the reserve here if !obj?
> > 
> > Well, this allocation should never fail:
> >   - we reserved memory
> >   - we accounted/throttle its usage
> > 
> > Thus this allocation should always succeed.
> 
> But if it *does* fail, it doesn't help that we mess up the reservation
> counts, no?

I guess you're right there. Will fix. Thanks!

> > > > +{
> > > > +	size_t size = ksize(obj);
> > > > +
> > > > +	kfree(obj);
> > > 
> > > We're trying to get rid of kfree() so I'd __kfree_reserve() could to
> > > mm/sl?b.c. Matt, thoughts?
> > 
> > My issue with moving these helpers into mm/sl?b.c is that it would
> > require replicating all this code 3 times. Even though the functionality
> > is (or should) be invariant to the actual slab implementation.
> 
> Right, I guess we could just rename ksize() to something else then and
> keep it internal to mm/.

That would be nice - we can stuff it into mm/internal.h or somesuch.

Also, you might have noticed, I still need to do everything SLOB. The
last time I rewrote all this code I was still hoping Linux would 'soon'
have a single slab allocator, but evidently we're still going with 3 for
now.. :-/

So I guess I can no longer hide behind that and will have to bite the
bullet and write the SLOB bits..

> > > > +	/*
> > > > +	 * ksize gives the full allocated size vs the requested size we used to
> > > > +	 * charge; however since we round up to the nearest power of two, this
> > > > +	 * should all work nicely.
> > > > +	 */
> > > > +	mem_reserve_kmalloc_charge(res, -size);
> > > > +}