linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [LSF/MM/BPF TOPIC] Flexible orders for anonymous folios
@ 2023-02-22 23:55 Yu Zhao
  2023-02-23  0:16 ` Suren Baghdasaryan
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Yu Zhao @ 2023-02-22 23:55 UTC (permalink / raw)
  To: lsf-pc
  Cc: Linux-MM, Yang Shi, Matthew Wilcox, Yin, Fengwei, Hugh Dickins,
	Kirill A . Shutemov

Currently anonymous folios only support two orders: 0 and the PMD
order. Flexible orders for anonymous folios can resist both internal
or external fragmentations when the PMD order is too underutilized or
costly to allocate. Flexible orders can also leverage the TLB
coalescing feature, .e.g., order 3 for AMD and order 4 for ARM CPUs.

Discussion points:
1. The page fault path: determining the best order and the fallback policy.
2. The reclaim path: detecting the utilization and the splitting policy.
3. The refcount and the mapcount models, e.g., reuse the PMD-mapped
THP model or not.
4. The splitting, and the collapsing if needed.
5. Other paths: COW, GUP, madvise(), mprotect(), page migration, etc.

A bit of history:
I discussed this topic at Matthew's THP Cabal meeting a couple of
years ago, as one of the major use cases of folios. Around the same
time, I tried to get Hugh to work with me on it, since he tried
something similar back in 2001 [1]. William's page clustering from
2003 [2] is also based on that, btw. Then I put the idea on the back
burner.

Now it seems to be a good time to revisit. Yang Shi and I have been
looking at some details, trying to scope out the work that would be
required. We don't have anything definitive yet, but we should have
enough to share by the time of the LSF/MM/BPF.

[1] https://lore.kernel.org/linux-mm/Pine.LNX.4.21.0107051737340.1577-100000@localhost.localdomain/
[2] https://lwn.net/Articles/23785/


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [LSF/MM/BPF TOPIC] Flexible orders for anonymous folios
  2023-02-22 23:55 [LSF/MM/BPF TOPIC] Flexible orders for anonymous folios Yu Zhao
@ 2023-02-23  0:16 ` Suren Baghdasaryan
  2023-02-23  4:01 ` Matthew Wilcox
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: Suren Baghdasaryan @ 2023-02-23  0:16 UTC (permalink / raw)
  To: Yu Zhao
  Cc: lsf-pc, Linux-MM, Yang Shi, Matthew Wilcox, Yin, Fengwei,
	Hugh Dickins, Kirill A . Shutemov

On Wed, Feb 22, 2023 at 3:56 PM Yu Zhao <yuzhao@google.com> wrote:
>
> Currently anonymous folios only support two orders: 0 and the PMD
> order. Flexible orders for anonymous folios can resist both internal
> or external fragmentations when the PMD order is too underutilized or
> costly to allocate. Flexible orders can also leverage the TLB
> coalescing feature, .e.g., order 3 for AMD and order 4 for ARM CPUs.
>
> Discussion points:
> 1. The page fault path: determining the best order and the fallback policy.
> 2. The reclaim path: detecting the utilization and the splitting policy.
> 3. The refcount and the mapcount models, e.g., reuse the PMD-mapped
> THP model or not.
> 4. The splitting, and the collapsing if needed.
> 5. Other paths: COW, GUP, madvise(), mprotect(), page migration, etc.
>
> A bit of history:
> I discussed this topic at Matthew's THP Cabal meeting a couple of
> years ago, as one of the major use cases of folios. Around the same
> time, I tried to get Hugh to work with me on it, since he tried
> something similar back in 2001 [1]. William's page clustering from
> 2003 [2] is also based on that, btw. Then I put the idea on the back
> burner.
>
> Now it seems to be a good time to revisit. Yang Shi and I have been
> looking at some details, trying to scope out the work that would be
> required. We don't have anything definitive yet, but we should have
> enough to share by the time of the LSF/MM/BPF.

This might be useful for Android. I would like to participate in this
discussion.

>
> [1] https://lore.kernel.org/linux-mm/Pine.LNX.4.21.0107051737340.1577-100000@localhost.localdomain/
> [2] https://lwn.net/Articles/23785/
>


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [LSF/MM/BPF TOPIC] Flexible orders for anonymous folios
  2023-02-22 23:55 [LSF/MM/BPF TOPIC] Flexible orders for anonymous folios Yu Zhao
  2023-02-23  0:16 ` Suren Baghdasaryan
@ 2023-02-23  4:01 ` Matthew Wilcox
  2023-02-23  4:45   ` Yin, Fengwei
                     ` (3 more replies)
  2023-02-24 20:34 ` Jason Gunthorpe
                   ` (3 subsequent siblings)
  5 siblings, 4 replies; 14+ messages in thread
From: Matthew Wilcox @ 2023-02-23  4:01 UTC (permalink / raw)
  To: Yu Zhao
  Cc: lsf-pc, Linux-MM, Yang Shi, Yin, Fengwei, Hugh Dickins,
	Kirill A . Shutemov

On Wed, Feb 22, 2023 at 04:55:20PM -0700, Yu Zhao wrote:
> Currently anonymous folios only support two orders: 0 and the PMD
> order. Flexible orders for anonymous folios can resist both internal
> or external fragmentations when the PMD order is too underutilized or
> costly to allocate. Flexible orders can also leverage the TLB
> coalescing feature, .e.g., order 3 for AMD and order 4 for ARM CPUs.
> 
> Discussion points:
> 1. The page fault path: determining the best order and the fallback policy.
> 2. The reclaim path: detecting the utilization and the splitting policy.
> 3. The refcount and the mapcount models, e.g., reuse the PMD-mapped
> THP model or not.
> 4. The splitting, and the collapsing if needed.
> 5. Other paths: COW, GUP, madvise(), mprotect(), page migration, etc.

6. Swap out an entire folio instead of splitting it before swap.
7. At some point we're going to want Zi Yan's patches to split a folio
   into arbitrary order folios instead of just to order-0.
8. For file folios, folio->index % folio->nr_pages is 0.  Do we want
   to maintain that invariant for anon folios?  It helps tile the
   folios so we don't end up with say, order-0, order-4, order-2 folios
   in a sequence.
9. How do we ensure that two page faults do not overwrite each others
   folios, eg PF1 decides to allocate an order-0 folio at index 6 and
   PF2 decides to allocate an order-2 folio at index 4?

Probably some other things left to decide.

> Now it seems to be a good time to revisit. Yang Shi and I have been
> looking at some details, trying to scope out the work that would be
> required. We don't have anything definitive yet, but we should have
> enough to share by the time of the LSF/MM/BPF.

Excellent.  There are other people also interested in this.  eg:

Ryan Roberts: https://lore.kernel.org/linux-mm/4c991dcb-c5bb-86bb-5a29-05df24429607@arm.com/
Fengwei Yin: https://lore.kernel.org/linux-mm/20230109072232.2398464-1-fengwei.yin@intel.com/

Obviously I'm keenly interested.
https://lore.kernel.org/linux-mm/Y%2FU8bQd15aUO97vS@casper.infradead.org/

This is definitely worth its own session in the MM track.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [LSF/MM/BPF TOPIC] Flexible orders for anonymous folios
  2023-02-23  4:01 ` Matthew Wilcox
@ 2023-02-23  4:45   ` Yin, Fengwei
  2023-02-23 18:07   ` Yang Shi
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 14+ messages in thread
From: Yin, Fengwei @ 2023-02-23  4:45 UTC (permalink / raw)
  To: Matthew Wilcox, Yu Zhao
  Cc: lsf-pc, Linux-MM, Yang Shi, Hugh Dickins, Kirill A . Shutemov



On 2/23/2023 12:01 PM, Matthew Wilcox wrote:
> On Wed, Feb 22, 2023 at 04:55:20PM -0700, Yu Zhao wrote:
>> Currently anonymous folios only support two orders: 0 and the PMD
>> order. Flexible orders for anonymous folios can resist both internal
>> or external fragmentations when the PMD order is too underutilized or
>> costly to allocate. Flexible orders can also leverage the TLB
>> coalescing feature, .e.g., order 3 for AMD and order 4 for ARM CPUs.
>>
>> Discussion points:
>> 1. The page fault path: determining the best order and the fallback policy.
>> 2. The reclaim path: detecting the utilization and the splitting policy.
>> 3. The refcount and the mapcount models, e.g., reuse the PMD-mapped
>> THP model or not.
>> 4. The splitting, and the collapsing if needed.
>> 5. Other paths: COW, GUP, madvise(), mprotect(), page migration, etc.
> 
> 6. Swap out an entire folio instead of splitting it before swap.
> 7. At some point we're going to want Zi Yan's patches to split a folio
>    into arbitrary order folios instead of just to order-0.
> 8. For file folios, folio->index % folio->nr_pages is 0.  Do we want
>    to maintain that invariant for anon folios?  It helps tile the
>    folios so we don't end up with say, order-0, order-4, order-2 folios
>    in a sequence.
> 9. How do we ensure that two page faults do not overwrite each others
>    folios, eg PF1 decides to allocate an order-0 folio at index 6 and
>    PF2 decides to allocate an order-2 folio at index 4?
> 
> Probably some other things left to decide.
> 
>> Now it seems to be a good time to revisit. Yang Shi and I have been
>> looking at some details, trying to scope out the work that would be
>> required. We don't have anything definitive yet, but we should have
>> enough to share by the time of the LSF/MM/BPF.
> 
> Excellent.  There are other people also interested in this.  eg:
> 
> Ryan Roberts: https://lore.kernel.org/linux-mm/4c991dcb-c5bb-86bb-5a29-05df24429607@arm.com/
> Fengwei Yin: https://lore.kernel.org/linux-mm/20230109072232.2398464-1-fengwei.yin@intel.com/
Yes. I definitely have interesting to join.


Regards
Yin, Fengwei

> 
> Obviously I'm keenly interested.
> https://lore.kernel.org/linux-mm/Y%2FU8bQd15aUO97vS@casper.infradead.org/
> 
> This is definitely worth its own session in the MM track.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [LSF/MM/BPF TOPIC] Flexible orders for anonymous folios
  2023-02-23  4:01 ` Matthew Wilcox
  2023-02-23  4:45   ` Yin, Fengwei
@ 2023-02-23 18:07   ` Yang Shi
  2023-03-01 10:35   ` Ryan Roberts
  2023-03-06 20:57   ` Zi Yan
  3 siblings, 0 replies; 14+ messages in thread
From: Yang Shi @ 2023-02-23 18:07 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Yu Zhao, lsf-pc, Linux-MM, Yin, Fengwei, Hugh Dickins,
	Kirill A . Shutemov

On Wed, Feb 22, 2023 at 8:01 PM Matthew Wilcox <willy@infradead.org> wrote:
>
> On Wed, Feb 22, 2023 at 04:55:20PM -0700, Yu Zhao wrote:
> > Currently anonymous folios only support two orders: 0 and the PMD
> > order. Flexible orders for anonymous folios can resist both internal
> > or external fragmentations when the PMD order is too underutilized or
> > costly to allocate. Flexible orders can also leverage the TLB
> > coalescing feature, .e.g., order 3 for AMD and order 4 for ARM CPUs.
> >
> > Discussion points:
> > 1. The page fault path: determining the best order and the fallback policy.
> > 2. The reclaim path: detecting the utilization and the splitting policy.
> > 3. The refcount and the mapcount models, e.g., reuse the PMD-mapped
> > THP model or not.
> > 4. The splitting, and the collapsing if needed.
> > 5. Other paths: COW, GUP, madvise(), mprotect(), page migration, etc.
>
> 6. Swap out an entire folio instead of splitting it before swap.

Yeah, the THP swap should be extended to support arbitrary order.
Other than swap out, swap in large folios should be considered as well
at some point

> 7. At some point we're going to want Zi Yan's patches to split a folio
>    into arbitrary order folios instead of just to order-0.

I agree.

> 8. For file folios, folio->index % folio->nr_pages is 0.  Do we want
>    to maintain that invariant for anon folios?  It helps tile the
>    folios so we don't end up with say, order-0, order-4, order-2 folios
>    in a sequence.

I think so. The TLB has alignment requirements anyway.

> 9. How do we ensure that two page faults do not overwrite each others
>    folios, eg PF1 decides to allocate an order-0 folio at index 6 and
>    PF2 decides to allocate an order-2 folio at index 4?

Good question. I don't have a good answer right now, but anyway the
kernel should make sure all the PTEs in the region covered by the
folio should be none off the top of my head.

>
> Probably some other things left to decide.
>
> > Now it seems to be a good time to revisit. Yang Shi and I have been
> > looking at some details, trying to scope out the work that would be
> > required. We don't have anything definitive yet, but we should have
> > enough to share by the time of the LSF/MM/BPF.
>
> Excellent.  There are other people also interested in this.  eg:
>
> Ryan Roberts: https://lore.kernel.org/linux-mm/4c991dcb-c5bb-86bb-5a29-05df24429607@arm.com/
> Fengwei Yin: https://lore.kernel.org/linux-mm/20230109072232.2398464-1-fengwei.yin@intel.com/
>
> Obviously I'm keenly interested.
> https://lore.kernel.org/linux-mm/Y%2FU8bQd15aUO97vS@casper.infradead.org/
>
> This is definitely worth its own session in the MM track.

Absolutely.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [LSF/MM/BPF TOPIC] Flexible orders for anonymous folios
  2023-02-22 23:55 [LSF/MM/BPF TOPIC] Flexible orders for anonymous folios Yu Zhao
  2023-02-23  0:16 ` Suren Baghdasaryan
  2023-02-23  4:01 ` Matthew Wilcox
@ 2023-02-24 20:34 ` Jason Gunthorpe
  2023-02-26  1:30 ` Hillf Danton
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: Jason Gunthorpe @ 2023-02-24 20:34 UTC (permalink / raw)
  To: Yu Zhao
  Cc: lsf-pc, Linux-MM, Yang Shi, Matthew Wilcox, Yin, Fengwei,
	Hugh Dickins, Kirill A . Shutemov

On Wed, Feb 22, 2023 at 04:55:20PM -0700, Yu Zhao wrote:
> Currently anonymous folios only support two orders: 0 and the PMD
> order. Flexible orders for anonymous folios can resist both internal
> or external fragmentations when the PMD order is too underutilized or
> costly to allocate. Flexible orders can also leverage the TLB
> coalescing feature, .e.g., order 3 for AMD and order 4 for ARM CPUs.

I'm interested in this too - we've started to look at using 64K as a
base page size on ARM systems and having an order 3 folio would be the
usual 2M "THP" size with the coalescing feature. Keeping THP is a
desirable thing.

We also have some IOMMU HW that can do flexible orders, so even if the
CPU TLB cannot store odd folio sizes the IOMMU TLB can, which can be
interesting for KVM & VFIO.

Thanks,
Jason


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [LSF/MM/BPF TOPIC] Flexible orders for anonymous folios
  2023-02-22 23:55 [LSF/MM/BPF TOPIC] Flexible orders for anonymous folios Yu Zhao
                   ` (2 preceding siblings ...)
  2023-02-24 20:34 ` Jason Gunthorpe
@ 2023-02-26  1:30 ` Hillf Danton
  2023-02-26  2:34   ` Matthew Wilcox
  2023-03-01 23:29 ` Chris Li
  2023-03-02  4:05 ` Yu Zhao
  5 siblings, 1 reply; 14+ messages in thread
From: Hillf Danton @ 2023-02-26  1:30 UTC (permalink / raw)
  To: Yu Zhao
  Cc: lsf-pc, Linux-MM, Yang Shi, Matthew Wilcox, Yin, Fengwei,
	Hugh Dickins, Kirill A . Shutemov

On Wed, Feb 22, 2023 at 04:55:20PM -0700, Yu Zhao wrote:
> Currently anonymous folios only support two orders: 0 and the PMD
> order. Flexible orders for anonymous folios can resist both internal
> or external fragmentations when the PMD order is too underutilized or
> costly to allocate. Flexible orders can also leverage the TLB
> coalescing feature, .e.g., order 3 for AMD and order 4 for ARM CPUs.
> 
> Discussion points:
> 1. The page fault path: determining the best order and the fallback policy.
> 2. The reclaim path: detecting the utilization and the splitting policy.
> 3. The refcount and the mapcount models, e.g., reuse the PMD-mapped
> THP model or not.
> 4. The splitting, and the collapsing if needed.
> 5. Other paths: COW, GUP, madvise(), mprotect(), page migration, etc.

  6. Given the number of TLB is farrr less than the number of pages,
     what workload prefers MADV_ORDER6 over MADV_HUGEPAGE for instance? 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [LSF/MM/BPF TOPIC] Flexible orders for anonymous folios
  2023-02-26  1:30 ` Hillf Danton
@ 2023-02-26  2:34   ` Matthew Wilcox
  2023-02-26  4:12     ` Hillf Danton
  0 siblings, 1 reply; 14+ messages in thread
From: Matthew Wilcox @ 2023-02-26  2:34 UTC (permalink / raw)
  To: Hillf Danton
  Cc: Yu Zhao, lsf-pc, Linux-MM, Yang Shi, Yin, Fengwei, Hugh Dickins,
	Kirill A . Shutemov

On Sun, Feb 26, 2023 at 09:30:31AM +0800, Hillf Danton wrote:
> On Wed, Feb 22, 2023 at 04:55:20PM -0700, Yu Zhao wrote:
> > Currently anonymous folios only support two orders: 0 and the PMD
> > order. Flexible orders for anonymous folios can resist both internal
> > or external fragmentations when the PMD order is too underutilized or
> > costly to allocate. Flexible orders can also leverage the TLB
> > coalescing feature, .e.g., order 3 for AMD and order 4 for ARM CPUs.
> > 
> > Discussion points:
> > 1. The page fault path: determining the best order and the fallback policy.
> > 2. The reclaim path: detecting the utilization and the splitting policy.
> > 3. The refcount and the mapcount models, e.g., reuse the PMD-mapped
> > THP model or not.
> > 4. The splitting, and the collapsing if needed.
> > 5. Other paths: COW, GUP, madvise(), mprotect(), page migration, etc.
> 
>   6. Given the number of TLB is farrr less than the number of pages,
>      what workload prefers MADV_ORDER6 over MADV_HUGEPAGE for instance? 

Many.  https://lore.kernel.org/linux-mm/Y%2FWRlX+MkmxelNbg@casper.infradead.org/



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [LSF/MM/BPF TOPIC] Flexible orders for anonymous folios
  2023-02-26  2:34   ` Matthew Wilcox
@ 2023-02-26  4:12     ` Hillf Danton
  2023-02-27  0:58       ` Hillf Danton
  0 siblings, 1 reply; 14+ messages in thread
From: Hillf Danton @ 2023-02-26  4:12 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Yu Zhao, lsf-pc, Linux-MM, Yang Shi, Yin, Fengwei, Hugh Dickins,
	Kirill A . Shutemov

On Sun, 26 Feb 2023 02:34:05 +0000 Matthew Wilcox <willy@infradead.org>
> On Sun, Feb 26, 2023 at 09:30:31AM +0800, Hillf Danton wrote:
> > On Wed, Feb 22, 2023 at 04:55:20PM -0700, Yu Zhao wrote:
> > > Currently anonymous folios only support two orders: 0 and the PMD
> > > order. Flexible orders for anonymous folios can resist both internal
> > > or external fragmentations when the PMD order is too underutilized or
> > > costly to allocate. Flexible orders can also leverage the TLB
> > > coalescing feature, .e.g., order 3 for AMD and order 4 for ARM CPUs.
> > > 
> > > Discussion points:
> > > 1. The page fault path: determining the best order and the fallback policy.
> > > 2. The reclaim path: detecting the utilization and the splitting policy.
> > > 3. The refcount and the mapcount models, e.g., reuse the PMD-mapped
> > > THP model or not.
> > > 4. The splitting, and the collapsing if needed.
> > > 5. Other paths: COW, GUP, madvise(), mprotect(), page migration, etc.
> > 
> >   6. Given the number of TLB is farrr less than the number of pages,
> >      what workload prefers MADV_ORDER6 over MADV_HUGEPAGE for instance? 
> 
> Many.  https://lore.kernel.org/linux-mm/Y%2FWRlX+MkmxelNbg@casper.infradead.org/

Which one, supposedly given Apache Spark, MariaDB, Memcached, MongoDB,
Apache Cassandra, Apache Hadoop, PostgreSQL and Redis to ease the anwser?


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [LSF/MM/BPF TOPIC] Flexible orders for anonymous folios
  2023-02-26  4:12     ` Hillf Danton
@ 2023-02-27  0:58       ` Hillf Danton
  0 siblings, 0 replies; 14+ messages in thread
From: Hillf Danton @ 2023-02-27  0:58 UTC (permalink / raw)
  To: Hillf Danton
  Cc: Matthew Wilcox, Yu Zhao, lsf-pc, Linux-MM, Yang Shi, Yin,
	Fengwei, Hugh Dickins, Kirill A . Shutemov

On Sun, 26 Feb 2023 12:12:59 +0800 Hillf Danton wrote:
> On Sun, 26 Feb 2023 02:34:05 +0000 Matthew Wilcox <willy@infradead.org>
> > On Sun, Feb 26, 2023 at 09:30:31AM +0800, Hillf Danton wrote:
> > > On Wed, Feb 22, 2023 at 04:55:20PM -0700, Yu Zhao wrote:
> > > > Currently anonymous folios only support two orders: 0 and the PMD
> > > > order. Flexible orders for anonymous folios can resist both internal
> > > > or external fragmentations when the PMD order is too underutilized or
> > > > costly to allocate. Flexible orders can also leverage the TLB
> > > > coalescing feature, .e.g., order 3 for AMD and order 4 for ARM CPUs.
> > > > 
> > > > Discussion points:
> > > > 1. The page fault path: determining the best order and the fallback policy.
> > > > 2. The reclaim path: detecting the utilization and the splitting policy.
> > > > 3. The refcount and the mapcount models, e.g., reuse the PMD-mapped
> > > > THP model or not.
> > > > 4. The splitting, and the collapsing if needed.
> > > > 5. Other paths: COW, GUP, madvise(), mprotect(), page migration, etc.
> > > 
> > >   6. Given the number of TLB is farrr less than the number of pages,
> > >      what workload prefers MADV_ORDER6 over MADV_HUGEPAGE for instance? 

        7. Given p4d_t, is 2023-25 the right time to add the PUD order?

> > 
> > Many.  https://lore.kernel.org/linux-mm/Y%2FWRlX+MkmxelNbg@casper.infradead.org/
> 
> Which one, supposedly given Apache Spark, MariaDB, Memcached, MongoDB,
> Apache Cassandra, Apache Hadoop, PostgreSQL and Redis to ease the anwser?


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [LSF/MM/BPF TOPIC] Flexible orders for anonymous folios
  2023-02-23  4:01 ` Matthew Wilcox
  2023-02-23  4:45   ` Yin, Fengwei
  2023-02-23 18:07   ` Yang Shi
@ 2023-03-01 10:35   ` Ryan Roberts
  2023-03-06 20:57   ` Zi Yan
  3 siblings, 0 replies; 14+ messages in thread
From: Ryan Roberts @ 2023-03-01 10:35 UTC (permalink / raw)
  To: Matthew Wilcox, Yu Zhao
  Cc: lsf-pc, Linux-MM, Yang Shi, Yin, Fengwei, Hugh Dickins,
	Kirill A . Shutemov

On 23/02/2023 04:01, Matthew Wilcox wrote:
> On Wed, Feb 22, 2023 at 04:55:20PM -0700, Yu Zhao wrote:
>> Currently anonymous folios only support two orders: 0 and the PMD
>> order. Flexible orders for anonymous folios can resist both internal
>> or external fragmentations when the PMD order is too underutilized or
>> costly to allocate. Flexible orders can also leverage the TLB
>> coalescing feature, .e.g., order 3 for AMD and order 4 for ARM CPUs.
>>
>> Discussion points:
>> 1. The page fault path: determining the best order and the fallback policy.
>> 2. The reclaim path: detecting the utilization and the splitting policy.
>> 3. The refcount and the mapcount models, e.g., reuse the PMD-mapped
>> THP model or not.
>> 4. The splitting, and the collapsing if needed.
>> 5. Other paths: COW, GUP, madvise(), mprotect(), page migration, etc.
> 
> 6. Swap out an entire folio instead of splitting it before swap.
> 7. At some point we're going to want Zi Yan's patches to split a folio
>    into arbitrary order folios instead of just to order-0.
> 8. For file folios, folio->index % folio->nr_pages is 0.  Do we want
>    to maintain that invariant for anon folios?  It helps tile the
>    folios so we don't end up with say, order-0, order-4, order-2 folios
>    in a sequence.
> 9. How do we ensure that two page faults do not overwrite each others
>    folios, eg PF1 decides to allocate an order-0 folio at index 6 and
>    PF2 decides to allocate an order-2 folio at index 4?
> 
> Probably some other things left to decide.
> 
>> Now it seems to be a good time to revisit. Yang Shi and I have been
>> looking at some details, trying to scope out the work that would be
>> required. We don't have anything definitive yet, but we should have
>> enough to share by the time of the LSF/MM/BPF.
> 
> Excellent.  There are other people also interested in this.  eg:
> 
> Ryan Roberts: https://lore.kernel.org/linux-mm/4c991dcb-c5bb-86bb-5a29-05df24429607@arm.com/

Yes, I'm very interested, and would be keen to join the discussion. I have some
thoughts in this mail, if you want to have a look:
https://lore.kernel.org/linux-mm/a7cd938e-a86f-e3af-f56c-433c92ac69c2@arm.com/

Feel free to CC me on any discussion.

> Fengwei Yin: https://lore.kernel.org/linux-mm/20230109072232.2398464-1-fengwei.yin@intel.com/
> 
> Obviously I'm keenly interested.
> https://lore.kernel.org/linux-mm/Y%2FU8bQd15aUO97vS@casper.infradead.org/
> 
> This is definitely worth its own session in the MM track.
> 
> 



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [LSF/MM/BPF TOPIC] Flexible orders for anonymous folios
  2023-02-22 23:55 [LSF/MM/BPF TOPIC] Flexible orders for anonymous folios Yu Zhao
                   ` (3 preceding siblings ...)
  2023-02-26  1:30 ` Hillf Danton
@ 2023-03-01 23:29 ` Chris Li
  2023-03-02  4:05 ` Yu Zhao
  5 siblings, 0 replies; 14+ messages in thread
From: Chris Li @ 2023-03-01 23:29 UTC (permalink / raw)
  To: Yu Zhao
  Cc: lsf-pc, Linux-MM, Yang Shi, Matthew Wilcox, Yin, Fengwei,
	Hugh Dickins, Kirill A . Shutemov

On Wed, Feb 22, 2023 at 04:55:20PM -0700, Yu Zhao wrote:
> Discussion points:
> 1. The page fault path: determining the best order and the fallback policy.
> 2. The reclaim path: detecting the utilization and the splitting policy.
> 3. The refcount and the mapcount models, e.g., reuse the PMD-mapped
> THP model or not.
> 4. The splitting, and the collapsing if needed.
> 5. Other paths: COW, GUP, madvise(), mprotect(), page migration, etc.
>

I am interested in this topic and I would like to partition the
discussion as well.

Chris


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [LSF/MM/BPF TOPIC] Flexible orders for anonymous folios
  2023-02-22 23:55 [LSF/MM/BPF TOPIC] Flexible orders for anonymous folios Yu Zhao
                   ` (4 preceding siblings ...)
  2023-03-01 23:29 ` Chris Li
@ 2023-03-02  4:05 ` Yu Zhao
  5 siblings, 0 replies; 14+ messages in thread
From: Yu Zhao @ 2023-03-02  4:05 UTC (permalink / raw)
  To: Yin, Fengwei, Yang Shi, Matthew Wilcox, Suren Baghdasaryan,
	Jason Gunthorpe, Hillf Danton, Ryan Roberts, Chris Li
  Cc: Linux-MM, Hugh Dickins, Kirill A . Shutemov, lsf-pc

First of all, if you have not filled out the form yet, please do it now :)

https://forms.gle/VKVXjWGBHZbnsz226

If you wish to present, please let me know. We probably can fit in two
more speakers, and I'll try to negotiate a one-hour session for this
topic. (The worst case: I'll give up my spot, which I have no problem
with.)

Also you don't have to wait until the conference to discuss this
topic. The biweekly THP Cabal meeting is open to everyone. Please ask
Matthew for the Zoom link. (I can't post it on the mailing list here
because of Zoom bombing concerns.)

Thank you.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [LSF/MM/BPF TOPIC] Flexible orders for anonymous folios
  2023-02-23  4:01 ` Matthew Wilcox
                     ` (2 preceding siblings ...)
  2023-03-01 10:35   ` Ryan Roberts
@ 2023-03-06 20:57   ` Zi Yan
  3 siblings, 0 replies; 14+ messages in thread
From: Zi Yan @ 2023-03-06 20:57 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Yu Zhao, lsf-pc, Linux-MM, Yang Shi, Yin, Fengwei, Hugh Dickins,
	Kirill A . Shutemov

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

On 22 Feb 2023, at 23:01, Matthew Wilcox wrote:

> On Wed, Feb 22, 2023 at 04:55:20PM -0700, Yu Zhao wrote:
>> Currently anonymous folios only support two orders: 0 and the PMD
>> order. Flexible orders for anonymous folios can resist both internal
>> or external fragmentations when the PMD order is too underutilized or
>> costly to allocate. Flexible orders can also leverage the TLB
>> coalescing feature, .e.g., order 3 for AMD and order 4 for ARM CPUs.
>>
>> Discussion points:
>> 1. The page fault path: determining the best order and the fallback policy.
>> 2. The reclaim path: detecting the utilization and the splitting policy.
>> 3. The refcount and the mapcount models, e.g., reuse the PMD-mapped
>> THP model or not.
>> 4. The splitting, and the collapsing if needed.
>> 5. Other paths: COW, GUP, madvise(), mprotect(), page migration, etc.
>
> 6. Swap out an entire folio instead of splitting it before swap.
> 7. At some point we're going to want Zi Yan's patches to split a folio
>    into arbitrary order folios instead of just to order-0.

Since you mentioned it, I rebased it here: https://github.com/x-y-z/linux-1gb-thp/tree/split_thp_to_any_order_mm-everything-2023-03-04-00-19 . I will send it
out whenever it is needed. :)

> 8. For file folios, folio->index % folio->nr_pages is 0.  Do we want
>    to maintain that invariant for anon folios?  It helps tile the
>    folios so we don't end up with say, order-0, order-4, order-2 folios
>    in a sequence.
> 9. How do we ensure that two page faults do not overwrite each others
>    folios, eg PF1 decides to allocate an order-0 folio at index 6 and
>    PF2 decides to allocate an order-2 folio at index 4?
>
> Probably some other things left to decide.
>
>> Now it seems to be a good time to revisit. Yang Shi and I have been
>> looking at some details, trying to scope out the work that would be
>> required. We don't have anything definitive yet, but we should have
>> enough to share by the time of the LSF/MM/BPF.
>
> Excellent.  There are other people also interested in this.  eg:
>
> Ryan Roberts: https://lore.kernel.org/linux-mm/4c991dcb-c5bb-86bb-5a29-05df24429607@arm.com/
> Fengwei Yin: https://lore.kernel.org/linux-mm/20230109072232.2398464-1-fengwei.yin@intel.com/
>
> Obviously I'm keenly interested.
> https://lore.kernel.org/linux-mm/Y%2FU8bQd15aUO97vS@casper.infradead.org/
>
> This is definitely worth its own session in the MM track.


--
Best Regards,
Yan, Zi

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 854 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-03-06 20:57 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-22 23:55 [LSF/MM/BPF TOPIC] Flexible orders for anonymous folios Yu Zhao
2023-02-23  0:16 ` Suren Baghdasaryan
2023-02-23  4:01 ` Matthew Wilcox
2023-02-23  4:45   ` Yin, Fengwei
2023-02-23 18:07   ` Yang Shi
2023-03-01 10:35   ` Ryan Roberts
2023-03-06 20:57   ` Zi Yan
2023-02-24 20:34 ` Jason Gunthorpe
2023-02-26  1:30 ` Hillf Danton
2023-02-26  2:34   ` Matthew Wilcox
2023-02-26  4:12     ` Hillf Danton
2023-02-27  0:58       ` Hillf Danton
2023-03-01 23:29 ` Chris Li
2023-03-02  4:05 ` Yu Zhao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox