From: Hugh Dickins <hugh.dickins@tiscali.co.uk>
To: Andrea Arcangeli <aarcange@redhat.com>
Cc: Izik Eidus <ieidus@redhat.com>,
akpm@linux-foundation.org, chrisw@redhat.com, avi@redhat.com,
riel@redhat.com, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, nickpiggin@yahoo.com.au,
Wu Fengguang <fengguang.wu@intel.com>
Subject: Re: [PATCH 06/10] ksm: identify PageKsm pages
Date: Wed, 22 Jul 2009 13:45:15 +0100 (BST) [thread overview]
Message-ID: <Pine.LNX.4.64.0907221313370.529@sister.anvils> (raw)
In-Reply-To: <20090721175139.GE2239@random.random>
On Tue, 21 Jul 2009, Andrea Arcangeli wrote:
> On Fri, Jul 17, 2009 at 08:30:46PM +0300, Izik Eidus wrote:
> > +static inline int PageKsm(struct page *page)
> > +{
> > + return ((unsigned long)page->mapping == PAGE_MAPPING_ANON);
> > +}
>
> I'm unconvinced it's sane to have PageAnon return 1 on Ksm pages.
If they're to be vm_normal_page pages (I think we'll agree they are),
then for now they have to be counted either as file pages or as anon
pages. We could trawl through mm/ adding the third category for KSM
pages, but I don't think that would be sensible - KSM is mostly
keeping out of everybody's way, and I want to preserve that.
They're not file pages in any sense, and they're clearly anon pages:
I got quite alarmed by the original /dev/ksm KSM, when I found my
task's anon rss going down and its file rss going up - there used
to be a special transfer from anon to file rss in replace_page().
I certainly agree they're a _special_ case of anon page,
and I think that's reflected by the NULL anon_vma.
I think you're getting sidetracked by the knowledge that they're
not just ordinary anon pages: yes, but they're certainly not file
pages, they are anonymous pages.
>
> The above will also have short lifetime so not sure it's worth it,
> if we want to swap we'll have to move to something that to:
>
> PageExternal()
> {
> return (unsigned long)page->mapping & PAGE_MAPPING_EXTERNAL != 0;
> }
I don't know about "External" (sounds like you have plans beyond KSM
that Izik is aware of but I'm not); but yes, I was imagining that for
swapping these pages we will use a PAGE_MAPPING_KSM bit 2 (set in
addition to PAGE_MAPPING_ANON), so that the pointer in page->mapping
needn't be NULL, but point somewhere useful into the stable tree,
to enable rmap.c operations on these pages.
But I'd still expect them to be PageAnon: even more so, really -
once they're swapping, they're even more ordinary anonymous pages.
>
> > +static inline void page_add_ksm_rmap(struct page *page)
> > +{
> > + if (atomic_inc_and_test(&page->_mapcount)) {
> > + page->mapping = (void *) PAGE_MAPPING_ANON;
> > + __inc_zone_page_state(page, NR_ANON_PAGES);
> > + }
> > +}
>
> Is it correct to account them as anon pages?
Yes: surely, they're not file pages, and that is the alternative.
Leave them out of such accounting completely, or give them their
own stats: yes, that can be done, but not without changes elsewhere;
which I think we'd prefer not to press until KSM is a more accepted
part of regular mm operation.
>
> > - if (PageAnon(old_page)) {
> > + if (PageAnon(old_page) && !PageKsm(old_page)) {
> > if (!trylock_page(old_page)) {
> > page_cache_get(old_page);
> > pte_unmap_unlock(page_table, ptl);
>
> What exactly does it buy to have PageAnon return 1 on ksm pages,
> besides requiring the above additional check (that if we stick to the
> above code, I would find safer to move inside reuse_swap_page).
That's certainly the ugliest part of accepting PageKsm pages as
PageAnon, and I wept when I realized we needed that check (well,
I exaggerate a little ;).
It didn't cross my mind to move it into reuse_swap_page(): yes,
we could do that. I don't see how it's safer; and to be honest,
its main appeal to me is that it would hide this wart away more,
where fewer eyes would notice it. Which may not be the best
argument for making the move! Technically, I think it would
just increase the overhead of COWing a KSM page (getting that
page lock, maybe having to drop ptlock etc.), but that may not
matter much: please persuade me it's safer in reuse_swap_page()
and I'll move it there.
Hugh
--
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>
next prev parent reply other threads:[~2009-07-22 12:45 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-17 17:30 [PATCH 00/10] ksm resend Izik Eidus
2009-07-17 17:30 ` [PATCH 01/10] ksm: add mmu_notifier set_pte_at_notify() Izik Eidus
2009-07-17 17:30 ` [PATCH 02/10] ksm: first tidy up madvise_vma() Izik Eidus
2009-07-17 17:30 ` [PATCH 03/10] ksm: define MADV_MERGEABLE and MADV_UNMERGEABLE Izik Eidus
2009-07-17 17:30 ` [PATCH 04/10] ksm: the mm interface to ksm Izik Eidus
2009-07-17 17:30 ` [PATCH 05/10] ksm: no debug in page_dup_rmap() Izik Eidus
2009-07-17 17:30 ` [PATCH 06/10] ksm: identify PageKsm pages Izik Eidus
2009-07-17 17:30 ` [PATCH 07/10] ksm: Kernel SamePage Merging Izik Eidus
2009-07-17 17:30 ` [PATCH 08/10] ksm: prevent mremap move poisoning Izik Eidus
2009-07-17 17:30 ` [PATCH 09/10] ksm: change copyright message Izik Eidus
2009-07-17 17:30 ` [PATCH 10/10] ksm: change ksm nice level to be 5 Izik Eidus
2009-07-19 13:50 ` Hugh Dickins
2009-07-20 4:50 ` Balbir Singh
2009-07-20 11:48 ` Izik Eidus
2009-07-20 12:14 ` Balbir Singh
2009-07-20 18:38 ` Rik van Riel
2009-07-19 13:49 ` [PATCH 09/10] ksm: change copyright message Hugh Dickins
2009-07-20 18:37 ` Rik van Riel
2009-07-20 18:37 ` [PATCH 08/10] ksm: prevent mremap move poisoning Rik van Riel
2009-07-20 18:35 ` [PATCH 07/10] ksm: Kernel SamePage Merging Rik van Riel
2009-07-18 2:45 ` [PATCH 06/10] ksm: identify PageKsm pages Wu Fengguang
2009-07-20 18:32 ` Rik van Riel
2009-07-21 17:51 ` Andrea Arcangeli
2009-07-21 17:55 ` Rik van Riel
2009-07-21 18:01 ` Andrea Arcangeli
2009-07-21 18:17 ` Izik Eidus
2009-07-22 12:54 ` Hugh Dickins
2009-07-23 2:06 ` KAMEZAWA Hiroyuki
2009-07-23 11:43 ` Hugh Dickins
2009-07-23 11:49 ` Lee Schermerhorn
2009-07-22 12:45 ` Hugh Dickins [this message]
2009-07-22 16:52 ` Andrea Arcangeli
2009-07-23 11:36 ` Hugh Dickins
2009-07-20 18:11 ` [PATCH 05/10] ksm: no debug in page_dup_rmap() Rik van Riel
2009-07-21 7:16 ` Nick Piggin
2009-07-20 17:38 ` [PATCH 04/10] ksm: the mm interface to ksm Rik van Riel
2009-07-20 15:09 ` [PATCH 03/10] ksm: define MADV_MERGEABLE and MADV_UNMERGEABLE Rik van Riel
2009-07-20 15:44 ` Ralf Baechle
2009-07-20 15:05 ` [PATCH 02/10] ksm: first tidy up madvise_vma() Rik van Riel
2009-07-20 14:48 ` [PATCH 01/10] ksm: add mmu_notifier set_pte_at_notify() Rik van Riel
2009-07-21 17:59 ` [PATCH 00/10] ksm resend Andrea Arcangeli
2009-07-22 13:05 ` Hugh Dickins
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=Pine.LNX.4.64.0907221313370.529@sister.anvils \
--to=hugh.dickins@tiscali.co.uk \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=avi@redhat.com \
--cc=chrisw@redhat.com \
--cc=fengguang.wu@intel.com \
--cc=ieidus@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nickpiggin@yahoo.com.au \
--cc=riel@redhat.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