[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <diqzwm53hil5.fsf@google.com>
Date: Thu, 09 Oct 2025 14:27:02 -0700
From: Ackerley Tng <ackerleytng@...gle.com>
To: Sean Christopherson <seanjc@...gle.com>, Marc Zyngier <maz@...nel.org>,
Oliver Upton <oliver.upton@...ux.dev>, Paolo Bonzini <pbonzini@...hat.com>
Cc: linux-arm-kernel@...ts.infradead.org, kvmarm@...ts.linux.dev,
kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
David Hildenbrand <david@...hat.com>, Fuad Tabba <tabba@...gle.com>, Shivank Garg <shivankg@....com>,
Ashish Kalra <ashish.kalra@....com>, Vlastimil Babka <vbabka@...e.cz>
Subject: Re: [PATCH v12 02/12] KVM: guest_memfd: Add macro to iterate over
gmem_files for a mapping/inode
Sean Christopherson <seanjc@...gle.com> writes:
> 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".
>
Can we also add to .clang-format:
diff --git i/.clang-format w/.clang-format
index 48405c54ef271..e4df86f2d3cf7 100644
--- i/.clang-format
+++ w/.clang-format
@@ -541,6 +541,7 @@ ForEachMacros:
- 'kvm_for_each_memslot'
- 'kvm_for_each_memslot_in_gfn_range'
- 'kvm_for_each_vcpu'
+ - 'kvm_gmem_for_each_file'
- 'libbpf_nla_for_each_attr'
- 'list_for_each'
- 'list_for_each_codec'
Reviewed-by: Ackerley Tng <ackerleytng@...gle.com>
Tested-by: Ackerley Tng <ackerleytng@...gle.com>
> No functional change intended.
>
> Signed-off-by: Sean Christopherson <seanjc@...gle.com>
> ---
> virt/kvm/guest_memfd.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c
> index 3c57fb42f12c..9b9e239b3073 100644
> --- a/virt/kvm/guest_memfd.c
> +++ b/virt/kvm/guest_memfd.c
> @@ -22,6 +22,9 @@ struct gmem_file {
> struct list_head entry;
> };
>
> +#define kvm_gmem_for_each_file(f, mapping) \
> + list_for_each_entry(f, &(mapping)->i_private_list, entry)
> +
> /**
> * folio_file_pfn - like folio_file_page, but return a pfn.
> * @folio: The folio which contains this index.
> @@ -159,13 +162,12 @@ static void __kvm_gmem_invalidate_begin(struct gmem_file *f, pgoff_t start,
> static void kvm_gmem_invalidate_begin(struct inode *inode, pgoff_t start,
> pgoff_t end)
> {
> - struct list_head *gmem_list = &inode->i_mapping->i_private_list;
> enum kvm_gfn_range_filter attr_filter;
> struct gmem_file *f;
>
> attr_filter = kvm_gmem_get_invalidate_filter(inode);
>
> - list_for_each_entry(f, gmem_list, entry)
> + kvm_gmem_for_each_file(f, inode->i_mapping)
> __kvm_gmem_invalidate_begin(f, start, end, attr_filter);
> }
>
> @@ -184,10 +186,9 @@ static void __kvm_gmem_invalidate_end(struct gmem_file *f, pgoff_t start,
> static void kvm_gmem_invalidate_end(struct inode *inode, pgoff_t start,
> pgoff_t end)
> {
> - struct list_head *gmem_list = &inode->i_mapping->i_private_list;
> struct gmem_file *f;
>
> - list_for_each_entry(f, gmem_list, entry)
> + kvm_gmem_for_each_file(f, inode->i_mapping)
> __kvm_gmem_invalidate_end(f, start, end);
> }
>
> --
> 2.51.0.710.ga91ca5db03-goog
Powered by blists - more mailing lists