linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: <zhouxianrong@huawei.com>
To: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	jack@suse.cz, kirill.shutemov@linux.intel.com,
	ross.zwisler@linux.intel.com, mhocko@suse.com,
	dave.jiang@intel.com, aneesh.kumar@linux.vnet.ibm.com,
	minchan@kernel.org, mingo@kernel.org, jglisse@redhat.com,
	willy@linux.intel.com, hughd@google.com, zhouxianrong@huawei.com,
	zhouxiyu@huawei.com, weidu.du@huawei.com, fanghua3@huawei.com,
	hutj@huawei.com, won.ho.park@huawei.com
Subject: [PATCH] mm: try to free swap only for reading swap fault
Date: Thu, 2 Nov 2017 20:35:19 +0800	[thread overview]
Message-ID: <1509626119-39916-1-git-send-email-zhouxianrong@huawei.com> (raw)

From: zhouxianrong <zhouxianrong@huawei.com>

the purpose of this patch is that when a reading swap fault
happens on a clean swap cache page whose swap count is equal
to one, then try_to_free_swap could remove this page from 
swap cache and mark this page dirty. so if later we reclaimed
this page then we could pageout this page due to this dirty.
so i want to allow this action only for writing swap fault.

i sampled the data of non-dirty anonymous pages which is no
need to pageout and total anonymous pages in shrink_page_list.

the results are:

        non-dirty anonymous pages     total anonymous pages
before  26343                         635218
after   36907                         634312

Signed-off-by: zhouxianrong <zhouxianrong@huawei.com>
---
 mm/memory.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memory.c b/mm/memory.c
index a728bed..5a944fe 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2999,7 +2999,7 @@ int do_swap_page(struct vm_fault *vmf)
 	}
 
 	swap_free(entry);
-	if (mem_cgroup_swap_full(page) ||
+	if (((vmf->flags & FAULT_FLAG_WRITE) && mem_cgroup_swap_full(page)) ||
 	    (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
 		try_to_free_swap(page);
 	unlock_page(page);
-- 
1.7.9.5

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

             reply	other threads:[~2017-11-02 12:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-02 12:35 zhouxianrong [this message]
2017-11-02 13:22 ` Michal Hocko
2017-11-03  3:31   ` zhouxianrong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1509626119-39916-1-git-send-email-zhouxianrong@huawei.com \
    --to=zhouxianrong@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=dave.jiang@intel.com \
    --cc=fanghua3@huawei.com \
    --cc=hughd@google.com \
    --cc=hutj@huawei.com \
    --cc=jack@suse.cz \
    --cc=jglisse@redhat.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=minchan@kernel.org \
    --cc=mingo@kernel.org \
    --cc=ross.zwisler@linux.intel.com \
    --cc=weidu.du@huawei.com \
    --cc=willy@linux.intel.com \
    --cc=won.ho.park@huawei.com \
    --cc=zhouxiyu@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox