]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: Rename invalidate_begin to invalidate_start for consistency
authorTakahiro Itazuri <itazur@amazon.com>
Mon, 20 Apr 2026 15:46:04 +0000 (15:46 +0000)
committerSean Christopherson <seanjc@google.com>
Wed, 13 May 2026 16:53:03 +0000 (09:53 -0700)
Rename kvm_mmu_invalidate_begin() to kvm_mmu_invalidate_start() to
align with mmu_notifier_ops.invalidate_range_start(), which is the
callback that ultimately drives KVM's MMU invalidation.

While the naming within KVM itself is a close split between "_begin" and
"_start":

  $ git grep -E "invalidate(_range)?_begin" **/kvm* | wc -l
  12
  $ git grep -E "invalidate(_range)?_start" **/kvm* | wc -l
  21

All two of the begin() uses are in KVM:

  $ git grep -E "invalidate(_range)?_begin" * | wc -l
  14

And those two holdouts are bugs in invalidate_range_start()'s comment,
i.e. will also be fixed sooner or later[*].  On the other hand, use of
_start() is pervasive throughout the kernel:

  $ git grep -E "invalidate(_range)?_start" * | wc -l
  117

Even if that weren't the case, conforming to the mmu_notifier_ops naming
is the right call since invalidate_range_start() is the external API that
KVM hooks into.

No functional change intended.

Link: https://lore.kernel.org/all/20260513163546.1176742-1-seanjc@google.com
Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
Link: https://patch.msgid.link/20260420154720.29012-4-itazur@amazon.com
[sean: massage changelog to provide more (accurate) numbers]
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/mmu/mmu.c
include/linux/kvm_host.h
virt/kvm/guest_memfd.c
virt/kvm/kvm_main.c

index f8aa7eda661eece2bb864e503692d126c6919a91..85fd8d9e70cea39b0e04141e9fc78db278288102 100644 (file)
@@ -7002,7 +7002,7 @@ void kvm_zap_gfn_range(struct kvm *kvm, gfn_t gfn_start, gfn_t gfn_end)
 
        write_lock(&kvm->mmu_lock);
 
-       kvm_mmu_invalidate_begin(kvm);
+       kvm_mmu_invalidate_start(kvm);
 
        kvm_mmu_invalidate_range_add(kvm, gfn_start, gfn_end);
 
index 4c14aee1fb0633f7d5fc71c807ffdeacd86b51d7..7b231a1e63ba2c7ca2c421f463213a1b91a59c72 100644 (file)
@@ -1562,7 +1562,7 @@ void kvm_mmu_free_memory_cache(struct kvm_mmu_memory_cache *mc);
 void *kvm_mmu_memory_cache_alloc(struct kvm_mmu_memory_cache *mc);
 #endif
 
-void kvm_mmu_invalidate_begin(struct kvm *kvm);
+void kvm_mmu_invalidate_start(struct kvm *kvm);
 void kvm_mmu_invalidate_range_add(struct kvm *kvm, gfn_t start, gfn_t end);
 void kvm_mmu_invalidate_end(struct kvm *kvm);
 bool kvm_mmu_unmap_gfn_range(struct kvm *kvm, struct kvm_gfn_range *range);
index 69c9d6d546b287b4f75ef69868259c082ca50933..a35a55571a2da1a324deb980bf6ccb7645647d18 100644 (file)
@@ -157,7 +157,7 @@ static enum kvm_gfn_range_filter kvm_gmem_get_invalidate_filter(struct inode *in
        return KVM_FILTER_PRIVATE;
 }
 
-static void __kvm_gmem_invalidate_begin(struct gmem_file *f, pgoff_t start,
+static void __kvm_gmem_invalidate_start(struct gmem_file *f, pgoff_t start,
                                        pgoff_t end,
                                        enum kvm_gfn_range_filter attr_filter)
 {
@@ -181,7 +181,7 @@ static void __kvm_gmem_invalidate_begin(struct gmem_file *f, pgoff_t start,
                        found_memslot = true;
 
                        KVM_MMU_LOCK(kvm);
-                       kvm_mmu_invalidate_begin(kvm);
+                       kvm_mmu_invalidate_start(kvm);
                }
 
                flush |= kvm_mmu_unmap_gfn_range(kvm, &gfn_range);
@@ -194,7 +194,7 @@ static void __kvm_gmem_invalidate_begin(struct gmem_file *f, pgoff_t start,
                KVM_MMU_UNLOCK(kvm);
 }
 
-static void kvm_gmem_invalidate_begin(struct inode *inode, pgoff_t start,
+static void kvm_gmem_invalidate_start(struct inode *inode, pgoff_t start,
                                      pgoff_t end)
 {
        enum kvm_gfn_range_filter attr_filter;
@@ -203,7 +203,7 @@ static void kvm_gmem_invalidate_begin(struct inode *inode, pgoff_t start,
        attr_filter = kvm_gmem_get_invalidate_filter(inode);
 
        kvm_gmem_for_each_file(f, inode)
-               __kvm_gmem_invalidate_begin(f, start, end, attr_filter);
+               __kvm_gmem_invalidate_start(f, start, end, attr_filter);
 }
 
 static void __kvm_gmem_invalidate_end(struct gmem_file *f, pgoff_t start,
@@ -238,7 +238,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_begin(inode, start, end);
+       kvm_gmem_invalidate_start(inode, start, end);
 
        truncate_inode_pages_range(inode->i_mapping, offset, offset + len - 1);
 
@@ -352,7 +352,7 @@ static int kvm_gmem_release(struct inode *inode, struct file *file)
         * Zap all SPTEs pointed at by this file.  Do not free the backing
         * memory, as its lifetime is associated with the inode, not the file.
         */
-       __kvm_gmem_invalidate_begin(f, 0, -1ul,
+       __kvm_gmem_invalidate_start(f, 0, -1ul,
                                    kvm_gmem_get_invalidate_filter(inode));
        __kvm_gmem_invalidate_end(f, 0, -1ul);
 
@@ -504,7 +504,7 @@ 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_begin(mapping->host, start, end);
+       kvm_gmem_invalidate_start(mapping->host, start, end);
 
        /*
         * Do not truncate the range, what action is taken in response to the
index 89489996fbc1efbb6dab0e9581f98ec13b01c0ec..7ba621d2c14c8b5068fa3c7e617c0b29b178df38 100644 (file)
@@ -670,7 +670,7 @@ static __always_inline bool kvm_age_hva_range_no_flush(struct mmu_notifier *mn,
        return kvm_age_hva_range(mn, start, end, handler, false);
 }
 
-void kvm_mmu_invalidate_begin(struct kvm *kvm)
+void kvm_mmu_invalidate_start(struct kvm *kvm)
 {
        lockdep_assert_held_write(&kvm->mmu_lock);
        /*
@@ -726,7 +726,7 @@ static int kvm_mmu_notifier_invalidate_range_start(struct mmu_notifier *mn,
                .start          = range->start,
                .end            = range->end,
                .handler        = kvm_mmu_unmap_gfn_range,
-               .on_lock        = kvm_mmu_invalidate_begin,
+               .on_lock        = kvm_mmu_invalidate_start,
                .flush_on_ret   = true,
                .may_block      = mmu_notifier_range_blockable(range),
        };
@@ -2542,7 +2542,7 @@ static int kvm_vm_set_mem_attributes(struct kvm *kvm, gfn_t start, gfn_t end,
                .end = end,
                .arg.attributes = attributes,
                .handler = kvm_pre_set_memory_attributes,
-               .on_lock = kvm_mmu_invalidate_begin,
+               .on_lock = kvm_mmu_invalidate_start,
                .flush_on_ret = true,
                .may_block = true,
        };