- 论坛徽章:
- 16
|
本帖最后由 embeddedlwp 于 2012-05-27 21:00 编辑
回复 17# 塑料袋
考虑两种情况:
1.一个进程的anon page要被PFRA swap out,已经调用了add_to_swap和try_to_unmap,但是swap cache中的page还没释放呢,此时进程要访问这个page啦,又要swap in,在swap cache里找到了page,填充了进程的pte,然后呢?shrink_page_list函数既然调用完了add_to_swap和try_to_unmap,接下如果页脏要写回,会从swap cache中删除page吗,还有这个pte被设置了,会再次调用try_to_unmap吗?
2.在add_to_swap函数中:
int add_to_swap(struct page * page, gfp_t gfp_mask)
{
swp_entry_t entry;
int err;
BUG_ON(!PageLocked(page));
for (;;) {
entry = get_swap_page();
if (!entry.val)
return 0;
/*
* Radix-tree node allocations from PF_MEMALLOC contexts could
* completely exhaust the page allocator. __GFP_NOMEMALLOC
* stops emergency reserves from being allocated.
*
* TODO: this could cause a theoretical memory reclaim
* deadlock in the swap out path.
*/
/*
* Add it to the swap cache and mark it dirty
*/
err = __add_to_swap_cache(page, entry,
gfp_mask|__GFP_NOMEMALLOC|__GFP_NOWARN);
switch (err) {
case 0: /* Success */
SetPageUptodate(page);
SetPageDirty(page);
INC_CACHE_INFO(add_total);
return 1;
case -EEXIST:
/* Raced with "speculative" read_swap_cache_async */
INC_CACHE_INFO(exist_race);
swap_free(entry);
continue;
default:
/* -ENOMEM radix-tree allocation failure */
swap_free(entry);
return 0;
}
}
}
红色部分,发生啥race,抢锁?还是抢什么?找了半天没看到抢什么啊?
|
|