Skip to contentSkip to conversation

State Of The Page

LSF/MM/BPF TOPIC Matthew Wilcox 8 participants 15 messages Jan 19, 2024 – Jan 27, 2024

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

It's probably worth doing another roundup of where we are on our journey to separating folios, slabs, pages, etc. Something suitable for people who aren't MM experts, and don't care about the details of how page allocation works. I can talk for hours about whatever people want to hear about but some ideas from me:

- Overview of how the conversion is going
- Convenience functions for filesystem writers
- What's next?
- What's the difference between &folio->page and page_folio(folio, 0)?
- What are we going to do about bio_vecs?
- How does all of this work with kmap()?

I'm sure people would like to suggest other questions they have that aren't adequately answered already and might be of interest to a wider audience.

maintainer
#1 lore raw
Quoted 13 lines · Matthew Wilcox

It's probably worth doing another roundup of where we are on our journey to separating folios, slabs, pages, etc. Something suitable for people who aren't MM experts, and don't care about the details of how page allocation works. I can talk for hours about whatever people want to hear about but some ideas from me:

- Overview of how the conversion is going
- Convenience functions for filesystem writers
- What's next?
- What's the difference between &folio->page and page_folio(folio, 0)?
- What are we going to do about bio_vecs?
- How does all of this work with kmap()?

Quoted 3 lines

I'm sure people would like to suggest other questions they have that aren't adequately answered already and might be of interest to a wider audience.

Thanks for suggesting this, I would like to attend your discussion. If you have more recent phyr thoughts (possibly related to your bio_vecs point?), or other tie-ins to large block size support, that would also be great.

#2 lore raw
In reply to Matthew Wilcox
Quoted 10 lines · Matthew Wilcox

It's probably worth doing another roundup of where we are on our journey to separating folios, slabs, pages, etc. Something suitable for people who aren't MM experts, and don't care about the details of how page allocation works. I can talk for hours about whatever people want to hear about but some ideas from me:

Quoted 5 lines

- Overview of how the conversion is going
- Convenience functions for filesystem writers
- What's next?
- What's the difference between &folio->page and page_folio(folio, 0)?
- What are we going to do about bio_vecs?

Thanks for suggesting bio_vecs, one of my current favorite topics.

I'm still interested in any work going on for a bio_vec-enabled API to the kernel's IOMMU infrastructure, which I've heard Leon R. is working on.

Quoted 6 lines

- How does all of this work with kmap()?

I'm sure people would like to suggest other questions they have that aren't adequately answered already and might be of interest to a wider audience.

--
Chuck Lever

#3 lore raw
In reply to Matthew Wilcox
Quoted 13 lines · Matthew Wilcox

It's probably worth doing another roundup of where we are on our journey to separating folios, slabs, pages, etc. Something suitable for people who aren't MM experts, and don't care about the details of how page allocation works. I can talk for hours about whatever people want to hear about but some ideas from me:

- Overview of how the conversion is going
- Convenience functions for filesystem writers
- What's next?
- What's the difference between &folio->page and page_folio(folio, 0)?
- What are we going to do about bio_vecs?
- How does all of this work with kmap()?

Quoted 4 lines

I'm sure people would like to suggest other questions they have that aren't adequately answered already and might be of interest to a wider audience.

Thanks for proposing this again, Matthew, I'd definitely like to be involved in the discussion as I think a couple of my colleagues, cc'd, would has well. Memory efficiency is a top priority for 2024 and, thus, getting on a pathway toward reducing the overhead of struct page is very important for our hosts that are not using large amounts of 1GB hugetlb.

I've seen your other thread regarding how the page allocator can be enlightened for memdesc, so I'm hoping that can either be covered in this topic or a separate topic.

Especially important for us would be the division of work so that we can parallelize development as much as possible for things like memdesc. If there are any areas that just haven't been investigated yet but we *know* we'll need to address to get to the new world of memdesc, I think we'd love to discuss that.

#4 lore raw
Quoted 25 lines · David Rientjes
Quoted 13 lines · Matthew Wilcox

It's probably worth doing another roundup of where we are on our journey to separating folios, slabs, pages, etc. Something suitable for people who aren't MM experts, and don't care about the details of how page allocation works. I can talk for hours about whatever people want to hear about but some ideas from me:

- Overview of how the conversion is going
- Convenience functions for filesystem writers
- What's next?
- What's the difference between &folio->page and page_folio(folio, 0)?
- What are we going to do about bio_vecs?
- How does all of this work with kmap()?

Quoted 4 lines

I'm sure people would like to suggest other questions they have that aren't adequately answered already and might be of interest to a wider audience.

Thanks for proposing this again, Matthew, I'd definitely like to be involved in the discussion as I think a couple of my colleagues, cc'd, would has well. Memory efficiency is a top priority for 2024 and, thus, getting on a pathway toward reducing the overhead of struct page is very important for our hosts that are not using large amounts of 1GB hugetlb.

Quoted 3 lines

I've seen your other thread regarding how the page allocator can be enlightened for memdesc, so I'm hoping that can either be covered in this topic or a separate topic.

I'd like to keep this topic relevant to as many people as possible. I can add a proposal for a topic on both the PCP and Buddy allocators (I have a series of Thoughts on how the PCP allocator works in a memdesc world that I haven't written down & sent out yet).

Or we can cover the page allocators in your biweekly meetings. Maybe both since not everybody can attend either the phone call or the conference.

Quoted 5 lines

Especially important for us would be the division of work so that we can parallelize development as much as possible for things like memdesc. If there are any areas that just haven't been investigated yet but we *know* we'll need to address to get to the new world of memdesc, I think we'd love to discuss that.

Thee's so much work to be done! And it's mostly parallelisable and almost trivial. It's just largely on the filesystem-page cache interaction, so it's not terribly interesting. See, for example, the ext2, ext4, gfs2, nilfs2, ufs and ubifs patchsets I've done over the past few releases. I have about half of an ntfs3 patchset ready to send.

There's a bunch of work to be done in DRM to switch from pages to folios due to their use of shmem. You can also grep for 'page->mapping' (because fortunately we aren't too imaginative when it comes to naming variables) and find 270 places that need to be changed. Some are comments, but those still need to be updated!

Anything using lock_page(), get_page(), set_page_dirty(), using &folio->page, any of the functions in mm/folio-compat.c needs auditing. We can make the first three of those work, but they're good indicators that the code needs to be looked at.

There is some interesting work to be done, and one of the things I'm thinking hard about right now is how we're doing folio conversions that make sense with today's code, and stop making sense when we get to memdescs. That doesn't apply to anything interacting with the page cache (because those are folios now and in the future), but it does apply to one spot in ext4 where it allocates memory from slab and attaches a buffer_head to it ...

#5 lore raw

Hi Matthew,

Thank you for proposing this topic. I would also like to be part of this discussion at LSF/MM specifically because of the memory efficiency opportunities coming of memdescs.

Quoted 27 lines · Matthew Wilcox
Quoted 25 lines · David Rientjes
Quoted 13 lines · Matthew Wilcox

It's probably worth doing another roundup of where we are on our journey to separating folios, slabs, pages, etc. Something suitable for people who aren't MM experts, and don't care about the details of how page allocation works. I can talk for hours about whatever people want to hear about but some ideas from me:

- Overview of how the conversion is going
- Convenience functions for filesystem writers
- What's next?
- What's the difference between &folio->page and page_folio(folio, 0)?
- What are we going to do about bio_vecs?
- How does all of this work with kmap()?

Quoted 4 lines

I'm sure people would like to suggest other questions they have that aren't adequately answered already and might be of interest to a wider audience.

Thanks for proposing this again, Matthew, I'd definitely like to be involved in the discussion as I think a couple of my colleagues, cc'd, would has well. Memory efficiency is a top priority for 2024 and, thus, getting on a pathway toward reducing the overhead of struct page is very important for our hosts that are not using large amounts of 1GB hugetlb.

Quoted 8 lines
Quoted 3 lines

I've seen your other thread regarding how the page allocator can be enlightened for memdesc, so I'm hoping that can either be covered in this topic or a separate topic.

I'd like to keep this topic relevant to as many people as possible. I can add a proposal for a topic on both the PCP and Buddy allocators (I have a series of Thoughts on how the PCP allocator works in a memdesc world that I haven't written down & sent out yet).

Interesting, given that pcp are mostly allocated by kmalloc and use vmalloc for large allocations, how memdesc can be different for them compared to regular kmalloc allocations given that they are sub-page?

Quoted 26 lines

Or we can cover the page allocators in your biweekly meetings. Maybe both since not everybody can attend either the phone call or the conference.

Quoted 5 lines

Especially important for us would be the division of work so that we can parallelize development as much as possible for things like memdesc. If there are any areas that just haven't been investigated yet but we *know* we'll need to address to get to the new world of memdesc, I think we'd love to discuss that.

Thee's so much work to be done! And it's mostly parallelisable and almost trivial. It's just largely on the filesystem-page cache interaction, so it's not terribly interesting. See, for example, the ext2, ext4, gfs2, nilfs2, ufs and ubifs patchsets I've done over the past few releases. I have about half of an ntfs3 patchset ready to send.

There's a bunch of work to be done in DRM to switch from pages to folios due to their use of shmem. You can also grep for 'page->mapping' (because fortunately we aren't too imaginative when it comes to naming variables) and find 270 places that need to be changed. Some are comments, but those still need to be updated!

Anything using lock_page(), get_page(), set_page_dirty(), using &folio->page, any of the functions in mm/folio-compat.c needs auditing. We can make the first three of those work, but they're good indicators that the code needs to be looked at.

Quoted 7 lines

There is some interesting work to be done, and one of the things I'm thinking hard about right now is how we're doing folio conversions that make sense with today's code, and stop making sense when we get to memdescs. That doesn't apply to anything interacting with the page cache (because those are folios now and in the future), but it does apply to one spot in ext4 where it allocates memory from slab and attaches a buffer_head to it ...

There are many more drivers that would need the conversion. For example, IOMMU page tables can occupy gigabytes of space, have different implementations for AMD, X86, and several ARMs. Conversion to memdesc and unifying the IO page table management implementation for these platforms would be beneficial.

#6 lore raw
Quoted 8 lines · Pasha Tatashin
Quoted 3 lines · Matthew Wilcox

I can add a proposal for a topic on both the PCP and Buddy allocators (I have a series of Thoughts on how the PCP allocator works in a memdesc world that I haven't written down & sent out yet).

Interesting, given that pcp are mostly allocated by kmalloc and use vmalloc for large allocations, how memdesc can be different for them compared to regular kmalloc allocations given that they are sub-page?

Oh! I don't mean the mm/percpu.c allocator. I mean the pcp allocator in mm/page_alloc.c.

I don't have any Thoughts on mm/percpu.c at this time. I'm vaguely aware that it exists ;-)

Quoted 25 lines
Quoted 17 lines

Thee's so much work to be done! And it's mostly parallelisable and almost trivial. It's just largely on the filesystem-page cache interaction, so it's not terribly interesting. See, for example, the ext2, ext4, gfs2, nilfs2, ufs and ubifs patchsets I've done over the past few releases. I have about half of an ntfs3 patchset ready to send.

There's a bunch of work to be done in DRM to switch from pages to folios due to their use of shmem. You can also grep for 'page->mapping' (because fortunately we aren't too imaginative when it comes to naming variables) and find 270 places that need to be changed. Some are comments, but those still need to be updated!

Anything using lock_page(), get_page(), set_page_dirty(), using &folio->page, any of the functions in mm/folio-compat.c needs auditing. We can make the first three of those work, but they're good indicators that the code needs to be looked at.

Quoted 7 lines

There is some interesting work to be done, and one of the things I'm thinking hard about right now is how we're doing folio conversions that make sense with today's code, and stop making sense when we get to memdescs. That doesn't apply to anything interacting with the page cache (because those are folios now and in the future), but it does apply to one spot in ext4 where it allocates memory from slab and attaches a buffer_head to it ...

Quoted 5 lines

There are many more drivers that would need the conversion. For example, IOMMU page tables can occupy gigabytes of space, have different implementations for AMD, X86, and several ARMs. Conversion to memdesc and unifying the IO page table management implementation for these platforms would be beneficial.

Understood; there's a lot of code that can benefit from larger allocations. I was listing the impediments to shrinking struct page rather than the places which would most benefit from switching to larger allocations. They're complementary to a large extent; you can switch to compound allocations today and get the benefit later. And unifying implementations is always a worthy project.

#7 lore raw
Quoted 7 lines · Matthew Wilcox
Quoted 5 lines · Pasha Tatashin
Quoted 3 lines · Matthew Wilcox

I can add a proposal for a topic on both the PCP and Buddy allocators (I have a series of Thoughts on how the PCP allocator works in a memdesc world that I haven't written down & sent out yet).

Quoted 6 lines
Quoted 3 lines

Interesting, given that pcp are mostly allocated by kmalloc and use vmalloc for large allocations, how memdesc can be different for them compared to regular kmalloc allocations given that they are sub-page?

Oh! I don't mean the mm/percpu.c allocator. I mean the pcp allocator in mm/page_alloc.c.

Nevermind, this makes perfect sense now :-)

Quoted 40 lines

I don't have any Thoughts on mm/percpu.c at this time. I'm vaguely aware that it exists ;-)

Quoted 25 lines
Quoted 17 lines

Thee's so much work to be done! And it's mostly parallelisable and almost trivial. It's just largely on the filesystem-page cache interaction, so it's not terribly interesting. See, for example, the ext2, ext4, gfs2, nilfs2, ufs and ubifs patchsets I've done over the past few releases. I have about half of an ntfs3 patchset ready to send.

There's a bunch of work to be done in DRM to switch from pages to folios due to their use of shmem. You can also grep for 'page->mapping' (because fortunately we aren't too imaginative when it comes to naming variables) and find 270 places that need to be changed. Some are comments, but those still need to be updated!

Anything using lock_page(), get_page(), set_page_dirty(), using &folio->page, any of the functions in mm/folio-compat.c needs auditing. We can make the first three of those work, but they're good indicators that the code needs to be looked at.

Quoted 7 lines

There is some interesting work to be done, and one of the things I'm thinking hard about right now is how we're doing folio conversions that make sense with today's code, and stop making sense when we get to memdescs. That doesn't apply to anything interacting with the page cache (because those are folios now and in the future), but it does apply to one spot in ext4 where it allocates memory from slab and attaches a buffer_head to it ...

Quoted 5 lines

There are many more drivers that would need the conversion. For example, IOMMU page tables can occupy gigabytes of space, have different implementations for AMD, X86, and several ARMs. Conversion to memdesc and unifying the IO page table management implementation for these platforms would be beneficial.

Understood; there's a lot of code that can benefit from larger allocations. I was listing the impediments to shrinking struct page rather than the places which would most benefit from switching to larger allocations. They're complementary to a large extent; you can switch to compound allocations today and get the benefit later. And unifying implementations is always a worthy project.

#8 lore raw
In reply to Matthew Wilcox
Quoted 5 lines · Matthew Wilcox

I'd like to keep this topic relevant to as many people as possible. I can add a proposal for a topic on both the PCP and Buddy allocators (I have a series of Thoughts on how the PCP allocator works in a memdesc world that I haven't written down & sent out yet).

Well the PCP cache's (I would not call it an allocator) intent is to provide cache hot / tlb hot pages. In some ways this is like the SLAB/SLUB situation. I.e. lists of objects vs. service objects that are locally related.

Can we come up with a design that uses a huge page (or some arbitrary page size) and the breaks out portions of the large page? That way potentially TLB use can be reduced (multiple sections of a large page use the same TLB) and defragmentation occurs because allocs and frees focus on a selection of large memory sections.

This is rougly equivalent to a per cpu page (folio?) in SLUB where cache hot objects can be served from a single memory section and also freed back without too much interaction with higher level more expensive components of the allocator.

#9 lore raw
Quoted 5 lines · Christoph Lameter (Ampere)

Can we come up with a design that uses a huge page (or some arbitrary page size) and the breaks out portions of the large page? That way potentially TLB use can be reduced (multiple sections of a large page use the same TLB) and defragmentation occurs because allocs and frees focus on a selection of large memory sections.

Could I trouble you to reply in this thread:
https://lore.kernel.org/linux-mm/[email protected]/
where I actually outline what I think we should do next.

#10 lore raw
Quoted 10 lines · Matthew Wilcox
Quoted 5 lines · Christoph Lameter (Ampere)

Can we come up with a design that uses a huge page (or some arbitrary page size) and the breaks out portions of the large page? That way potentially TLB use can be reduced (multiple sections of a large page use the same TLB) and defragmentation occurs because allocs and frees focus on a selection of large memory sections.

Could I trouble you to reply in this thread:
https://lore.kernel.org/linux-mm/[email protected]/
where I actually outline what I think we should do next.

Ahh... ok. Will do.

#11 lore raw
In reply to Matthew Wilcox
Quoted 14 lines · Matthew Wilcox

It's probably worth doing another roundup of where we are on our journey to separating folios, slabs, pages, etc. Something suitable for people who aren't MM experts, and don't care about the details of how page allocation works. I can talk for hours about whatever people want to hear about but some ideas from me:

- Overview of how the conversion is going
- Convenience functions for filesystem writers
- What's next?
- What's the difference between &folio->page and page_folio(folio, 0)?
- What are we going to do about bio_vecs?
- How does all of this work with kmap()?

Quoted 4 lines

I'm sure people would like to suggest other questions they have that aren't adequately answered already and might be of interest to a wider audience.

Matthew,

And everyone else who suggests LSF/MM/BPF topic.

Please do not forget to also fill out the Google form:

https://forms.gle/TGCgBDH1x5pXiWFo7

So we have your attendance request with suggested topics in our spreadsheet.

Thanks,
Amir.

#12 lore raw
Quoted 9 lines · Amir Goldstein

Matthew,

And everyone else who suggests LSF/MM/BPF topic.

Please do not forget to also fill out the Google form:

https://forms.gle/TGCgBDH1x5pXiWFo7

So we have your attendance request with suggested topics in our spreadsheet.

I'm pretty sure I already filled that out months ago within a day of the initial announcement, and I thought I included SOTP as one of the topics. But honestly, I'm not sure which topics I filled in there. Is there a way for me to know what I wrote in and edit my initial response?

#13 lore raw
In reply to Matthew Wilcox
Quoted 1 line · Matthew Wilcox

- What are we going to do about bio_vecs?

For bios and biovecs, I think it's important to keep in mind the distinction between the code that owns and submits the bio, and the consumer underneath.

The code underneath could just as easily work with pfns, and the code above got those pages from somewhere else, so it doesn't _need_ the bio for access to those pages/folios (it would be a lot of refactoring though).

But I've been thinking about going in a different direction - what if we unified iov_iter and bio? We've got ~3 different scatter-gather types that an IO passes through down the stack, and it would be lovely if we could get it down to just one; e.g. for DIO, pinning pages right at the copy_from_user boundary.

#14 lore raw
Quoted 12 lines · Kent Overstreet
Quoted 1 line · Matthew Wilcox

- What are we going to do about bio_vecs?

For bios and biovecs, I think it's important to keep in mind the distinction between the code that owns and submits the bio, and the consumer underneath.

The code underneath could just as easily work with pfns, and the code above got those pages from somewhere else, so it doesn't _need_ the bio for access to those pages/folios (it would be a lot of refactoring though).

Quoted 5 lines

But I've been thinking about going in a different direction - what if we unified iov_iter and bio? We've got ~3 different scatter-gather types that an IO passes through down the stack, and it would be lovely if we could get it down to just one; e.g. for DIO, pinning pages right at the copy_from_user boundary.

Yes, but ...

One of the things that Xen can do and Linux can't is I/O to/from memory that doesn't have an associated struct page. We have all kinds of hacks in place to get around that right now, and I'd like to remove those.

Since we want that kind of memory (lets take, eg, GPU memory as an example) to be mappable to userspace, and we want to be able to do DIO to that memory, that points us to using a non-page-based structure right from the start. Yes, if it happens to be backed by pages we need to 'pin' them in some way (I'd like to get away from per-page or even per-folio pinning, but we'll see about that), but the data structure that we use to represent that memory as it moves through the I/O subsystem needs to be physical address based.

So my 40,000 foot view is that we do something like get_user_phyrs() at the start of DIO, pas the phyr to the filesystem; the filesystem then passes one or more phyrs to the block layer, the block layer gives the phyrs to the driver which DMA maps the phyr.

Yes, the IO completion path (for buffered IO) needs to figure out which folios are decsribed by this phyr, but that's a phys_to_folio() call away.