[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Disable swiotlb for Dom0


  • To: Julien Grall <julien@xxxxxxx>, "sstabellini@xxxxxxxxxx" <sstabellini@xxxxxxxxxx>
  • From: Roman Skakun <Roman_Skakun@xxxxxxxx>
  • Date: Fri, 13 Aug 2021 15:59:53 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZregRLNf01nj4+DF+xNM1YazSprrtjcYbgSgxKQ5sBc=; b=fCQxRyeRHM93qKI7fLYwaDQnnwNaBJb0OW3IoG57XGIuew92Di1u7fyJcqqstc8+R6VyRZ7sjQZTZ1mjwmowiFyzXXNSfzDnGAlkJZpEe6q5k3878EtDww/xC0wv4cCCvtntVPOxoATxZfsfF1NRnn1K2S4xMwr4YmjTu9MkS5jUts0v0D1bt4/o1fYP/6AWdrMmkTdy9lDbx0Z15hMZi4DPBEj+J7tH17TQZ5zssk8qkz8Q14GgWHyvQFOt/VGdqCfoMnNQ4VF97fzRdaMOKj1QhS5uHnp6k2dmuSwqu6dFwJ+uThSnTrrdPTV1gke6L+X2Tm/T2mpgWl2/HBFq9g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VicMO0YRfpMYBEavh5Dzk6sbQNOHoXjFGgv21Ps9keHjxjZHmyXMz4bgY34Scok0SNrtv3BrUN8sS1g+Dzb9qf9kLaVKLOfpduVenHTXUBw86x7g3P3KwVKkvs3gPXv9wEPIoVgIo+TCdxUCp1iLuy9kx2+ufgTAJcol/0sNaCkxhlZ/0urizSosheFWZghNx1v67kr4UqWyXcKwSWi5jdfzhcXKFlzmTSARGqHj3FgK+YPRpryhU49Q6xobyjc5a0T94ZdkvO04fuErqDnxerEHVdmKBhysrZdqljTufshyQ7WU8yh2kHrDJgP3NQhzjNHfnv4l4OL2m2n+oUQXzA==
  • Authentication-results: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=epam.com;
  • Cc: Bertrand Marquis <bertrand.marquis@xxxxxxx>, Andrii Anisov <Andrii_Anisov@xxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>, Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Roman Skakun <rm.skakun@xxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Roman Skakun <Roman_Skakun@xxxxxxxx>
  • Delivery-date: Fri, 13 Aug 2021 16:00:20 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHXjfwJK3kYIT7XAUWdmOu1AWm+tKts6kUAgAD/OfqAADJaAIAAJhCIgAArBQCAAqGMMYAAN/uAgABIigY=
  • Thread-topic: Disable swiotlb for Dom0


>
> But I think, we cannot use64af97000 address in the swiotlb_bounce()
>> directly.
>>
>I am not sure to understand what you mean. Can you clarify?

I thought, that the address 64af97000 can be used directly here:
https://elixir.bootlin.com/linux/v5.10/source/kernel/dma/swiotlb.c#L572
and I was confused about it.
After some diggings I realized that this code is not reachable because 
DMA_ATTR_SKIP_CPU_SYNC is active.

>> Swiotlb did not fit requested slots because the maximum slot size equals
>> IO_TLB_SEGSIZE=128 by default.
>
>Ok. So it sounds like your problem is the have a DMA buffer that is too
>large for the default swiotlb. Did you try to bump the value from the
>command line?

Yes, you are right. I checked the implementation more detailed and figured out that
swiotlb tries to find a contiguous segment that is a big enough, as shown here:
https://elixir.bootlin.com/linux/v5.10/source/kernel/dma/swiotlb.c#L528,

But the maximum TLB segment equals 128K by default in accordance with
https://elixir.bootlin.com/linux/v5.10/source/include/linux/swiotlb.h#L25

This means that the max size of TLB segment equals:
128 * 2048 = 256K
 
After this, I tried to increase the TLB segment size like this:

diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index fbdc65782195..85f32865bb6c 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -22,7 +22,7 @@ enum swiotlb_force {
  * must be a power of 2.  What is the appropriate value ?
  * The complexity of {map,unmap}_single is linearly dependent on this value.
  */
-#define IO_TLB_SEGSIZE 128
+#define IO_TLB_SEGSIZE 2048
 
 /*
  * log of the size of each IO TLB slab.  The number of slabs is command line

and the problem is gone.

Also, I found the article https://www.xilinx.com/support/answers/72694.html
where I believe the same issue was mentioned.

Thank you so much for your time and help!


From: Julien Grall <julien@xxxxxxx>
Sent: Friday, August 13, 2021 1:51 PM
To: Roman Skakun <Roman_Skakun@xxxxxxxx>; sstabellini@xxxxxxxxxx <sstabellini@xxxxxxxxxx>
Cc: Bertrand Marquis <bertrand.marquis@xxxxxxx>; Andrii Anisov <Andrii_Anisov@xxxxxxxx>; Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>; Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>; Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>; xen-devel@xxxxxxxxxxxxxxxxxxxx <xen-devel@xxxxxxxxxxxxxxxxxxxx>; Roman Skakun <rm.skakun@xxxxxxxxx>; Jan Beulich <jbeulich@xxxxxxxx>
Subject: Re: Disable swiotlb for Dom0
 


On 13/08/2021 10:38, Roman Skakun wrote:
> Hi Julien,

Hi Roman,

>> So 0xb6000000 is most likely the GFN used to mapped the grant from the domU.
>>
>> swiotlb-xen on Arm will convert it to the MFN because it is not aware
>> whether the device is behind an IOMMU.
>
> If I'm understand right, it seems like that swiotlb-xen is not ready to
> work properly in case
> when we retrieved MFN instead of proper GFN mapped to Dom0 memory.
> Maybe you know some ideas to overcome this condition?

swiotlb-xen work as intended. You have a DMA buffer at an address that
your device cannot deal with. So it will try to bounce it.

>
>>  As the address is too high to be handled by the device, swiotlb will try
>>  to bounce it. I think it is correct to bounce the page but I am not sure
>>  why it can't. What the size of the DMA transaction?
>
> The DMA map size is 3686400 bytes.

So that's a 3MB buffer. I am slightly confused because in an earlier
message you wrote that the memory is coming from the guest. How did you
map it?

>
> I've added several logs to swiotlb map_single() and see:
> [  151.298455] <SWIOTLB> swiotlb_tbl_map_single() origin_addr:
> 64af97000, needed: 708,
> avail: 7fc0, stride: 2, index: 4160

I am not sure how to read the logs... Are the number in hexadecimal or
decimal? It might be useful if you post the diff of your changes.

[...]

> Swiotlb did not fit requested slots because the maximum slot size equals
> IO_TLB_SEGSIZE=128 by default.

Ok. So it sounds like your problem is the have a DMA buffer that is too
large for the default swiotlb. Did you try to bump the value from the
command line?

> But I think, we cannot use64af97000 address in the swiotlb_bounce()
> directly.

I am not sure to understand what you mean. Can you clarify?

Cheers,

[...]

--
Julien Grall

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.