Hugemem kernel explained

Source: Internet
Author: User

The red flag DC series Linux operating system (x86 Platform) has four types of cores:

* Up (single kernel supported)
* SMP (supports multiple kernels)
* Hugemem
* ICC * (core compiled with Intel C compiler)

The core of hugemem is often a lot of confusion, and it is hoped that hugemem will be clearly explained once and for all.

Hugemem vs. SMP

On the X86 platform, the SMP and hugemem cores of the Red Flag dc4.1 and 5.0 enable PAE support, that is, they both support 4 GB or more physical memory. The purpose of the hugememe core is to _ No _ support for over 4 GB physical memory (SMP core support ), it supports large memory x86 systems more stably (the so-called large memory can be simply understood as a system with over 12 GB memory ).

The only difference between SMP and hugemem core is that hugemem core uses 4g/4G patches, the 4G/4G patch can be used to expand the directly mapped kernel data code address space from 1g to 4G, and also expand the virtual address space of the process from 3G to 4G. When the physical memory is too large, the management of these physical memory itself will occupy a lot of valuable kernel address space (so-called low-end memory), although the total physical memory has a lot of idle, low-end memory consumption may also lead to memory shortage, triggering OOM (out of memory) Killer, resulting in application termination or even core crash.

If the physical memory exceeds 12 GB, we recommend that you use the hugemem kernel. However, hugemem may cause some performance loss.

The above description should be sufficient for general users. If you want to learn more about the 4G/4G patch, please continue reading...

Problems caused by large memory x86 systems

4G/4G patch is mainly used in large memory x86 systems (the so-called large memory can be simply understood as a system with over 12g memory ), such a system usually requires more kernel address space and user address space.

In the X86 architecture, we know that the virtual address space is 4 GB. In this 4g space, the user space occupies 3 GB (0x00000000 to 0 xbfffff), and the core space occupies 1 GB (0xc0000000 to 0 xffffffff ). This allocation policy becomes 3g/1g allocation. This allocation method does not have any problems for systems with less than 1 GB physical memory. Even if the physical memory exceeds 1 GB, the 3 GB/1 GB allocation policy has no problems, because the kernel can store some kernel data structures (such as page buffering) in the high-end memory area (memory with a physical address greater than 1 GB ). However, with the increase of physical memory, problems with the 3G/1g allocation policy will gradually be exposed. This is because some key kernel data structures (such as mem_map [] used to manage physical memory) are stored within 1 GB of core space. For 32 GB memory systems, mem_map [] will occupy nearly 1.5% GB of low-end memory (memory with a physical address less than MB), leaving less than of the memory for other core parts; for 64 GB memory systems, mem_map [] itself will consume all the low-end memory, causing the system to fail to start. The practice of putting mem_map [] into high-end memory is not practical, because mem_map [] and memory management, the architecture is related to the underlying implementation, almost all key components of file systems and drivers are associated.

4G/4G role

Different from 3g/1g, the 4G/4G allocation method can increase the core space from 1g to 4g, and the user space from 3G to 4G. From the/proc/Pid/maps file, you can intuitively see the role of 4G/4G:

00e80000-00faf000 R-XP 00000000 0:01 175909/lib/tls/libc-2.3.2.so

00faf000-00fb2000 RW-P 0012f000 0:01 175909/lib/tls/libc-2.3.2.so

[...]

Feffe000-ff000000 rwxp fffff000 00:00 0

From the above maps, we can see that the stack base address is 0xff000000 (4 GB minus 16 Mb ).

From/proc/maps, we can see that the core has a low-end memory of 4 GB. Even for 64 GB physical memory systems, there is a low-end memory of 3 GB for use:

Memtotal: 66052020 KB

Memfree: 65958260 KB

Hightotal: 62914556 KB

Highfree: 62853140 KB

Lowtotal: 3137464 KB

Lowfree: 3105120 KB

Compared with the 3G/1g allocation policy, for a 4G/4G physical memory system, the use of 4G/4G allocation can increase the low-end memory by more than 3 times. For a 32G physical memory system, there will be more improvements, six times of the original. In theory, the 4G/4G strategy can support x86 systems with a physical memory of g (if there is no hardware limit), even for such systems, the 4G/4G policy can also ensure that 1g of available low-end memory is available.

4G/4G cost

There is no free lunch in the world, as are 4g/4G. 4G/4G increases the low-end memory by completely separating the address ing between the user space and the core space. This will cause some performance loss. Specifically, when context switching occurs (for example, a process calls a system call or is interrupted), the page table must be reloaded (no loading is required under the 3G/1g policy, because the core can directly "borrow" the page tables of each process for memory ing ), after the page table is reloaded, TLB must be cleared (otherwise, the ing of records in TLB is inconsistent with that in the new page table). Clearing TLB is a very time-consuming operation, the "old" ing originally cached in TLB will be lost, which is still the second (because it is not too late to directly read the page table from the CPU cache without TLB ), the biggest loss lies in the high cost of clearing the TLB (through the % Cr 3 operation.

When to use (or not) 4g/4G?

There is no perfect answer to this question. There are only some thumb laws. Generally, 4G/4G is required for memory exceeding 16g (unless the running application load is very light, but the large memory system rarely has a light load ), if the load is heavy (it is better to run a large number of I/O operations on the database), 4G/4G should be considered for systems above 12g. You can also roughly judge by observing the idle low-end memory size (/proc/meminfo). If the idle low-end memory (lowfree) is less than 100 MB, then you can consider using 4g/4G. Generally, systems under 8 GB do not need to use 4g/4G.

It should be noted that if large memory is needed, the best solution is to use a 64-bit system instead of 4G/4G.

 

 Original article addressHttp://x.uplinux.com /? 2/action_viewspace_itemid_26.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.