免费注册 查看新帖 |

Chinaunix

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

[内存管理] 回收页框的疑问。。。 [复制链接]

论坛徽章:
4
酉鸡
日期:2014-03-21 23:19:50狮子座
日期:2014-08-01 22:11:40酉鸡
日期:2015-01-10 21:31:442015年辞旧岁徽章
日期:2015-03-03 16:54:15
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-05-10 12:38 |只看该作者 |倒序浏览
30可用积分
本帖最后由 chishanmingshen 于 2013-05-10 20:46 编辑

int try_to_free_swap(struct page *page)
{
        VM_BUG_ON(!PageLocked(page));

        if (!PageSwapCache(page))
                return 0;
        if (PageWriteback(page))
                return 0;
        if (page_swapcount(page))
                return 0;

        /*
         * Once hibernation has begun to create its image of memory,
         * there's a danger that one of the calls to try_to_free_swap()
         * - most probably a call from __try_to_reclaim_swap() while
         * hibernation is allocating its own swap pages for the image,
         * but conceivably even a call from memory reclaim - will free
         * the swap from a page which has already been recorded in the
         * image as a clean swapcache page, and then reuse its swap for
         * another page of the image.  On waking from hibernation, the
         * original page might be freed under memory pressure, then
         * later read back in from swap, now with the wrong data.
         *
         * Hibration suspends storage while it is writing the image
         * to disk so check that here.
         */

        if (pm_suspended_storage())
                return 0;

        delete_from_swap_cache(page);
        SetPageDirty(page);
        return 1;
}

如何理解这个大段注释的case?请大家指点,谢谢!

最佳答案

查看完整内容

In portable devices it is useful to write a hibernation image to disk, and then suspend. If the battery runs out or power is otherwise lost, the computer will power off, but it will be resumed from the hibernated image. If not, it will resume normally from memory suspend, and hibernation image will be discarded.

论坛徽章:
1
双鱼座
日期:2013-08-28 13:47:26
2 [报告]
发表于 2013-05-10 12:38 |只看该作者
In portable devices it is useful to write a hibernation image to disk, and then suspend. If the battery runs out or power is otherwise lost, the computer will power off, but it will be resumed from the hibernated image. If not, it will resume normally from memory suspend, and hibernation image will be discarded.

论坛徽章:
4
酉鸡
日期:2014-03-21 23:19:50狮子座
日期:2014-08-01 22:11:40酉鸡
日期:2015-01-10 21:31:442015年辞旧岁徽章
日期:2015-03-03 16:54:15
3 [报告]
发表于 2013-05-11 15:31 |只看该作者
回复 2# firkraag

谢谢,是说内存休眠?


   

论坛徽章:
4
酉鸡
日期:2014-03-21 23:19:50狮子座
日期:2014-08-01 22:11:40酉鸡
日期:2015-01-10 21:31:442015年辞旧岁徽章
日期:2015-03-03 16:54:15
4 [报告]
发表于 2013-05-18 08:48 |只看该作者
回复 2# firkraag


谢谢!(☆_☆)

   
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP