Chinaunix

标题: PG_Readahead的疑问 [打印本页]

作者: 王非文    时间: 2014-07-24 11:44
标题: PG_Readahead的疑问
在readahead.c 中有如下注释,觉得PG_readahead应该是一个独立的标志位。
/*
* On-demand readahead design.
*
* The fields in struct file_ra_state represent the most-recently-executed
* readahead attempt:
*
*                        |<----- async_size ---------|
*     |------------------- size -------------------->|
*     |==================#===========================|
*     ^start             ^page marked with PG_readahead

而在include/linux/page_flags.h 中的pageflags的枚举变量中并没有 PG_Readahead 的成员。

SetPageReadahead() 展开之后其实是置位PG_reclaim
Static inline void SetPageReadahead(struct page *page)
{
    Set_bit(PG_reclaim, &page->flags);
}

疑惑啊,为什么PG_Readahead 不是pageflags中的一员,有知道的解释一下吗?

(1)
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_swapbacked,      /* Page is backed by RAM/swap */
    PG_unevictable,     /* Page is "unevictable"  */
#ifdef CONFIG_MMU
    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
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
    PG_compound_lock,
#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,
};

(2)
/* PG_readahead is only used for file reads; PG_reclaim is only for writes */
PAGEFLAG(Reclaim, reclaim) TESTCLEARFLAG(Reclaim, reclaim)
PAGEFLAG(Readahead, reclaim)        /* Reminder to do async read-ahead */

#define PAGEFLAG(uname, lname) TESTPAGEFLAG(uname, lname)       \
    SETPAGEFLAG(uname, lname) CLEARPAGEFLAG(uname, lname)

#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); }




作者: 黎明748    时间: 2014-07-24 14:03
内核里面找不到PG_readahead。。。
作者: chenyu105    时间: 2014-07-24 14:24
1.这个标志是宏生成的
2. 这个标志和reclaim标志复用了  在reclaim流程自然不会去预读,所以是互斥
作者: 王非文    时间: 2014-07-24 15:28
1.这个标志是宏生成的
能说具体一点吗?即使是宏生成的,但是在枚举变量pageflags中没有PG_readahead的声明
2. 这个标志和reclaim标志复用了  在reclaim流程自然不会去预读,所以是互斥
这句话就更加不明白了,SetPageReadahead() 展开之后其实是置位PG_reclaim,看到是PG_readahead 和 PG_reclaim是等价的。
作者: embeddedlwp    时间: 2014-07-24 15:34
page flags bit是非常紧张的,能复用就复用吧,
作者: embeddedlwp    时间: 2014-07-24 15:35
http://lwn.net/Articles/335768/




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2