Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

KVM: guest_memfd: Add macro to iterate over gmem_files for a mapping/inode

Add a kvm_gmem_for_each_file() to make it more obvious that KVM is
iterating over guest_memfd _files_, not guest_memfd instances, as could
be assumed given the name "gmem_list".

No functional change intended.

Reviewed-by: Ackerley Tng <ackerleytng@google.com>
Tested-by: Ackerley Tng <ackerleytng@google.com>
Reviewed-by: Shivank Garg <shivankg@amd.com>
Tested-by: Shivank Garg <shivankg@amd.com>
Link: https://lore.kernel.org/r/20251016172853.52451-3-seanjc@google.com
[sean: drop .clang-format change]
Signed-off-by: Sean Christopherson <seanjc@google.com>

+5 -4
+5 -4
virt/kvm/guest_memfd.c
··· 22 22 struct list_head entry; 23 23 }; 24 24 25 + #define kvm_gmem_for_each_file(f, mapping) \ 26 + list_for_each_entry(f, &(mapping)->i_private_list, entry) 27 + 25 28 /** 26 29 * folio_file_pfn - like folio_file_page, but return a pfn. 27 30 * @folio: The folio which contains this index. ··· 167 164 static void kvm_gmem_invalidate_begin(struct inode *inode, pgoff_t start, 168 165 pgoff_t end) 169 166 { 170 - struct list_head *gmem_list = &inode->i_mapping->i_private_list; 171 167 enum kvm_gfn_range_filter attr_filter; 172 168 struct gmem_file *f; 173 169 174 170 attr_filter = kvm_gmem_get_invalidate_filter(inode); 175 171 176 - list_for_each_entry(f, gmem_list, entry) 172 + kvm_gmem_for_each_file(f, inode->i_mapping) 177 173 __kvm_gmem_invalidate_begin(f, start, end, attr_filter); 178 174 } 179 175 ··· 191 189 static void kvm_gmem_invalidate_end(struct inode *inode, pgoff_t start, 192 190 pgoff_t end) 193 191 { 194 - struct list_head *gmem_list = &inode->i_mapping->i_private_list; 195 192 struct gmem_file *f; 196 193 197 - list_for_each_entry(f, gmem_list, entry) 194 + kvm_gmem_for_each_file(f, inode->i_mapping) 198 195 __kvm_gmem_invalidate_end(f, start, end); 199 196 } 200 197