//@kernel/include/linux/page-flags.h
enum pageflags {
PG_locked, /* Page is locked. Don't touch. */
PG_error,
PG_referenced,
PG_uptodate,
PG_dirty,
PG_lru,
PG_active,
PG_slab,
PG_owner_priv_1, /* Owner use. If pagecache, fs may use*/
PG_arch_1,
PG_reserved,
PG_private, /* If pagecache, has fs-private data */
PG_private_2, /* If pagecache, has fs aux data */
PG_writeback, /* Page is under writeback */
#ifdef CONFIG_PAGEFLAGS_EXTENDED
PG_head, /* A head page */
PG_tail, /* A tail page */
#else
PG_compound, /* A compound page */
#endif
PG_swapcache, /* Swap page: swp_entry_t in private */
PG_mappedtodisk, /* Has blocks allocated on-disk */
PG_reclaim, /* To be reclaimed asap */
PG_buddy, /* Page is free, on buddy lists */
PG_swapbacked, /* Page is backed by RAM/swap */
PG_unevictable, /* Page is "unevictable" */
#ifdef CONFIG_HAVE_MLOCKED_PAGE_BIT
PG_mlocked, /* Page is vma mlocked */
#endif
#ifdef CONFIG_ARCH_USES_PG_UNCACHED
PG_uncached, /* Page has been mapped as uncached */
#endif
#ifdef CONFIG_MEMORY_FAILURE
PG_hwpoison, /* hardware poisoned page. Don't touch */
#endif
__NR_PAGEFLAGS,
/* Filesystems */
PG_checked = PG_owner_priv_1,
/* Two page bits are conscripted by FS-Cache to maintain local caching
* state. These bits are set on pages belonging to the netfs's inodes
* when those inodes are being locally cached.
*/
PG_fscache = PG_private_2, /* page backed by cache */
/* XEN */
PG_pinned = PG_owner_priv_1,
PG_savepinned = PG_dirty,
/* SLOB */
PG_slob_free = PG_private,
/* SLUB */
PG_slub_frozen = PG_active,
PG_slub_debug = PG_error,
};
#ifndef __GENERATING_BOUNDS_H
/*
* Macros to create function definitions for page flags
*/
#define TESTPAGEFLAG(uname, lname) \
static inline int Page##uname(struct page *page) \
{ return test_bit(PG_##lname, &page->flags); }
#define SETPAGEFLAG(uname, lname) \
static inline void SetPage##uname(struct page *page) \
{ set_bit(PG_##lname, &page->flags); }
#define CLEARPAGEFLAG(uname, lname) \
static inline void ClearPage##uname(struct page *page) \
{ clear_bit(PG_##lname, &page->flags); }
...
#endif /* !__GENERATING_BOUNDS_H */
#define PAGEFLAG(uname, lname) TESTPAGEFLAG(uname, lname) \
SETPAGEFLAG(uname, lname) CLEARPAGEFLAG(uname, lname)
//所以
PAGEFLAG(Reserved, reserved) __CLEARPAGEFLAG(Reserved, reserved)
//
//实际上就是:
TESTPAGEFLAG(Reserved, reserved) SETPAGEFLAG(Reserved, reserved) CLEARPAGEFLAG(Reserved, reserved)
//
//也就是声明了如下的几个函数:
static inline int PageReserved(struct page *page)
{ return test_bit(PG_reserved, &page->flags); }
static inline void SetPageReserved(struct page *page)
{ set_bit(PG_reserved, &page->flags); }
static inline void ClearPageReserved(struct page *page)
{ clear_bit(PG_reserved, &page->flags); }
//随着linux的长时间运行,空闲页面会越来越少,为了防止linux内核进入请求页面的僵局中,
//Linux内核采用页面回收算法(PFRA)从[用户进程]和[内核高速缓存]中[回收内存页框],
//并根据需要把[要回收页框的内容]交换到[磁盘]上的[交换区]. 调用该函数可以[使页面不被交换].
//因此对于[必须使用物理地址空间]中[固定地址段]的应用场景(例如[DMA],[共享内存],[映射到用户空间的kernel内存段]等)
page flags
最新推荐文章于 2022-03-23 16:57:45 发布