Linux内存管理——物理内存分配与回收

在Linux中,CPU访问的地址不是物理内存中的实地址,而是虚拟地址空间中的虚地址。因此,对于内存页面的管理,通常是先在虚存空间中分配一个虚存区间,然后才根据需要为此区间分配相应的物理页面并建立映射,先分配虚存区间,再分配物理页面。

1、页描述符

内核用struct page结构表示系统中的每个物理页,也叫页描述符,在linux/mm_types.h中。

struct page {
    unsigned long flags;        /* Atomic flags, some possibly
                     * updated asynchronously */
    /*
     * Five words (20/40 bytes) are available in this union.
     * WARNING: bit 0 of the first word is used for PageTail(). That
     * means the other users of this union MUST NOT use the bit to
     * avoid collision and false-positive PageTail().
     */
    union {
        struct {    /* Page cache and anonymous pages */
            /**
             * @lru: Pageout list, eg. active_list protected by
             * pgdat->lru_lock.  Sometimes used as a generic list
             * by the pag

你可能感兴趣的:(操作系统)