mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
KVM: guest_memfd: Pass mapping type filter to invalidation helper
Accept the mapping type filter as a parameter in the invalidation start helper instead of querying it internally. This allows callers to specify which mappings (shared, private, or both) should be invalidated. In the next patch, the conversion process will use this new parameter to invalidate mappings only when they're different from the target state of the conversion, i.e. invalidate only shared mappings on a shared to private conversion and not both. No functional change intended. Signed-off-by: Ackerley Tng <ackerleytng@google.com> Reviewed-by: Fuad Tabba <fuad.tabba@linux.dev> Reviewed-by: Binbin Wu <binbin.wu@linux.intel.com> Reviewed-by: David Hildenbrand (Arm) <david@kernel.org> Tested-by: Yan Zhao <yan.y.zhao@intel.com> Link: https://patch.msgid.link/20260910-gmem-inplace-conversion-v13-13-dd6fbf94f4e1@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
parent
2e646bcfcf
commit
2f7f4e1028
|
|
@ -192,13 +192,13 @@ static void __kvm_gmem_invalidate_start(struct gmem_file *f, pgoff_t start,
|
|||
}
|
||||
|
||||
static void kvm_gmem_invalidate_start(struct inode *inode, pgoff_t start,
|
||||
pgoff_t end)
|
||||
pgoff_t end,
|
||||
enum kvm_gfn_range_filter filter)
|
||||
{
|
||||
enum kvm_gfn_range_filter attr_filter = kvm_gmem_get_all_gfns_filter(inode);
|
||||
struct gmem_file *f;
|
||||
|
||||
kvm_gmem_for_each_file(f, inode)
|
||||
__kvm_gmem_invalidate_start(f, start, end, attr_filter);
|
||||
__kvm_gmem_invalidate_start(f, start, end, filter);
|
||||
}
|
||||
|
||||
static void __kvm_gmem_invalidate_end(struct gmem_file *f, pgoff_t start,
|
||||
|
|
@ -224,6 +224,7 @@ static void kvm_gmem_invalidate_end(struct inode *inode, pgoff_t start,
|
|||
|
||||
static long kvm_gmem_punch_hole(struct inode *inode, loff_t offset, loff_t len)
|
||||
{
|
||||
enum kvm_gfn_range_filter filter = kvm_gmem_get_all_gfns_filter(inode);
|
||||
pgoff_t start = offset >> PAGE_SHIFT;
|
||||
pgoff_t end = (offset + len) >> PAGE_SHIFT;
|
||||
|
||||
|
|
@ -233,7 +234,7 @@ static long kvm_gmem_punch_hole(struct inode *inode, loff_t offset, loff_t len)
|
|||
*/
|
||||
filemap_invalidate_lock(inode->i_mapping);
|
||||
|
||||
kvm_gmem_invalidate_start(inode, start, end);
|
||||
kvm_gmem_invalidate_start(inode, start, end, filter);
|
||||
|
||||
truncate_inode_pages_range(inode->i_mapping, offset, offset + len - 1);
|
||||
|
||||
|
|
@ -561,6 +562,8 @@ static int kvm_gmem_migrate_folio(struct address_space *mapping,
|
|||
|
||||
static int kvm_gmem_error_folio(struct address_space *mapping, struct folio *folio)
|
||||
{
|
||||
struct inode *inode = mapping->host;
|
||||
enum kvm_gfn_range_filter filter;
|
||||
pgoff_t start, end;
|
||||
|
||||
filemap_invalidate_lock_shared(mapping);
|
||||
|
|
@ -568,7 +571,8 @@ static int kvm_gmem_error_folio(struct address_space *mapping, struct folio *fol
|
|||
start = folio->index;
|
||||
end = start + folio_nr_pages(folio);
|
||||
|
||||
kvm_gmem_invalidate_start(mapping->host, start, end);
|
||||
filter = kvm_gmem_get_all_gfns_filter(inode);
|
||||
kvm_gmem_invalidate_start(inode, start, end, filter);
|
||||
|
||||
/*
|
||||
* Do not truncate the range, what action is taken in response to the
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user