Re: [PATCH 04/12] swiotlb-xen: ensure to issue well-formed XENMEM_exchange requests

From: Jan Beulich
Date: Wed Sep 08 2021 - 05:16:57 EST


On 08.09.2021 08:57, Christoph Hellwig wrote:
> On Tue, Sep 07, 2021 at 02:05:32PM +0200, Jan Beulich wrote:
>> While the hypervisor hasn't been enforcing this, we would still better
>> avoid issuing requests with GFNs not aligned to the requested order.
>>
>> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
>> ---
>> I wonder how useful it is to include the alignment in the panic()
>> message. I further wonder how useful it is to wrap "bytes" in
>> PAGE_ALIGN(), when it is a multiple of a segment's size anyway (or at
>> least was supposed to be, prior to "swiotlb-xen: maintain slab count
>> properly").
>>
>> --- a/drivers/xen/swiotlb-xen.c
>> +++ b/drivers/xen/swiotlb-xen.c
>> @@ -231,10 +231,10 @@ retry:
>> /*
>> * Get IO TLB memory from any location.
>> */
>> - start = memblock_alloc(PAGE_ALIGN(bytes), PAGE_SIZE);
>> + start = memblock_alloc(PAGE_ALIGN(bytes), IO_TLB_SEGSIZE << IO_TLB_SHIFT);
>> if (!start)
>> - panic("%s: Failed to allocate %lu bytes align=0x%lx\n",
>> - __func__, PAGE_ALIGN(bytes), PAGE_SIZE);
>> + panic("%s: Failed to allocate %lu bytes align=%#x\n",
>> + __func__, PAGE_ALIGN(bytes), IO_TLB_SEGSIZE << IO_TLB_SHIFT);
>
> CAn you avoid the overly long lines here? A good way to make it more
> readable would be a variable to hold the byte count.

There already is a variable for the byte count - bytes. Did you read
the post-commit-message remark? _That's_ what I'd prefer to shorten
things. Meanwhile I can of course wrap lines; I will admit that I
failed to pay attention to line length here.

Jan