Re: [PATCH v12 01/12] KVM: guest_memfd: Rename "struct kvm_gmem" to "struct gmem_file"

Ackerley Tng
2025-10-09T21:08:02Z

"Garg, Shivank" <shivankg@amd.com> writes:

> On 10/8/2025 3:44 AM, Sean Christopherson wrote:
>>
>> [...snip...]
>>
>> @@ -659,18 +667,18 @@ static struct folio *__kvm_gmem_get_pfn(struct file *file,
>> pgoff_t index, kvm_pfn_t *pfn,
>> bool *is_prepared, int *max_order)
>> {
>> - struct file *gmem_file = READ_ONCE(slot->gmem.file);
>> - struct kvm_gmem *gmem = file->private_data;
>> + struct file *slot_file = READ_ONCE(slot->gmem.file);
>> + struct gmem_file *f = file->private_data;
> ^^^
>> struct folio *folio;
>>
>> - if (file != gmem_file) {
>> - WARN_ON_ONCE(gmem_file);
>> + if (file != slot_file) {
>> + WARN_ON_ONCE(slot_file);
>> return ERR_PTR(-EFAULT);
>> }
>>
>> - gmem = file->private_data;
>> - if (xa_load(&gmem->bindings, index) != slot) {
>> - WARN_ON_ONCE(xa_load(&gmem->bindings, index));
>> + f = file->private_data;
>
> This redundant initialization can be dropped.
>
> I sent a cleanup patch including this change a few weeks ago:

Agree, and probably good to opportunistically drop this line in this
patch than to combine cleanups in Shivank's other patch.

>
> https://lore.kernel.org/kvm/20250902080307.153171-2-shivankg@amd.com
>
> Could you please review it?
>
> Everything else looks good to me!
>
> Reviewed-by: Shivank Garg <shivankg@amd.com>
>

Reviewed-by: Ackerley Tng <ackerleytng@google.com>
Tested-by: Ackerley Tng <ackerleytng@google.com>

>> + if (xa_load(&f->bindings, index) != slot) {
>> + WARN_ON_ONCE(xa_load(&f->bindings, index));
>> return ERR_PTR(-EIO);
>> }
>>
>
> Thanks,
> Shivank