linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: James Courtier-Dutton <James@superbug.demon.co.uk>
To: Christoph Lameter <clameter@engr.sgi.com>
Cc: linux-mm@kvack.org
Subject: Re: Possible cure for memory fragmentation.
Date: Thu, 22 Dec 2005 15:27:38 +0000	[thread overview]
Message-ID: <43AAC5EA.3090800@superbug.demon.co.uk> (raw)
In-Reply-To: <Pine.LNX.4.62.0512211058350.2455@schroedinger.engr.sgi.com>

Christoph Lameter wrote:
> On Wed, 21 Dec 2005, James Courtier-Dutton wrote:
> 
> 
>>I am suggesting we add a new memory allocation function into the kernel
>>called kremalloc().
>>
>>The purpose of any call to kremalloc() would mean that:
>>a) One really needs the memory already allocated, so don't loose it.
>>b) One does not mind if the memory location moves.
>>
>>Now, the kernel driver module that has previously allocated a memory block,
>>could at a time convenient to itself, allow the memory to be moved. It
>>would simple call kremalloc() with the same size parameter as it originally
>>called kmalloc(). The mm would then notice this, and then, if that location
>>had been tagged with (1), the mm could then happily move it, and the kernel
>>driver module would be happy. If it was not tagged with (1) the mm would
>>simply return, so very little overhead.
> 
> 
> Moving regular mapped kernel memory is not trivial. See my page migration
> patchsets.
> 
> Slab memory cannot be resized since the memory is managed in portions 
> of fixed sizes. So if these size boundaries are violated then the 
> kremalloc would degenerate into a kfree and a kmalloc. kremalloc 
> would be:
> 
> void *kremalloc(void *p, int oldsize, int newsize, gfp_t f)
> {
> 	void *new;
> 
> 	if (newsize < sizeboundary)
> 		return p;
> 
> 	new = kmalloc(size, f);
> 
> 	memcpy(new, old, oldsize);
> 
> 	kfree(p);
> 
> 	return new;
> }
> 
> 
> 

I think you missed the point I was trying to make.
The driver does not call kremalloc with a different size. It calls it 
with the SAME size. Then if the kernel thinks it would benefit from 
moving the allocation to a different location, it can do:

new = kmalloc(size, f);
if (!new)
	return p;
memcpy(new, old, oldsize);
kfree(p);

If the kernel does not wish to move it, kremalloc returns without having 
done anything.

This would effectively allow for dynamic recovery from a fragmented 
memory layout.

James

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2005-12-22 15:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-21 11:46 James Courtier-Dutton
2005-12-21 19:04 ` Christoph Lameter
2005-12-22 15:27   ` James Courtier-Dutton [this message]
2005-12-22 17:14     ` Christoph Lameter
2005-12-22 17:41       ` James Courtier-Dutton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43AAC5EA.3090800@superbug.demon.co.uk \
    --to=james@superbug.demon.co.uk \
    --cc=clameter@engr.sgi.com \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox