【问题标题】:How does Linux kernel find dirty page to flush?Linux内核如何找到要刷新的脏页?
【发布时间】:2012-03-02 16:05:09
【问题描述】:

由于页面存储在每个inode内的address_space中,后台页面缓存刷新线程如何知道所有脏页?

【问题讨论】:

    标签: memory-management filesystems operating-system linux-kernel


    【解决方案1】:

    他们都在一个place

    struct bdi_writeback {
            struct backing_dev_info *bdi;   /* our parent bdi */
            unsigned int nr;
    
            unsigned long last_old_flush;   /* last old data flush */
            unsigned long last_active;      /* last time bdi thread was active */
    
            struct task_struct *task;       /* writeback thread */
            struct timer_list wakeup_timer; /* used for delayed bdi thread wakeup */
            struct list_head b_dirty;       /* dirty inodes */
            struct list_head b_io;          /* parked for writeback */
            struct list_head b_more_io;     /* parked for more writeback */
            spinlock_t list_lock;           /* protects the b_* lists */
    };
    

    b_dirty 是您要查找的列表。

    有关刷新如何发生的一些信息,请查看in here。虽然代码有点复杂。总结一下(很多),考虑到在默认配置中写入磁盘的数据将保留在内存中,直到 a)它们超过 30 秒,或者 b)脏页消耗了超过 10% 的活动、工作记忆。

    【讨论】:

      【解决方案2】:

      在 x86 平台上,操作系统必须检查其page table entries 以查找脏页。其中有一个特殊的 dirty 位,由 CPU 在内存写入期间自动设置。一定有一些代码可以扫描PTEs 寻找dirty=1。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-08-29
        • 1970-01-01
        • 1970-01-01
        • 2016-03-20
        相关资源
        最近更新 更多