[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJuCfpG18PvjmcMma_rKSBRfUHui3TJ73w8f+fDmzv3Vi__HMA@mail.gmail.com>
Date: Thu, 1 Apr 2021 12:47:13 -0700
From: Suren Baghdasaryan <surenb@...gle.com>
To: Greg KH <gregkh@...uxfoundation.org>
Cc: stable <stable@...r.kernel.org>, Jann Horn <jannh@...gle.com>,
Kirill Tkhai <ktkhai@...tuozzo.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Shaohua Li <shli@...com>, Nadav Amit <namit@...are.com>,
linux-mm <linux-mm@...ck.org>,
LKML <linux-kernel@...r.kernel.org>,
kernel-team <kernel-team@...roid.com>,
Yang Shi <yang.shi@...ux.alibaba.com>,
"Kirill A. Shutemov" <kirill@...temov.name>,
Hugh Dickins <hughd@...gle.com>,
Andrea Arcangeli <aarcange@...hat.com>,
Christian Koenig <christian.koenig@....com>,
Claudio Imbrenda <imbrenda@...ux.vnet.ibm.com>,
Rik van Riel <riel@...riel.com>,
Huang Ying <ying.huang@...el.com>,
Minchan Kim <minchan@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH 1/5] mm: reuse only-pte-mapped KSM page in do_wp_page()
On Thu, Apr 1, 2021 at 12:38 PM Greg KH <gregkh@...uxfoundation.org> wrote:
>
> On Thu, Apr 01, 2021 at 11:17:37AM -0700, Suren Baghdasaryan wrote:
> > From: Kirill Tkhai <ktkhai@...tuozzo.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@...ux-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@...tuozzo.com>
> > Reviewed-by: Yang Shi <yang.shi@...ux.alibaba.com>
> > Cc: "Kirill A. Shutemov" <kirill@...temov.name>
> > Cc: Hugh Dickins <hughd@...gle.com>
> > Cc: Andrea Arcangeli <aarcange@...hat.com>
> > Cc: Christian Koenig <christian.koenig@....com>
> > Cc: Claudio Imbrenda <imbrenda@...ux.vnet.ibm.com>
> > Cc: Rik van Riel <riel@...riel.com>
> > Cc: Huang Ying <ying.huang@...el.com>
> > Cc: Minchan Kim <minchan@...nel.org>
> > Cc: Kirill Tkhai <ktkhai@...tuozzo.com>
> > Signed-off-by: Andrew Morton <akpm@...ux-foundation.org>
> > Signed-off-by: Linus Torvalds <torvalds@...ux-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
Powered by blists - more mailing lists