免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2346 | 回复: 5
打印 上一主题 下一主题

[文件系统] PG_Readahead的疑问 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2014-07-24 11:44 |只看该作者 |倒序浏览
在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); }



论坛徽章:
0
2 [报告]
发表于 2014-07-24 14:03 |只看该作者
内核里面找不到PG_readahead。。。

论坛徽章:
0
3 [报告]
发表于 2014-07-24 14:24 |只看该作者
1.这个标志是宏生成的
2. 这个标志和reclaim标志复用了  在reclaim流程自然不会去预读,所以是互斥

论坛徽章:
0
4 [报告]
发表于 2014-07-24 15:28 |只看该作者
1.这个标志是宏生成的
能说具体一点吗?即使是宏生成的,但是在枚举变量pageflags中没有PG_readahead的声明
2. 这个标志和reclaim标志复用了  在reclaim流程自然不会去预读,所以是互斥
这句话就更加不明白了,SetPageReadahead() 展开之后其实是置位PG_reclaim,看到是PG_readahead 和 PG_reclaim是等价的。

论坛徽章:
16
2015亚冠之吉达阿赫利
日期:2015-08-17 11:21:462015年迎新春徽章
日期:2015-03-04 09:58:11酉鸡
日期:2014-12-07 09:06:19水瓶座
日期:2014-11-04 14:23:29天秤座
日期:2014-03-02 08:57:52双鱼座
日期:2014-02-22 13:07:56午马
日期:2014-02-14 11:08:18双鱼座
日期:2014-02-13 11:09:37卯兔
日期:2014-02-06 15:10:34子鼠
日期:2014-01-20 14:48:19戌狗
日期:2013-12-19 09:37:46射手座
日期:2013-12-19 09:33:47
5 [报告]
发表于 2014-07-24 15:34 |只看该作者
page flags bit是非常紧张的,能复用就复用吧,

论坛徽章:
16
2015亚冠之吉达阿赫利
日期:2015-08-17 11:21:462015年迎新春徽章
日期:2015-03-04 09:58:11酉鸡
日期:2014-12-07 09:06:19水瓶座
日期:2014-11-04 14:23:29天秤座
日期:2014-03-02 08:57:52双鱼座
日期:2014-02-22 13:07:56午马
日期:2014-02-14 11:08:18双鱼座
日期:2014-02-13 11:09:37卯兔
日期:2014-02-06 15:10:34子鼠
日期:2014-01-20 14:48:19戌狗
日期:2013-12-19 09:37:46射手座
日期:2013-12-19 09:33:47
6 [报告]
发表于 2014-07-24 15:35 |只看该作者
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP