Linux-mm Archive on lore.kernel.org
 help / color / Atom feed
From: huang ying <huang.ying.caritas@gmail.com>
To: Minchan Kim <minchan@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, LKML <linux-kernel@vger.kernel.org>,
	kernel-team <kernel-team@lge.com>, Christoph Hellwig <hch@lst.de>,
	Dan Williams <dan.j.williams@intel.com>,
	Ross Zwisler <ross.zwisler@linux.intel.com>,
	Hugh Dickins <hughd@google.com>,
	Huang Ying <ying.huang@intel.com>
Subject: Re: [PATCH v2 4/4] mm:swap: skip swapcache for swapin of synchronous device
Date: Mon, 9 Oct 2017 09:26:18 +0800
Message-ID: <CAC=cRTN=1saVebn7E+Rpjh+WiOBthwO=v71+mmNJzmbP7REFOw@mail.gmail.com> (raw)
In-Reply-To: <CAC=cRTMm41DpnSdv0BvBDLcdfgyssD2u5xqUmGUgZ5RdGroWhQ@mail.gmail.com>

On Fri, Sep 29, 2017 at 4:51 PM, huang ying
<huang.ying.caritas@gmail.com> wrote:
> On Wed, Sep 20, 2017 at 1:43 PM, Minchan Kim <minchan@kernel.org> wrote:

[snip]

>> diff --git a/mm/memory.c b/mm/memory.c
>> index ec4e15494901..163ab2062385 100644
>> --- a/mm/memory.c
>> +++ b/mm/memory.c
>> @@ -2842,7 +2842,7 @@ EXPORT_SYMBOL(unmap_mapping_range);
>>  int do_swap_page(struct vm_fault *vmf)
>>  {
>>         struct vm_area_struct *vma = vmf->vma;
>> -       struct page *page = NULL, *swapcache;
>> +       struct page *page = NULL, *swapcache = NULL;
>>         struct mem_cgroup *memcg;
>>         struct vma_swap_readahead swap_ra;
>>         swp_entry_t entry;
>> @@ -2881,17 +2881,35 @@ int do_swap_page(struct vm_fault *vmf)
>>                 }
>>                 goto out;
>>         }
>> +
>> +
>>         delayacct_set_flag(DELAYACCT_PF_SWAPIN);
>>         if (!page)
>>                 page = lookup_swap_cache(entry, vma_readahead ? vma : NULL,
>>                                          vmf->address);
>>         if (!page) {
>> -               if (vma_readahead)
>> -                       page = do_swap_page_readahead(entry,
>> -                               GFP_HIGHUSER_MOVABLE, vmf, &swap_ra);
>> -               else
>> -                       page = swapin_readahead(entry,
>> -                               GFP_HIGHUSER_MOVABLE, vma, vmf->address);
>> +               struct swap_info_struct *si = swp_swap_info(entry);
>> +
>> +               if (!(si->flags & SWP_SYNCHRONOUS_IO)) {
>> +                       if (vma_readahead)
>> +                               page = do_swap_page_readahead(entry,
>> +                                       GFP_HIGHUSER_MOVABLE, vmf, &swap_ra);
>> +                       else
>> +                               page = swapin_readahead(entry,
>> +                                       GFP_HIGHUSER_MOVABLE, vma, vmf->address);
>> +                       swapcache = page;
>> +               } else {
>> +                       /* skip swapcache */
>> +                       page = alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, vmf->address);
>> +                       if (page) {
>> +                               __SetPageLocked(page);
>> +                               __SetPageSwapBacked(page);
>> +                               set_page_private(page, entry.val);
>> +                               lru_cache_add_anon(page);
>> +                               swap_readpage(page, true);
>> +                       }
>> +               }
>
> I have a question for this.  If a page is mapped in multiple processes
> (for example, because of fork).  With swap cache, after swapping out
> and swapping in, the page will be still shared by these processes.
> But with your changes, it appears that there will be multiple pages
> with same contents mapped in multiple processes, even if the page
> isn't written in these processes.  So this may waste some memory in
> some situation?  And copying from device is even faster than looking
> up swap cache in your system?

Hi, Minchan,

Could you help me on this?

Best Regards,
Huang, Ying

[snip]

--
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 index

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-20  5:43 [PATCH v2 0/4] skip swapcache for super fast device Minchan Kim
2017-09-20  5:43 ` [PATCH v2 1/4] zram: set BDI_CAP_STABLE_WRITES once Minchan Kim
2017-09-20  5:43 ` [PATCH v2 2/4] bdi: introduce BDI_CAP_SYNCHRONOUS_IO Minchan Kim
2017-09-20  5:43 ` [PATCH v2 3/4] mm:swap: introduce SWP_SYNCHRONOUS_IO Minchan Kim
2017-09-20  5:43 ` [PATCH v2 4/4] mm:swap: skip swapcache for swapin of synchronous device Minchan Kim
2017-09-29  8:51   ` huang ying
2017-10-09  1:26     ` huang ying [this message]
2017-10-10  0:34     ` Minchan Kim
2017-10-10  1:10       ` Huang, Ying
  -- strict thread matches above, loose matches on Subject: below --
2017-09-19  7:09 [PATCH v2 0/4] skip swapcache for super fast device Minchan Kim
2017-09-19  7:10 ` [PATCH v2 4/4] mm:swap: skip swapcache for swapin of synchronous device Minchan Kim

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='CAC=cRTN=1saVebn7E+Rpjh+WiOBthwO=v71+mmNJzmbP7REFOw@mail.gmail.com' \
    --to=huang.ying.caritas@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=dan.j.williams@intel.com \
    --cc=hch@lst.de \
    --cc=hughd@google.com \
    --cc=kernel-team@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan@kernel.org \
    --cc=ross.zwisler@linux.intel.com \
    --cc=ying.huang@intel.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

Linux-mm Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mm/0 linux-mm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mm linux-mm/ https://lore.kernel.org/linux-mm \
		linux-mm@kvack.org
	public-inbox-index linux-mm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kvack.linux-mm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git