Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1200668 > unrolled thread

Re: [SHDCI] Heavy (thousands) DMA leaks

Started byJiri Slaby <jslaby@suse.cz>
First post2015-08-05 14:00 +0200
Last post2015-08-06 11:20 +0200
Articles 6 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [SHDCI] Heavy (thousands) DMA leaks Jiri Slaby <jslaby@suse.cz> - 2015-08-05 14:00 +0200
    [RFC] sdhci: fix DMA leaks [was: [SHDCI] Heavy (thousands) DMA leaks] Jiri Slaby <jslaby@suse.cz> - 2015-08-05 17:20 +0200
      Re: [RFC] sdhci: fix DMA leaks [was: [SHDCI] Heavy (thousands) DMA  leaks] Pavel Machek <pavel@ucw.cz> - 2015-08-05 18:30 +0200
      RE: [RFC] sdhci: fix DMA leaks [was: [SHDCI] Heavy (thousands) DMA  leaks] Chen Bough <Haibo.Chen@freescale.com> - 2015-08-06 09:50 +0200
        Re: [RFC] sdhci: fix DMA leaks [was: [SHDCI] Heavy (thousands) DMA  leaks] Jiri Slaby <jslaby@suse.cz> - 2015-08-06 11:10 +0200
          RE: [RFC] sdhci: fix DMA leaks [was: [SHDCI] Heavy (thousands) DMA  leaks] Chen Bough <Haibo.Chen@freescale.com> - 2015-08-06 11:20 +0200

#1200668 — Re: [SHDCI] Heavy (thousands) DMA leaks

FromJiri Slaby <jslaby@suse.cz>
Date2015-08-05 14:00 +0200
SubjectRe: [SHDCI] Heavy (thousands) DMA leaks
Message-ID<pU5wu-nj-9@gated-at.bofh.it>

[Multipart message — attachments visible in raw view] — view raw

On 08/03/2015, 11:39 AM, Jiri Slaby wrote:
> Hi,
> 
> On 08/03/2015, 11:30 AM, Chen Bough wrote:
>> I carefully review my patch, all the DMA memory mapped in sdhci_pre_req() is unmapped in sdhci_post_req.
> 
> I suspect 'host_cookie' or 'next' handling is bad somewhere. But I don't
> know...
> 
>> Can you provide the method of your testing DMA leaks?
> 
> boot kernel with CONFIG_DMA_API_DEBUG
> insert the card
> mount it
> rsync from the card ~200 MB
> umount it
> unload the sdhci driver
> the leak warning is reported
> 
> I am not sure whether suspend-resume is needed after the first step.

No, it's not. This is sufficient:
boot kernel with CONFIG_DMA_API_DEBUG
insert the card
<no mounting, partition table read is enough>
remove the card
unload the sdhci driver
the leak warning is reported

>> You said over 4000 leaked mappings during one card transfer, if true, 
>> We can't map any dma memory after some sd transfer, do you meet this?
> 
> Yes, I see:
> sdhci-pci 0000:02:00.0: swiotlb buffer is full (sz: 65536 bytes)
> after some time. The driver falls back to non-DMA transfers after that.
> It also generates a warning about that:
> WARNING: CPU: 0 PID: 0 at drivers/mmc/host/sdhci.c:857
> sdhci_prepare_data+0x8ec/0x900 [sdhci]()

I am attaching a debug patch and a debug log. You can see where
0x00000000fffb0000 and 0x00000000fffe0000 is leaked. It is when 'invalid
cookie' error happens.

regards,
-- 
js
suse labs

[toc] | [next] | [standalone]


#1200863 — [RFC] sdhci: fix DMA leaks [was: [SHDCI] Heavy (thousands) DMA leaks]

FromJiri Slaby <jslaby@suse.cz>
Date2015-08-05 17:20 +0200
Subject[RFC] sdhci: fix DMA leaks [was: [SHDCI] Heavy (thousands) DMA leaks]
Message-ID<pU8E2-57u-29@gated-at.bofh.it>
In reply to#1200668

[Multipart message — attachments visible in raw view] — view raw

On 08/05/2015, 01:52 PM, Jiri Slaby wrote:
>> Yes, I see:
>> sdhci-pci 0000:02:00.0: swiotlb buffer is full (sz: 65536 bytes)
>> after some time. The driver falls back to non-DMA transfers after that.
>> It also generates a warning about that:
>> WARNING: CPU: 0 PID: 0 at drivers/mmc/host/sdhci.c:857
>> sdhci_prepare_data+0x8ec/0x900 [sdhci]()
> 
> I am attaching a debug patch and a debug log. You can see where
> 0x00000000fffb0000 and 0x00000000fffe0000 is leaked. It is when 'invalid
> cookie' error happens.

And you could see the cookie handling is totally bogus.

With this rewrite, I no longer see the problems. Could you confirm it
still does the good job with respect to performance -- the numbers you
mentioned in your commit.

Ulf, what do you think about the attached patch? (Do not look at the
commented info prints.)

thanks,
-- 
js
suse labs

[toc] | [prev] | [next] | [standalone]


#1200965 — Re: [RFC] sdhci: fix DMA leaks [was: [SHDCI] Heavy (thousands) DMA leaks]

FromPavel Machek <pavel@ucw.cz>
Date2015-08-05 18:30 +0200
SubjectRe: [RFC] sdhci: fix DMA leaks [was: [SHDCI] Heavy (thousands) DMA leaks]
Message-ID<pU9JM-6FB-13@gated-at.bofh.it>
In reply to#1200863
On Wed 2015-08-05 17:11:48, Jiri Slaby wrote:
> On 08/05/2015, 01:52 PM, Jiri Slaby wrote:
> >> Yes, I see:
> >> sdhci-pci 0000:02:00.0: swiotlb buffer is full (sz: 65536 bytes)
> >> after some time. The driver falls back to non-DMA transfers after that.
> >> It also generates a warning about that:
> >> WARNING: CPU: 0 PID: 0 at drivers/mmc/host/sdhci.c:857
> >> sdhci_prepare_data+0x8ec/0x900 [sdhci]()
> > 
> > I am attaching a debug patch and a debug log. You can see where
> > 0x00000000fffb0000 and 0x00000000fffe0000 is leaked. It is when 'invalid
> > cookie' error happens.
> 
> And you could see the cookie handling is totally bogus.
> 
> With this rewrite, I no longer see the problems. Could you confirm it
> still does the good job with respect to performance -- the numbers you
> mentioned in your commit.
> 
> Ulf, what do you think about the attached patch? (Do not look at the
> commented info prints.)

Umm. Normally we inline patches for easier comments.

Attaching it with type of _mailbox_ is not really good.

									Pavel

[-- Attachment #2: fix.patch --]
[-- Type: application/mbox, Encoding: base64, Size: 8.2K --]





-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1201526 — RE: [RFC] sdhci: fix DMA leaks [was: [SHDCI] Heavy (thousands) DMA leaks]

FromChen Bough <Haibo.Chen@freescale.com>
Date2015-08-06 09:50 +0200
SubjectRE: [RFC] sdhci: fix DMA leaks [was: [SHDCI] Heavy (thousands) DMA leaks]
Message-ID<pUo66-2mn-5@gated-at.bofh.it>
In reply to#1200863
SGkgSnMsDQoNCkkgcmVhZCB5b3VyIGF0dGFjaGVkIGxvZyBhbmQgcGF0Y2gsIHllcywgZG1hIG1l
bW9yeSBsZWFrIHdpbGwgaGFwcGVuIHdoZW4NCm1vcmUgdGhhbiBvbmUgcHJlX3JlcXVlc3QgZXhl
Y3V0ZS4gVGhlIG1ldGhvZCBvZiArK25leHQtPmNvb2tpZSBpcyBub3QgZ29vZCwNCnlvdXIgcGF0
Y2ggc2VlbXMgZ29vZCwgYnV0IEkgc3RpbGwgbmVlZCBzb21lIHRpbWUgdG8gdGVzdCB0aGUgcGF0
Y2gsIGJlY2F1c2UNCnlvdSB1bm1hcCB0aGUgZG1hIGluIHNkaGNpX2ZpbmlzaF9kYXRhIHJhdGhl
ciB0aGFuIHRoZSBzZGhjaV9wb3N0X3JlcS4NCg0KQW55d2F5LCB0aGFua3MgZm9yIHJlcG9ydCBh
bmQgZGVidWcgdGhpcyBpc3N1ZS4gSSB3aWxsIGdpdmUgeW91IG15IHRlc3QgcmVzdWx0DQpBU0FQ
LiAgDQoNCkJlc3QgUmVnYXJkcw0KSGFpYm8gQ2hlbg0KDQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNz
YWdlLS0tLS0NCj4gRnJvbTogSmlyaSBTbGFieSBbbWFpbHRvOmpzbGFieUBzdXNlLmN6XQ0KPiBT
ZW50OiBXZWRuZXNkYXksIEF1Z3VzdCAwNSwgMjAxNSAxMToxMiBQTQ0KPiBUbzogQ2hlbiBIYWli
by1CNTE0MjE7IFVsZiBIYW5zc29uDQo+IENjOiBsaW51eC1tbWNAdmdlci5rZXJuZWwub3JnOyBM
aW51eCBrZXJuZWwgbWFpb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eW91IGNvbmZpcm0g
aXQNCj4gc3RpbGwgZG9lcyB0aGUgZ29vZCBqb2Igd2l0aCByZXNwZWN0IHRvIHBlcmZvcm1hbmNl
IC0tIHRoZSBudW1iZXJzIHlvdQ0KPiBtZW50aW9uZWQgaW4geW91ciBjb21taXQuDQo+IA0KPiBV
bGYsIHdoYXQgZG8geW91IHRoaW5rIGFib3V0IHRoZSBhdHRhY2hlZCBwYXRjaD8gKERvIG5vdCBs
b29rIGF0IHRoZQ0KPiBjb21tZW50ZWQgaW5mbyBwcmludHMuKQ0KPiANCj4gdGhhbmtzLA0KPiAt
LQ0KPiBqcw0KPiBzdXNlIGxhYnMNCg==
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1201594 — Re: [RFC] sdhci: fix DMA leaks [was: [SHDCI] Heavy (thousands) DMA leaks]

FromJiri Slaby <jslaby@suse.cz>
Date2015-08-06 11:10 +0200
SubjectRe: [RFC] sdhci: fix DMA leaks [was: [SHDCI] Heavy (thousands) DMA leaks]
Message-ID<pUplv-4re-7@gated-at.bofh.it>
In reply to#1201526
On 08/06/2015, 09:42 AM, Chen Bough wrote:
> I read your attached log and patch, yes, dma memory leak will happen when
> more than one pre_request execute. The method of ++next->cookie is not good,
> your patch seems good, but I still need some time to test the patch, because
> you unmap the dma in sdhci_finish_data rather than the sdhci_post_req.

Hi,

yes, this is not correct. We can perhaps differentiate according to the
COOKIE value. Should I fix it or are you going to prepare a patch based
on my RFC?

thanks,
-- 
js
suse labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1201599 — RE: [RFC] sdhci: fix DMA leaks [was: [SHDCI] Heavy (thousands) DMA leaks]

FromChen Bough <Haibo.Chen@freescale.com>
Date2015-08-06 11:20 +0200
SubjectRE: [RFC] sdhci: fix DMA leaks [was: [SHDCI] Heavy (thousands) DMA leaks]
Message-ID<pUpvc-4Ct-3@gated-at.bofh.it>
In reply to#1201594
SSB3aWxsIGZvcm1hdCBhIHBhdGNoIGJhc2VkIG9uIHlvdXIgZGlmZiBmaWxlIGZpcnN0bHkuIEkg
d2lsbCB0ZXN0IHRoaXMgb24gbXkgc2lkZSwNCklmIGFueSBpc3N1ZSwgbGlrZSBkbWEgaXNzdWUg
b3IgcGVyZm9ybWFuY2UgaXNzdWUsIEkgd2lsbCBhZGQgc29tZSBtb2RpZmljYXRpb24uDQpUaGVu
IEkgd2lsbCBzZW5kIHRoZSBwYXRjaCBmb3IgcmV2aWV3LCBhbmQgeW91IGNhbiB0ZXN0IHRoZSBw
YXRjaCBvbiB5b3VyIHBsYXRmb3JtLg0KDQpCZXN0IFJlZ2FyZHMNCkhhaWJvIENoZW4NCg0KDQo+
IC0tLS0tT3JpZ2luYWwgTWVzc2FnZS0tLS0tDQo+IEZyb206IEppcmkgU2xhYnkgW21haWx0bzpq
c2xhYnlAc3VzZS5jel0NCj4gU2VudDogVGh1cnNkYXksIEF1Z3VzdCAwNiwgMjAxNSA1OjA3IFBN
DQo+IFRvOiBDaGVuIEhhaWJvLUI1MTQyMTsgVWxmIEhhbnNzb24NCj4gQ2M6IGxpbnV4LW1tY0B2
Z2VyLmtlcm5lbC5vcmc7IExpbnV4IGtlcm5lbCBtYWlsaW5nIGxpc3QNCj4gU3ViamVjdDogUmU6
IFtSRkNdIHNkaGNpOiBmaXggRE1BIGxlYWtzIFt3YXM6IFtTSERDSV0gSGVhdnkgKHRob3VzYW5k
cykNCj4gRE1BIGxlYWtzXQ0KPiANCj4gT24gMDgvMDYvMjAxNSwgMDk6NDIgQU0sIENoZW4gQm91
Z2ggd3JvdGU6DQo+ID4gSSByZWFkIHlvdXIgYXR0YWNoZWQgbG9nIGFuZCBwYXRjaCwgeWVzLCBk
bWEgbWVtb3J5IGxlYWsgd2lsbCBoYXBwZW4NCj4gPiB3aGVuIG1vcmUgdGhhbiBvbmUgcHJlX3Jl
cXVlc3QgZXhlY3V0ZS4gVGhlIG1ldGhvZCBvZiArK25leHQtPmNvb2tpZQ0KPiA+IGlzIG5vdCBn
b29kLCB5b3VyIHBhdGNoIHNlZW1zIGdvb2QsIGJ1dCBJIHN0aWxsIG5lZWQgc29tZSB0aW1lIHRv
IHRlc3QNCj4gPiB0aGUgcGF0Y2gsIGJlY2F1c2UgeW91IHVubWFwIHRoZSBkbWEgaW4gc2RoY2lf
ZmluaXNoX2RhdGEgcmF0aGVyIHRoYW4NCj4gdGhlIHNkaGNpX3Bvc3RfcmVxLg0KPiANCj4gSGks
DQo+IA0KPiB5ZXMsIHRoaXMgaXMgbm90IGNvcnJlY3QuIFdlIGNhbiBwZXJoYXBzIGRpZmZlcmVu
dGlhdGUgYWNjb3JkaW5nIHRvIHRoZQ0KPiBDT09LSUUgdmFsdWUuIFNob3VsZCBJIGZpeCBpdCBv
ciBhcmUgeW91IGdvaW5nIHRvIHByZXBhcmUgYSBwYXRjaCBiYXNlZA0KPiBvbiBteSBSRkM/DQo+
IA0KPiB0aGFua3MsDQo+IC0tDQo+IGpzDQo+IHN1c2UgbGFicw0K
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web