From: "Peter T. Breuer" <ptb@inv.it.uc3m.es>
To: user-mode-linux-devel@lists.sourceforge.net
Subject: [uml-devel] kmalloc does not recover mem in 2.4.24
Date: Fri, 24 Dec 2004 06:36:24 +0100 (MET) [thread overview]
Message-ID: <200412240536.iBO5aOG20540@inv.it.uc3m.es> (raw)
Howdy. I've been running 2.4.24-1um very happily for a good long time.
Since April, I believe. But I've just noticed that kmalloc does not seem
to recover memory. Here I've cooked up some demonstration code:
sh-2.03# free
total used free shared buffers cached
Mem: 29524 4540 24984 0 140 2824
^^^^^
-/+ buffers/cache: 1576 27948
Swap: 0 0 0
sh-2.03# insmod mem.o
tiny driver loaded
(this module uses kmalloc to allocate 1000 pages in its init function,
and will release it in its exit function)
sh-2.03# free
total used free shared buffers cached
Mem: 29524 8684 20840 0 140 2824
^^^^^
-/+ buffers/cache: 5720 23804
Swap: 0 0 0
sh-2.03# rmmod mem
tiny driver unloaded
sh-2.03# free
total used free shared buffers cached
Mem: 29524 8680 20844 0 140 2824
^^^^^
-/+ buffers/cache: 5716 23808
Swap: 0 0 0
Same mem usage! Nothing released. I am running UML under kernel 2.6.3,
where it also shows timing anomalies - any sleep takes ages to complete.
Here's my test code:
#include <linux/major.h>
#include <linux/module.h>
#include <linux/version.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/blkdev.h>
#include <linux/blk.h>
int linux_version_code = LINUX_VERSION_CODE;
#define MAX_TINY 1024
static char ** tiny_cache;
static int max_tiny = MAX_TINY;
static int __init
tiny_init (void)
{
int i, err;
tiny_cache = kmalloc(sizeof(char *) * max_tiny, GFP_KERNEL);
for (i = 0; i < max_tiny; i++) {
tiny_cache[i] = kmalloc(PAGE_SIZE, GFP_KERNEL);
if (!tiny_cache[i])
goto error_out;
}
printk (KERN_INFO "tiny driver loaded\n");
return 0;
error_out:
printk (KERN_ERR "tiny driver failed to load\n");
while (--i >= 0) {
kfree(tiny_cache[i]);
}
kfree(tiny_cache);
return -EINVAL;
}
static void __exit
tiny_cleanup (void)
{
int i;
for (i = 0; i < max_tiny; i++) {
kfree (tiny_cache[i]);
}
kfree(tiny_cache);
printk (KERN_INFO "tiny driver unloaded\n");
}
module_init (tiny_init);
module_exit (tiny_cleanup);
Peter
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
reply other threads:[~2004-12-24 5:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=200412240536.iBO5aOG20540@inv.it.uc3m.es \
--to=ptb@inv.it.uc3m.es \
--cc=user-mode-linux-devel@lists.sourceforge.net \
/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