- 论坛徽章:
- 4
|
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.
|