linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: David Hildenbrand <david@redhat.com>
Cc: Alex Shi <seakeel@gmail.com>,
	alexs@kernel.org, Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	izik.eidus@ravellosystems.com, aarcange@redhat.com,
	chrisw@sous-sol.org, hughd@google.com
Subject: Re: [PATCH 02/10] mm/ksm: skip subpages of compound pages
Date: Wed, 5 Jun 2024 22:12:06 +0100	[thread overview]
Message-ID: <ZmDUpryUaVraNF6m@casper.infradead.org> (raw)
In-Reply-To: <8a614d01-191e-45d1-b6b6-c36ec0bd9e5a@redhat.com>

On Wed, Jun 05, 2024 at 09:47:10AM +0200, David Hildenbrand wrote:
> On 05.06.24 08:14, Alex Shi wrote:
> > 
> > 
> > On 6/5/24 11:52 AM, Matthew Wilcox wrote:
> > > On Tue, Jun 04, 2024 at 12:24:44PM +0800, alexs@kernel.org wrote:
> > > > From: "Alex Shi (tencent)" <alexs@kernel.org>
> > > > 
> > > > When a folio isn't fit for KSM, the subpages are unlikely to be good,
> > > > So let's skip the rest page checking to save some actions.
> > > 
> > > Why would you say that is true?  We have plenty of evidence that
> > > userspace allocators can allocate large folios, then use only the first
> > > few bytes, leaving many tail pages full of zeroes.
> > 
> > Um, that do need tail pages...
> > Is there some way to use more folio in ksm?
> 
> My take, and Willy can correct me if I am wrong:
> 
> "struct page" is not going to away any time soon, but it might shrink at
> some point.
> 
> That is, we can use the "struct page" pointer to point at a page frame, and
> use "struct folio" to lookup/manage the metadata.

Right.

> That is, use "struct page" when accessing the actual memory content
> (checksum, testing for identical content), but use the folio part when
> looking up metadata (folio_test_anon() etc). In the future we might want to
> replace the "struct page" pointer by an index into the folio, but that
> doesn't have to happen right now.

My current thinking is that folio->pfn is how we know where the memory
described by the folio is.  Using an index would be memmap[folio->pfn +
index] which isn't terribly expensive, but we may as well pass around the
(folio, page) pair and save the reference to memmap.

> For KSM, that would mean that you have a folio+page (late folio+index) pair
> when possibly dealing with large folios, but you can use a folio without a
> page when dealing with KSM folios, that are always small.

Yes, agreed.


  reply	other threads:[~2024-06-05 21:12 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-04  4:24 [PATCH 00/10] use folio in ksm alexs
2024-06-04  4:24 ` [PATCH 01/10] mm/ksm: reduce the flush action for ksm merging page alexs
2024-06-04  8:07   ` David Hildenbrand
2024-06-04 10:26     ` Alex Shi
2024-06-04 10:45       ` David Hildenbrand
2024-06-04 13:02         ` Alex Shi
2024-06-05  7:26           ` David Hildenbrand
2024-06-05  9:10             ` Alex Shi
2024-06-05  9:14               ` David Hildenbrand
2024-06-05  9:49                 ` Alex Shi
2024-06-05 10:00                   ` David Hildenbrand
2024-06-04  4:24 ` [PATCH 02/10] mm/ksm: skip subpages of compound pages alexs
2024-06-04  8:12   ` David Hildenbrand
2024-06-04 10:31     ` Alex Shi
2024-06-04 10:43       ` David Hildenbrand
2024-06-04 13:10         ` Alex Shi
2024-06-04 13:14           ` David Hildenbrand
2024-06-05  3:58             ` Alex Shi
2024-06-05  7:40               ` David Hildenbrand
2024-06-05  3:52   ` Matthew Wilcox
2024-06-05  6:14     ` Alex Shi
2024-06-05  7:47       ` David Hildenbrand
2024-06-05 21:12         ` Matthew Wilcox [this message]
2024-06-06  7:11           ` David Hildenbrand
2024-06-04  4:24 ` [PATCH 03/10] mm/ksm: use folio in try_to_merge_one_page alexs
2024-06-04  8:19   ` David Hildenbrand
2024-06-05  3:38     ` Alex Shi
2024-06-04  4:24 ` [PATCH 04/10] mm/ksm: add identical_folio func alexs
2024-06-04  8:25   ` David Hildenbrand
2024-06-04  4:24 ` [PATCH 05/10] mm/ksm: use folio in stable_tree_search alexs
2024-06-04  4:24 ` [PATCH 06/10] mm/ksm: remove page_stable_node alexs
2024-06-04  4:24 ` [PATCH 07/10] mm/ksm: use folio in unstable_tree_search_insert alexs
2024-06-04  4:24 ` [PATCH 08/10] mm/ksm: use folio in try_to_merge_xx serie funcs alexs
2024-06-04  4:24 ` [PATCH 09/10] mm/ksm: calc_checksum for folio alexs
2024-06-04 13:18   ` David Hildenbrand
2024-06-05  3:44     ` Alex Shi
2024-06-05  7:53       ` David Hildenbrand
2024-06-04  4:24 ` [PATCH 10/10] m/ksm: use folio in ksm scan path alexs
2024-06-04 13:28 ` [PATCH 00/10] use folio in ksm David Hildenbrand
2024-06-05  3:46   ` Alex Shi

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=ZmDUpryUaVraNF6m@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=alexs@kernel.org \
    --cc=chrisw@sous-sol.org \
    --cc=david@redhat.com \
    --cc=hughd@google.com \
    --cc=izik.eidus@ravellosystems.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=seakeel@gmail.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