linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vineeth Pillai <vpillai@digitalocean.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Huang Ying <ying.huang@intel.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Rik van Riel <riel@redhat.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Minchan Kim <minchan@kernel.org>, Shaohua Li <shli@kernel.org>,
	Daniel Jordan <daniel.m.jordan@oracle.com>,
	Hugh Dickins <hughd@google.com>,
	Kelley Nielsen <kelleynnn@gmail.com>
Subject: Re: [PATCH] mm, swap: Fix swapoff with KSM pages
Date: Fri, 28 Dec 2018 11:56:39 -0500	[thread overview]
Message-ID: <CANaguZDGr+WbaJ1czsOvcHCSNAyusK6KAHNhNppe_9hwQhAFtg@mail.gmail.com> (raw)
In-Reply-To: <20181227185553.81928247d95418191b063d40@linux-foundation.org>

[-- Attachment #1: Type: text/plain, Size: 2372 bytes --]

Thanks for letting me know Andrew! I shall include all the fixes in the
next iteration.

Thanks,
Vineeth

On Thu, Dec 27, 2018 at 9:55 PM Andrew Morton <akpm@linux-foundation.org>
wrote:

> On Wed, 26 Dec 2018 13:15:22 +0800 Huang Ying <ying.huang@intel.com>
> wrote:
>
> > KSM pages may be mapped to the multiple VMAs that cannot be reached
> > from one anon_vma.  So during swapin, a new copy of the page need to
> > be generated if a different anon_vma is needed, please refer to
> > comments of ksm_might_need_to_copy() for details.
> >
> > During swapoff, unuse_vma() uses anon_vma (if available) to locate VMA
> > and virtual address mapped to the page, so not all mappings to a
> > swapped out KSM page could be found.  So in try_to_unuse(), even if
> > the swap count of a swap entry isn't zero, the page needs to be
> > deleted from swap cache, so that, in the next round a new page could
> > be allocated and swapin for the other mappings of the swapped out KSM
> > page.
> >
> > But this contradicts with the THP swap support.  Where the THP could
> > be deleted from swap cache only after the swap count of every swap
> > entry in the huge swap cluster backing the THP has reach 0.  So
> > try_to_unuse() is changed in commit e07098294adf ("mm, THP, swap:
> > support to reclaim swap space for THP swapped out") to check that
> > before delete a page from swap cache, but this has broken KSM swapoff
> > too.
> >
> > Fortunately, KSM is for the normal pages only, so the original
> > behavior for KSM pages could be restored easily via checking
> > PageTransCompound().  That is how this patch works.
> >
> > ...
> >
> > --- a/mm/swapfile.c
> > +++ b/mm/swapfile.c
> > @@ -2197,7 +2197,8 @@ int try_to_unuse(unsigned int type, bool frontswap,
> >                */
> >               if (PageSwapCache(page) &&
> >                   likely(page_private(page) == entry.val) &&
> > -                 !page_swapped(page))
> > +                 (!PageTransCompound(page) ||
> > +                  !swap_page_trans_huge_swapped(si, entry)))
> >                       delete_from_swap_cache(compound_head(page));
> >
>
> The patch "mm, swap: rid swapoff of quadratic complexity" changes this
> code significantly.  There are a few issues with that patch so I'll
> drop it for now.
>
> Vineeth, please ensure that future versions retain the above fix,
> thanks.
>
>
>

[-- Attachment #2: Type: text/html, Size: 3439 bytes --]

  reply	other threads:[~2018-12-28 16:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-26  5:15 Huang Ying
2018-12-26  5:37 ` Huang, Ying
2018-12-26  5:37   ` Huang, Ying
2018-12-28  2:55 ` Andrew Morton
2018-12-28 16:56   ` Vineeth Pillai [this message]
2018-12-28 16:56     ` Vineeth Pillai

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=CANaguZDGr+WbaJ1czsOvcHCSNAyusK6KAHNhNppe_9hwQhAFtg@mail.gmail.com \
    --to=vpillai@digitalocean.com \
    --cc=akpm@linux-foundation.org \
    --cc=daniel.m.jordan@oracle.com \
    --cc=hannes@cmpxchg.org \
    --cc=hughd@google.com \
    --cc=kelleynnn@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan@kernel.org \
    --cc=riel@redhat.com \
    --cc=shli@kernel.org \
    --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
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