4

Each process has 2 memory area: User space (high memory) and kernel space (low memmory). In the kernel space, are the first 896 MB used for mapping kernel code (not fully 1 GB)? This means, when a user -space application performs a system call or anything related to the kernel, the kernel will refer to kernel space for the system call to execute, is it?

The reserved 128MB in kernel space (for high memory (user space) access), is it all the references of user-space memory area? So, a kernel process can access any user space by refer to this area, is this true?

That's why this area is called highmem in kernel space, isn't it?

2 Answers 2

9

"High memory" and "low memory" do not apply to the virtual address space of processes, it's about physical memory instead.

In the process' virtual address space, the user space occupies the first 3GB, and the kernel space the fourth GB of this linear address space.

The first 896MB of the kernel space (not only kernel code, but its data also) is "directly" mapped to the first 896 MB of the physical memory. It is "direct" in the sense that there's always an offset of 0xc0000000 between any linear address of this 896MB part of the virtual kernel space and its corresponding address in physical memory (note however that the MMU is enabled and that page table entries are actually used for this).

The last 128MB part of the virtual kernel space is where are mapped some pieces of the physical "high memory" (> 896MB) : thus it can only map no more than 128MB of "high memory" at a time.

Reference: "Understanding the Linux Kernel", third edition - sections "8.1.3. Memory Zones" and "8.1.6. Kernel Mappings of High-Memory Page Frames".

1
  • Note that the recent KPTI patches for Linux remove this direct mapping.
    – forest
    Dec 24, 2018 at 4:41
1

N.B. :- Memory split only happens in older linux system (32-bit) for more details please see below comment.

High and Low Memory :

  • Low memory : Memory for which logical addresses exist in kernel space. On almost every system you will likely encounter, all memory is low memory.
  • High memory : Memory for which logical addresses do not exist, because it is beyond the address range set aside for kernel virtual addresses.This means the kernel needs to start using temporary mappings of the pieces of physical memory that it wants to access.

Kernel splits virtual address into two part user address space and kernel address space. The kernel’s code and data structures must fit into that space, but the biggest consumer of kernel address space is virtual mappings for physical memory. Thus kernel needs its own virtual address for any memory it must touch directly. So, the maximum amount of physical memory that could be handled by the kernel was the amount that could be mapped into the kernel’s portion of the virtual address space, minus the space used by kernel code.

enter image description here

2
  • I see you're adding content to this old question. It would be nice if we had something on this question, to point out that it is (and arguably always was!) obsolescent. I.e. 32-bit Linux is generally not used on PCs anymore, and 64-bit Linux does not split physical memory into highmem / lowmem (and obviously the 3GB/1GB user/kernel split doesn't apply either, both virtual areas are significantly larger).
    – sourcejedi
    Nov 25, 2018 at 10:21
  • @sourcejedi Thanks, for pointing out, although 32-bit architecture is obsolete but, these are the concepts which we should know how older Linux system works.
    – finn
    Dec 5, 2018 at 19:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .