Re: Qs: Kernel memory allocation; fbcon greyscale implementation

Topi Miettinen (Topi.Miettinen@medialab.sonera.fi)
Fri, 23 Apr 1999 21:04:15 +0300


"Stephen C. Tweedie" writes:
> Hi,
>
> On Thu, 22 Apr 1999 21:41:38 +0200 (CEST), Andrea Arcangeli
> <andrea@e-mind.com> said:
>
> > On Thu, 22 Apr 1999, Timo Ketola wrote:
> >> 2) The kernel message says that 412k of the memory is reserved. I'm
> >> afraid that the 640k-1M area is reserved and lost. If thats true, how
> >> can I get them back.
>
> > I don't think you loose memory. reserved should be memory used by the
> > kernel too.
>
> No. If there is phsyical memory at those addresses, you can't use it.
> Look at arch/i386/mm/init.c, function mem_init(): basically we have
> already marked all memory as reserved by this point, and we now go
> through the low memory (below 0x9F0000) and high memory (above 1MB)
> clearing the PG_reserved bits. Once we've done that, we do a
> free_page() on all non-reserved pages to place them on the kernel free
> list. The reserved pages never make it onto the free lists so are never
> allocated by the kernel.
>
> The kernel _does_ let you play with reserved pages to some extent, for
> example to allow mmap()ing of ISA framebuffers into process address
> space. However, the VM is careful to tread carefully around those
> reserved pages, not performing any demand-paging or swapping on them.

Intel (and possibly other) motherboard chipsets allow changing the area
between 0xc0000 and 0x100000 to cacheable ram. Look at their web site for
docs.

Warning: this is only useful and safe when the area is not used by ISA card
or dosemu etc!

For example, the registers of my Natoma bridge can be tweaked with command:

$ lspci | grep Host
00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)
$ setpci -s 00:00.0 59.b=33 5a.w=3333 5c.l=33333333

I also wrote this module to give the memory to kernel (also thinkpad area).

-Topi

#include <linux/version.h>
#include <linux/config.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/mman.h>
#include <linux/mm.h>
#include <linux/init.h>
#include <linux/string.h>
#include <asm/page.h>
#include <asm/atomic.h>

int init_module(void)
{
unsigned long i;
for (i=0x9f000+PAGE_OFFSET; i < 0xa0000+PAGE_OFFSET; i+=PAGE_SIZE) {
clear_bit(PG_reserved, &mem_map[MAP_NR(i)].flags);
}
for (i=0xc0000+PAGE_OFFSET; i < 0x100000+PAGE_OFFSET; i+=PAGE_SIZE) {
clear_bit(PG_reserved, &mem_map[MAP_NR(i)].flags);
}
return -ENXIO;
}

-
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/