Re: Address spaces

From: Pete Zaitcev (zaitcev_at_yahoo.com)
Date: 12/03/03


Date: Wed, 03 Dec 2003 13:36:14 -0800

On Wed, 03 Dec 2003 19:31:57 +0000, Ivan Van den Bossche wrote:

> Could somebody explain me the purposes of:
>
> * vmalloc address space
> * kmap address space
> * Fixed Virtual Address Mapping
>
> These are all used in the Linear address space of the Linux Kernel.

First of all, traditionally, when a Linux hacker mentions
"linear mapping", he means the fixed map at PAGE_OFFSET.
IMHO, it would be best not to use CPU-specific "linear"
anywhere near Linux to avoid confusion. Just call it "lowmem".
The main purpose of this mapping is, well, to map everything.
On some architectures, notably i386, high end machines have
more memory than fits into the lowmem range, so the rest
has to be remapped on demand, UNIX-style. It's called "highmem"
and supported by kmap framework.

The vmalloc is different. Its purpose is to create virtually
contiguous mapping of disjoint physical pages for the use by
kernel. Thus, it's different from kmap in two aspects:
a) If something is kmap-ped it cannot be simultaneously
present in any other mapping, such as lowmem, and
b) kmap only contains highmem pages of RAM, but vmalloc
contains all sorts of crap, including MMIO.

Historically vmalloc was used to load kernel modules,
but some people considering themselves clever started
to abuse it for all sorts of things. This is not a good idea,
in particular because there all sorts of kernel APIs
expect either lowmem or highmem, but not vmalloc
(in particular, DMA and address translations).
Another reason is that on some architectures vmalloc is
very scarce, and should not be wasted. The i386 usually
offers about 128MB in total for modules and ioremap.

-- Pete



Relevant Pages

  • Address spaces
    ... * vmalloc address space ... kmap address space ... Fixed Virtual Address Mapping ... These are all used in the Linear address space of the Linux Kernel. ...
    (comp.os.linux.development.system)
  • Re: [patch 1/2] x86_64 page fault NMI-safe
    ... all vmalloc issues, and can make sure that all processes are created ... entries for the new mapping. ... but now they are all mapped by the one *shared* top-level entry. ... So the only downside is that you do end up taking a fault in the ...
    (Linux-Kernel)
  • Re: [patch 1/2] x86_64 page fault NMI-safe
    ... all vmalloc issues, and can make sure that all processes are created ... entries for the new mapping. ... but now they are all mapped by the one *shared* top-level entry. ...
    (Linux-Kernel)
  • Re: still nfs problems [Was: Linux 2.6.37-rc8]
    ... kmap of a user page in!HIGHMEM ... user and kernel virtual addresses are different. ... This time it's about the user space mapping. ... kernel (well, OK, mostly within drivers) touches a user page via its ...
    (Linux-Kernel)
  • Re: [git pull] drm patches for 2.6.27-rc1
    ... So those are the ones we don't want to support for non-HIGHMEM setups. ... 64-bit we really should not be using any form of kmap. ... Especially with large vertex buffers or textures, mapping a lot of pages ...
    (Linux-Kernel)