Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 356632
b: refs/heads/master
c: 56f3180
h: refs/heads/master
v: v3
  • Loading branch information
Hugh Dickins authored and Linus Torvalds committed Feb 24, 2013
1 parent dedac55 commit 3fb59a5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9e16b7fb1d066d38d01fd57c449f2640c5d208cb
refs/heads/master: 56f31801ccdecb420d0d1fd2bf9f337c355214a9
18 changes: 8 additions & 10 deletions trunk/mm/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -2954,7 +2954,7 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
unsigned int flags, pte_t orig_pte)
{
spinlock_t *ptl;
struct page *page, *swapcache = NULL;
struct page *page, *swapcache;
swp_entry_t entry;
pte_t pte;
int locked;
Expand Down Expand Up @@ -3005,9 +3005,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
*/
ret = VM_FAULT_HWPOISON;
delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
swapcache = page;
goto out_release;
}

swapcache = page;
locked = lock_page_or_retry(page, mm, flags);

delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
Expand All @@ -3025,16 +3027,12 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
if (unlikely(!PageSwapCache(page) || page_private(page) != entry.val))
goto out_page;

swapcache = page;
page = ksm_might_need_to_copy(page, vma, address);
if (unlikely(!page)) {
ret = VM_FAULT_OOM;
page = swapcache;
swapcache = NULL;
goto out_page;
}
if (page == swapcache)
swapcache = NULL;

if (mem_cgroup_try_charge_swapin(mm, page, GFP_KERNEL, &ptr)) {
ret = VM_FAULT_OOM;
Expand Down Expand Up @@ -3078,18 +3076,18 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
}
flush_icache_page(vma, page);
set_pte_at(mm, address, page_table, pte);
if (swapcache) /* ksm created a completely new copy */
page_add_new_anon_rmap(page, vma, address);
else
if (page == swapcache)
do_page_add_anon_rmap(page, vma, address, exclusive);
else /* ksm created a completely new copy */
page_add_new_anon_rmap(page, vma, address);
/* It's better to call commit-charge after rmap is established */
mem_cgroup_commit_charge_swapin(page, ptr);

swap_free(entry);
if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
try_to_free_swap(page);
unlock_page(page);
if (swapcache) {
if (page != swapcache) {
/*
* Hold the lock to avoid the swap entry to be reused
* until we take the PT lock for the pte_same() check
Expand Down Expand Up @@ -3122,7 +3120,7 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
unlock_page(page);
out_release:
page_cache_release(page);
if (swapcache) {
if (page != swapcache) {
unlock_page(swapcache);
page_cache_release(swapcache);
}
Expand Down

0 comments on commit 3fb59a5

Please sign in to comment.