MFC note: pge should go at the end of the struct vm_object for some KBI stability.
Details
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Skipped - Unit
Tests Skipped
Event Timeline
Right now both hooks are called with the object locked, and the 'before_removal' is called with the page xbusied.
I am not sure that this is what needed for the callers: for instance, we might consider xbusying the page for 'after_insert' unconditionally regardless of the vm_page_alloc() mode. Then hooks are allowed to unlock the object if needed.
Would you mind adding a note what this will be good for in the future to the proposed commit message?
The intent is to allow augment the actions on the page lifetime in a modular way. For instance, in D55956 there is a need to page in/out additional metadata when a page is paged.
Right now this is not even a commit candidate, but the initial form of concrete change to discuss the needs and get it into some useful shape (I hope).
We already have pager methods for page insertion and removal, why aren't they sufficient?
I'm not very clear on how this would be useful for MTE. Suppose we fault on a page that had been paged out and freed. We need to recover the MTE tags associated with that (anonymous) page. The page fault handler will allocate some pages and insert them into the object. What will the hook do at that point? The page is allocated but its contents are not valid until vm_pager_getpages() has paged in the page data, so I don't see how the after_insert hook is useful.
I want the hooks to be set on per-object basis, not globally for all pagers of some type. My use case is having objects backing the IOMMU-managed DMA to be swap objects. This is not too useful for busdma, but I believe is doable and might be not even too hard for bhyve pass-through, assuming I land the iommu/bhyve integration.
I'm not very clear on how this would be useful for MTE. Suppose we fault on a page that had been paged out and freed. We need to recover the MTE tags associated with that (anonymous) page. The page fault handler will allocate some pages and insert them into the object. What will the hook do at that point? The page is allocated but its contents are not valid until vm_pager_getpages() has paged in the page data, so I don't see how the after_insert hook is useful.
I supposed that for MTE there is a need to page in something in addition to the current page, and this something is indexed by the same pindex but belongs to a different swap object.
But the design allows to specify more hooks, and I exactly want the discussion which hooks are useful.
At least for now I suggest renaming the hooks to remove the use of "pager".
Certain pager types already let us set per-object hooks: phys_pager_ops and cdev_pager_ops. Should this replace those mechanisms too?
I'm not very clear on how this would be useful for MTE. Suppose we fault on a page that had been paged out and freed. We need to recover the MTE tags associated with that (anonymous) page. The page fault handler will allocate some pages and insert them into the object. What will the hook do at that point? The page is allocated but its contents are not valid until vm_pager_getpages() has paged in the page data, so I don't see how the after_insert hook is useful.
I supposed that for MTE there is a need to page in something in addition to the current page, and this something is indexed by the same pindex but belongs to a different swap object.
AFAIK, MTE does not need to page in anything, it just needs to maintain additional metadata for swapped-out pages. (Maybe it would indeed be useful to be able to swap out MTE tag metadata, since it is somewhat large.) It might be that this metadata should be maintained in the object rather than in swpblks. e.g., I can imagine having a new MD field in struct vm_object which is a pctrie root, and the swap pager allocates tag blocks and inserts them into the trie.
But the design allows to specify more hooks, and I exactly want the discussion which hooks are useful.
Maybe @andrew can chime in. I /think/ it is sufficient to hook swap_pager_getpages() and _putpages(). In CHERI we need something similar for preserving capability tags across page-out->page-in.
Not all swap objects need to save tags, just anonymous objects.
Done.
Certain pager types already let us set per-object hooks: phys_pager_ops and cdev_pager_ops. Should this replace those mechanisms too?
They are quite different. Per-object methods (not hooks, I would say) for phys and cdev are about augmenting the pager methods, not about the page lifetime management. So far the set of objects (anon and possibly vnodes) that could use page lifetime hooks do not intersect with the set of objects that utilize the pager methods (phys and cdev).
I'm not very clear on how this would be useful for MTE. Suppose we fault on a page that had been paged out and freed. We need to recover the MTE tags associated with that (anonymous) page. The page fault handler will allocate some pages and insert them into the object. What will the hook do at that point? The page is allocated but its contents are not valid until vm_pager_getpages() has paged in the page data, so I don't see how the after_insert hook is useful.
I supposed that for MTE there is a need to page in something in addition to the current page, and this something is indexed by the same pindex but belongs to a different swap object.
AFAIK, MTE does not need to page in anything, it just needs to maintain additional metadata for swapped-out pages. (Maybe it would indeed be useful to be able to swap out MTE tag metadata, since it is somewhat large.) It might be that this metadata should be maintained in the object rather than in swpblks. e.g., I can imagine having a new MD field in struct vm_object which is a pctrie root, and the swap pager allocates tag blocks and inserts them into the trie.
But the design allows to specify more hooks, and I exactly want the discussion which hooks are useful.
Maybe @andrew can chime in. I /think/ it is sufficient to hook swap_pager_getpages() and _putpages(). In CHERI we need something similar for preserving capability tags across page-out->page-in.
FWIW page insertion removal is the superset of swapin/swapout, so the added hooks should be fine (I want to think so).
Not all swap objects need to save tags, just anonymous objects.
And then MTE code should attach hooks only to the relevant objects kinds.