[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <655a04b7-f73c-b2e4-026e-c361c545dd8e@linux.vnet.ibm.com>
Date: Wed, 18 Aug 2021 10:48:51 +0200
From: Janis Schoetterl-Glausch <scgl@...ux.vnet.ibm.com>
To: David Hildenbrand <david@...hat.com>,
Janosch Frank <frankja@...ux.ibm.com>,
Janis Schoetterl-Glausch <scgl@...ux.ibm.com>,
kvm@...r.kernel.org, borntraeger@...ibm.com,
imbrenda@...ux.ibm.com, Heiko Carstens <hca@...ux.ibm.com>,
Vasily Gorbik <gor@...ux.ibm.com>
Cc: cohuck@...hat.com, linux-s390@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] KVM: s390: gaccess: Cleanup access to guest frames
On 8/18/21 10:44 AM, David Hildenbrand wrote:
> On 18.08.21 10:06, Janosch Frank wrote:
>> On 8/18/21 9:54 AM, David Hildenbrand wrote:
>>> On 16.08.21 17:07, Janis Schoetterl-Glausch wrote:
>>>> Introduce a helper function for guest frame access.
>>>> Rewrite the calculation of the gpa and the length of the segment
>>>> to be more readable.
>>>>
>>>> Signed-off-by: Janis Schoetterl-Glausch <scgl@...ux.ibm.com>
>> [...]
>>>> - unsigned long _len, gpa;
>>>> + unsigned long gpa;
>>>> + unsigned int seg;
>>>> int rc = 0;
>>>> while (len && !rc) {
>>>> gpa = kvm_s390_real_to_abs(vcpu, gra);
>>>> - _len = min(PAGE_SIZE - (gpa & ~PAGE_MASK), len);
>>>> - if (mode)
>>>> - rc = write_guest_abs(vcpu, gpa, data, _len);
>>>> - else
>>>> - rc = read_guest_abs(vcpu, gpa, data, _len);
>>>> - len -= _len;
>>>> - gra += _len;
>>>> - data += _len;
>>>> + seg = min(PAGE_SIZE - offset_in_page(gpa), len);
>>>
>>> What does "seg" mean? I certainly know when "len" means -- which is also
>>> what the function eats.
>>
>> What does "_len" mean especially in contrast to "len"?
>>
>> "seg" is used in the common kvm guest access functions so it's at least
>> consistent although I share the sentiment that it's not a great name for
>> the length we access inside the page.
>>
>> Originally I suggested "len_in_page" if you have a better name I'd
>> expect we'll both be happy to discuss it :-)
>
> Similar code I encountered in other places uses "len" vs "cur_len" or "total_len" vs. "cur_len". I agree that everything is better than "len" vs. "_len".
>
> I just cannot come up with a proper word for "seg" that would make sense. "Segment" ? Maybe my uneducated mind is missing some important English words that just fit perfectly here.
Yes, it's short for segment, kvm_main has a function next_segment to calculate it.
I don't like the naming scheme much either.
>
> Anyhow, just my 2 cents, you maintain this code :)
>
Powered by blists - more mailing lists