linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: zhouxianrong <zhouxianrong@huawei.com>
To: "Huang, Ying" <ying.huang@intel.com>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"tim.c.chen@linux.intel.com" <tim.c.chen@linux.intel.com>,
	"mhocko@suse.com" <mhocko@suse.com>,
	"rientjes@google.com" <rientjes@google.com>,
	"mingo@kernel.org" <mingo@kernel.org>,
	"vegard.nossum@oracle.com" <vegard.nossum@oracle.com>,
	"minchan@kernel.org" <minchan@kernel.org>,
	"aaron.lu@intel.com" <aaron.lu@intel.com>,
	Zhouxiyu <zhouxiyu@huawei.com>,
	"Duwei (Device OS)" <weidu.du@huawei.com>,
	fanghua <fanghua3@huawei.com>, hutj <hutj@huawei.com>,
	Won Ho Park <won.ho.park@huawei.com>
Subject: 答复: [PATCH] mm: extend reuse_swap_page range as much as possible
Date: Thu, 2 Nov 2017 02:09:57 +0000	[thread overview]
Message-ID: <AE94847B1D9E864B8593BD8051012AF36E13E3BE@DGGEMA505-MBS.china.huawei.com> (raw)
In-Reply-To: <87tvyd4fsx.fsf@yhuang-dev.intel.com>

<zhouxianrong@huawei.com> writes:

> From: zhouxianrong <zhouxianrong@huawei.com>
>
> origanlly reuse_swap_page requires that the sum of page's mapcount and 
> swapcount less than or equal to one.
> in this case we can reuse this page and avoid COW currently.
>
> now reuse_swap_page requires only that page's mapcount less than or 
> equal to one and the page is not dirty in swap cache. in this case we 
> do not care its swap count.
>
> the page without dirty in swap cache means that it has been written to 
> swap device successfully for reclaim before and then read again on a 
> swap fault. in this case the page can be reused even though its swap 
> count is greater than one and postpone the COW on other successive 
> accesses to the swap cache page later rather than now.
>
> i did this patch test in kernel 4.4.23 with arm64 and none huge 
> memory. it work fine.

Why do you need this?  You saved copying one page from memory to memory
(COW) now, at the cost of reading a page from disk to memory later?

yes, accessing later does not always happen, there is probability for it, so postpone COW now.

Best Regards,
Huang, Ying

> Signed-off-by: zhouxianrong <zhouxianrong@huawei.com>
> ---
>  mm/swapfile.c |    9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/mm/swapfile.c b/mm/swapfile.c index bf91dc9..c21cf07 
> 100644
> --- a/mm/swapfile.c
> +++ b/mm/swapfile.c
> @@ -1543,22 +1543,27 @@ static int 
> page_trans_huge_map_swapcount(struct page *page, int *total_mapcount,  
> bool reuse_swap_page(struct page *page, int *total_map_swapcount)  {
>  	int count, total_mapcount, total_swapcount;
> +	int dirty;
>  
>  	VM_BUG_ON_PAGE(!PageLocked(page), page);
>  	if (unlikely(PageKsm(page)))
>  		return false;
> +	dirty = PageDirty(page);
>  	count = page_trans_huge_map_swapcount(page, &total_mapcount,
>  					      &total_swapcount);
>  	if (total_map_swapcount)
>  		*total_map_swapcount = total_mapcount + total_swapcount;
> -	if (count == 1 && PageSwapCache(page) &&
> +	if ((total_mapcount <= 1 && !dirty) ||
> +		(count == 1 && PageSwapCache(page) &&
>  	    (likely(!PageTransCompound(page)) ||
>  	     /* The remaining swap count will be freed soon */
> -	     total_swapcount == page_swapcount(page))) {
> +	     total_swapcount == page_swapcount(page)))) {
>  		if (!PageWriteback(page)) {
>  			page = compound_head(page);
>  			delete_from_swap_cache(page);
>  			SetPageDirty(page);
> +			if (!dirty)
> +				return true;
>  		} else {
>  			swp_entry_t entry;
>  			struct swap_info_struct *p;

  reply	other threads:[~2017-11-02  2:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-01 10:51 zhouxianrong
2017-11-02  1:42 ` Huang, Ying
2017-11-02  2:09   ` zhouxianrong [this message]
2017-11-02  4:22     ` 答复: " Minchan Kim
2017-11-02  7:49       ` Michal Hocko

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=AE94847B1D9E864B8593BD8051012AF36E13E3BE@DGGEMA505-MBS.china.huawei.com \
    --to=zhouxianrong@huawei.com \
    --cc=aaron.lu@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=fanghua3@huawei.com \
    --cc=hutj@huawei.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=rientjes@google.com \
    --cc=tim.c.chen@linux.intel.com \
    --cc=vegard.nossum@oracle.com \
    --cc=weidu.du@huawei.com \
    --cc=won.ho.park@huawei.com \
    --cc=ying.huang@intel.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