Kernel page Global Directory (PGD) of page table of Process created in Linux Kernel

Source: Internet
Author: User

KernelPage Global Directory (PGD)of User process created

In earlier versions:

When you fork a process, you must establish the process's own kernel page directory entry (the kernel page directory entry to the user space
Page directory is placed on a contiguous page of the same physical address, so it cannot be shared, but the kernel page table of all processes
Process 0 Sharing)
3G user, a page directory in a map 4M of space (a page table of Contents 1024 Items page tables, each page table corresponds to 1 pages 4K
), namely:
#define Pgdir_shift 22
#define PGDIR_SIZE (1UL << pgdir_shift)
>>> Sys_fork->do_fork->copy_mm->mm_init->pgd_alloc->get_pgd_slow
#if config_x86_pae
。。。。。。。。。。。。。
#else
extern __inline__ pgd_t *get_pgd_slow (void)
{
>>> Allocation page Catalog table (contains 1024 page catalogs), that is, the page directory allocated for a process can be mapped to a space of
1024*4m=4g
pgd_t *PGD = (pgd_t *) __get_free_page (Gfp_kernel);
if (PGD) {
>>> #define USER_PTRS_PER_PGD (task_size/pgdir_size)
>>> task_size is 3G in size, USER_PTRS_PER_PGD is the number of page directory entries corresponding to the user space (
3g/4m=768)
>>> empty page catalog entries for user space
memset (PGD, 0, USER_PTRS_PER_PGD * sizeof (pgd_t));
>>>Copy the No. 768 to 1023 items of the Kernel Page directory table (swapper_pg_dir) to the page directory table of the process
Items from 768 to 1023
memcpy (PGD + USER_PTRS_PER_PGD, Swapper_pg_dir + USER_PTRS_PER_PGD,
(PTRS_PER_PGD-USER_PTRS_PER_PGD) * sizeof (pgd_t));
 }
return PGD;
}
#endif

The newer version:

pgd_t *pgd_alloc (struct mm_struct *mm)  
Pgd_ctor (mm, PGD); The key code that copies the page catalog entries that point to the kernel space into the project for the newly assigned PGD.
-
Clone_pgd_range (PGD + kernel_pgd_boundary, //item points to the KERNEL space
Swapper_pg_dir + kernel_pgd_boundary, kernel_pgd_ptrs);

Ref.

[1] http://biancheng.dnbcw.info/linux/321897.html

[2] http://m.blog.csdn.net/blog/SunnyBeiKe/6898253

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.