From: Stefan Klug <stefan.klug@baslerweb.com>
To: <linux-usb@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH][RFC] USB: zerocopy support for usbfs
Date: Thu, 3 Jul 2014 10:22:06 +0200 [thread overview]
Message-ID: <53B512AE.2040802@baslerweb.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1407021532370.874-100000@iolanthe.rowland.org>
On 02.07.2014 21:38, Alan Stern wrote:
> On Wed, 2 Jul 2014, Oliver Neukum wrote:
>
>>
Stefan Klug
Software Developer
Basler AG
An der Strusbek 60-62
22926 Ahrensburg
Germany
Tel. +49 4102 463 582
Fax +49 4102 463 46 582
Stefan.Klug@baslerweb.com
www.baslerweb.com
Vorstand: Dr.-Ing. Dietmar Ley (Vorsitzender) · John P. Jennings · Arndt Bake · Hardy Mehl
Aufsichtsratsvorsitzender: Norbert Basler
Basler AG · Amtsgericht Lübeck HRB 4090 · Ust-IdNr.: DE 135 098 121 · Steuer-Nr.: 30 292 04497 · WEEE-Reg.-Nr. DE 83888045
On Wed, 2014-07-02 at 17:53 +0200, Stefan Klug wrote:
>>
>>> Implementation details:
>>> The patch only touches drivers/usb/core/devio.c.
>>> In procy_do_submiturb(), it is checked if zerocopy is allowed. This is
>>> currently a rough
>>> check which compares the number of required pages to
>>> ps->dev->bus->sg_tablesize.
>> It seems to me that the check is per call, so using
>> multiple calls one could still pin unlimited amounts
>> of memory.
> usbfs keeps track of the total amount of pinned memory and enforces an
> overall limit. It will be necessary to add the size of the transfer
> buffer to that total.
Leaving the zerocopy transfers out of this limit was intentional. I
thought this is user-memory so we shouldn't add it to the overall limit
as it is not allocated by usbfs.
But I didn't think of the pinning problem. So yes, I can add it to the
overall limit.
>>> I don't know if there is more to check there.
>>> Then the user memory provided inside the usbdevfs_urb structure is
>>> pinned to
>>> physical memory using get_user_pages_fast().
>>> All the user pages are added to the scatter-gather list and the logic
>>> continues as before.
>> How do you enforce the cache coherency rules?
> There is no way to do this. If the user program accesses memory when
> it shouldn't, the transfer might not work right.
So this one is fine, right?
>> Also you don't have a fall back if get_user_pages_fast()
>> returns less than requested. It seems to me that than you
>> ought to fall back buffered IO.
> Agreed.
Good point. I'll add the fallback to the next iteration.
next prev parent reply other threads:[~2014-07-03 8:22 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-02 15:53 [PATCH][RFC] USB: zerocopy support for usbfs Stefan Klug
2014-07-02 17:55 ` Greg KH
2014-07-03 7:06 ` Stefan Klug
2014-07-02 18:24 ` Alan Stern
2014-07-02 18:49 ` Peter Stuge
2014-07-02 19:31 ` Alan Stern
2014-07-02 19:42 ` Peter Stuge
2014-07-02 20:40 ` Alan Stern
2014-07-03 7:48 ` Stefan Klug
2014-07-03 8:40 ` David Laight
2014-07-03 14:15 ` Alan Stern
2014-07-02 18:58 ` Oliver Neukum
2014-07-02 19:38 ` Alan Stern
2014-07-03 8:22 ` Stefan Klug [this message]
2014-07-04 8:55 ` Oliver Neukum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53B512AE.2040802@baslerweb.com \
--to=stefan.klug@baslerweb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).