Re: [PATCH v17 3/3] vfio/nvgrace-gpu: Add vfio pci variant module for grace hopper

From: Ankit Agrawal
Date: Thu Feb 08 2024 - 06:14:02 EST


>> >>
>> >> If mem_count == 0, going through nvgrace_gpu_map_and_read() is not
>> >> necessary.
>> >
>> > Harmless, other than the possibly unnecessary call through to
>> > nvgrace_gpu_map_device_mem().  Maybe both
>> nvgrace_gpu_map_and_read()
>> > and nvgrace_gpu_map_and_write() could conditionally return 0 as their
>> > first operation when !mem_count.  Thanks,
>> >
>> >Alex
>>
>> IMO, this seems like adding too much code to reduce the call length for a
>> very specific case. If there aren't any strong opinion on this, I'm planning to
>> leave this code as it is.
>
> a slight difference. if mem_count==0 the result should always succeed
> no matter nvgrace_gpu_map_device_mem() succeeds or not. Of course
> if it fails it's already a big problem probably nobody cares about the subtle
> difference when reading non-exist range.
>
> but regarding to readability it's still clearer:
>
> if (mem_count)
>        nvgrace_gpu_map_and_read();

Makes sense. I'll change it.