From: Suren Baghdasaryan <surenb@google.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: stable <stable@vger.kernel.org>, Jann Horn <jannh@google.com>,
Kirill Tkhai <ktkhai@virtuozzo.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Shaohua Li <shli@fb.com>, Nadav Amit <namit@vmware.com>,
linux-mm <linux-mm@kvack.org>,
LKML <linux-kernel@vger.kernel.org>,
kernel-team <kernel-team@android.com>,
Yang Shi <yang.shi@linux.alibaba.com>,
"Kirill A. Shutemov" <kirill@shutemov.name>,
Hugh Dickins <hughd@google.com>,
Andrea Arcangeli <aarcange@redhat.com>,
Christian Koenig <christian.koenig@amd.com>,
Claudio Imbrenda <imbrenda@linux.vnet.ibm.com>,
Rik van Riel <riel@surriel.com>,
Huang Ying <ying.huang@intel.com>,
Minchan Kim <minchan@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 1/5] mm: reuse only-pte-mapped KSM page in do_wp_page()
Date: Thu, 1 Apr 2021 12:47:13 -0700 [thread overview]
Message-ID: <CAJuCfpG18PvjmcMma_rKSBRfUHui3TJ73w8f+fDmzv3Vi__HMA@mail.gmail.com> (raw)
In-Reply-To: <YGYhJxFpfCx9VqZS@kroah.com>
On Thu, Apr 1, 2021 at 12:38 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Thu, Apr 01, 2021 at 11:17:37AM -0700, Suren Baghdasaryan wrote:
> > From: Kirill Tkhai <ktkhai@virtuozzo.com>
> >
> > Add an optimization for KSM pages almost in the same way that we have
> > for ordinary anonymous pages. If there is a write fault in a page,
> > which is mapped to an only pte, and it is not related to swap cache; the
> > page may be reused without copying its content.
> >
> > [ Note that we do not consider PageSwapCache() pages at least for now,
> > since we don't want to complicate __get_ksm_page(), which has nice
> > optimization based on this (for the migration case). Currenly it is
> > spinning on PageSwapCache() pages, waiting for when they have
> > unfreezed counters (i.e., for the migration finish). But we don't want
> > to make it also spinning on swap cache pages, which we try to reuse,
> > since there is not a very high probability to reuse them. So, for now
> > we do not consider PageSwapCache() pages at all. ]
> >
> > So in reuse_ksm_page() we check for 1) PageSwapCache() and 2)
> > page_stable_node(), to skip a page, which KSM is currently trying to
> > link to stable tree. Then we do page_ref_freeze() to prohibit KSM to
> > merge one more page into the page, we are reusing. After that, nobody
> > can refer to the reusing page: KSM skips !PageSwapCache() pages with
> > zero refcount; and the protection against of all other participants is
> > the same as for reused ordinary anon pages pte lock, page lock and
> > mmap_sem.
> >
> > [akpm@linux-foundation.org: replace BUG_ON()s with WARN_ON()s]
> > Link: http://lkml.kernel.org/r/154471491016.31352.1168978849911555609.stgit@localhost.localdomain
> > Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
> > Reviewed-by: Yang Shi <yang.shi@linux.alibaba.com>
> > Cc: "Kirill A. Shutemov" <kirill@shutemov.name>
> > Cc: Hugh Dickins <hughd@google.com>
> > Cc: Andrea Arcangeli <aarcange@redhat.com>
> > Cc: Christian Koenig <christian.koenig@amd.com>
> > Cc: Claudio Imbrenda <imbrenda@linux.vnet.ibm.com>
> > Cc: Rik van Riel <riel@surriel.com>
> > Cc: Huang Ying <ying.huang@intel.com>
> > Cc: Minchan Kim <minchan@kernel.org>
> > Cc: Kirill Tkhai <ktkhai@virtuozzo.com>
> > Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> > Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
> > ---
> > include/linux/ksm.h | 7 +++++++
> > mm/ksm.c | 30 ++++++++++++++++++++++++++++--
> > mm/memory.c | 16 ++++++++++++++--
> > 3 files changed, 49 insertions(+), 4 deletions(-)
>
> You forgot to put the git commit id of the upstream commit in here
> somewhere so we can properly reference it and track it.
>
> When/if you resend this, please add it to all of the commits.
Will do. Thanks!
>
> thanks,
>
> greg k-h
next prev parent reply other threads:[~2021-04-01 19:47 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-01 18:17 [PATCH 0/5] 4.14 backports of fixes for "CoW after fork() issue" Suren Baghdasaryan
2021-04-01 18:17 ` [PATCH 1/5] mm: reuse only-pte-mapped KSM page in do_wp_page() Suren Baghdasaryan
2021-04-01 19:38 ` Greg KH
2021-04-01 19:47 ` Suren Baghdasaryan [this message]
2021-04-01 18:17 ` [PATCH 2/5] mm: do_wp_page() simplification Suren Baghdasaryan
2021-04-01 18:17 ` [PATCH 3/5] mm: fix misplaced unlock_page in do_wp_page() Suren Baghdasaryan
2021-04-01 18:17 ` [PATCH 4/5] userfaultfd: wp: add helper for writeprotect check Suren Baghdasaryan
2021-04-01 18:17 ` [PATCH 5/5] mm/userfaultfd: fix memory corruption due to writeprotect Suren Baghdasaryan
2021-04-01 18:59 ` [PATCH 0/5] 4.14 backports of fixes for "CoW after fork() issue" Linus Torvalds
2021-04-01 19:43 ` Suren Baghdasaryan
2021-04-01 23:47 ` Peter Xu
2021-04-02 0:12 ` Suren Baghdasaryan
2021-04-07 13:21 ` Vlastimil Babka
2021-04-07 14:30 ` Peter Xu
2021-04-07 16:07 ` Linus Torvalds
2021-04-07 16:33 ` Suren Baghdasaryan
2021-04-07 17:04 ` Linus Torvalds
2021-04-07 18:47 ` Mikulas Patocka
2021-04-07 19:22 ` Linus Torvalds
2021-04-07 21:53 ` Suren Baghdasaryan
2021-04-21 20:01 ` Suren Baghdasaryan
2021-04-21 21:05 ` Peter Xu
2021-04-21 21:17 ` Suren Baghdasaryan
2021-04-21 23:01 ` Suren Baghdasaryan
2021-04-21 22:59 ` Vlastimil Babka
2021-04-21 23:05 ` Suren Baghdasaryan
2021-04-01 18:21 [PATCH 0/5] 4.19 " Suren Baghdasaryan
2021-04-01 18:21 ` [PATCH 1/5] mm: reuse only-pte-mapped KSM page in do_wp_page() Suren Baghdasaryan
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=CAJuCfpG18PvjmcMma_rKSBRfUHui3TJ73w8f+fDmzv3Vi__HMA@mail.gmail.com \
--to=surenb@google.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=christian.koenig@amd.com \
--cc=gregkh@linuxfoundation.org \
--cc=hughd@google.com \
--cc=imbrenda@linux.vnet.ibm.com \
--cc=jannh@google.com \
--cc=kernel-team@android.com \
--cc=kirill@shutemov.name \
--cc=ktkhai@virtuozzo.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=namit@vmware.com \
--cc=riel@surriel.com \
--cc=shli@fb.com \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=yang.shi@linux.alibaba.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
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;
as well as URLs for NNTP newsgroup(s).