[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-kernel
Subject:    Kernel page count management
From:       Mathias Waack <mathias () atoll-net ! de>
Date:       2000-02-07 9:36:14
[Download RAW message or body]

Hi all, 

sorry for bothering you, but I've asked this question in the usenet 
without any answers. 

So, that's my problem:

If I request a page by calling get_free_page, the kernel 
sets the usage count for this page to 1. So far so good, but if
I request more pages by calling __get_free_pages(GFP...,order) 
it sets only the usage count of the first returned page. 

Some sample code:

#include <linux/module.h>
#include <linux/kernel.h>
#include <asm/io.h>

int init_module(void)
{
  int order;
  unsigned long mem;

  for (order = 3; order >= 0; --order) {
    printk(KERN_INFO "checking for order %d\n",order);
    mem = __get_free_pages(GFP_ATOMIC, order);
    if (!mem) printk(KERN_INFO "got no mem\n");
    else {
      int i;
      for (i=0;i < 1<<order; ++i) {
       printk("page %d hast count %d\n",i, atomic_read(&mem_map[MAP_NR(mem + PAGE_SIZE*i)].count));
      }
      free_pages(mem,order);
    }
  }
  return -ENOMEM;
}

void cleanup_module(void)
{
}
 
I've compiled the code with
        cc -D__SMP__ -D__KERNEL__ -DMODULE -DSIMU -O -Wall -I/usr/include   -c main.c -o main.o

Can anybody explain this behaviour to me? Where is my mistake? 
As far as I understand the kernel, the usage count for all pages should 
be set to 1. Should I do it by hand after allocation? 

If I do nothing but simple use this memory (for mmapping it to user space later), the 
system crashes from time to time. I think (or better: I hope) my other code is correct...

I'm using a dual Pentium running a 2.2.14 kernel. The kernel is configured correct and 
runs stable (if I do not use my own code, of course;) 

Thanks for your answers

Mathias



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic