* [PATCH v3] usb: gadget: storage_common: make FSG_NUM_BUFFERS variable size
@ 2011-08-08 21:43 Per Forlin
2011-08-09 13:57 ` Alan Stern
2011-08-12 9:20 ` Felipe Balbi
0 siblings, 2 replies; 6+ messages in thread
From: Per Forlin @ 2011-08-08 21:43 UTC (permalink / raw)
To: Felipe Balbi, Greg Kroah-Hartman, linux-usb, linux-kernel,
linaro-dev, Michal Nazarewicz, Alan Stern
Cc: Per Forlin
FSG_NUM_BUFFERS is set to 2 as default.
Usually 2 buffers are enough to establish a good buffering pipeline.
The number may be increased in order to compensate a for bursty VFS
behaviour.
Here follows a description of system that may require more than
2 buffers.
* CPU ondemand governor active
* latency cost for wake up and/or frequency change
* DMA for IO
Use case description.
* Data transfer from MMC via VFS to USB.
* DMA shuffles data from MMC and to USB.
* The CPU wakes up every now and then to pass data in and out from VFS,
which cause the bursty VFS behaviour.
Test set up
* Running dd on the host reading from the mass storage device
* cmdline: dd if=/dev/sdb of=/dev/null bs=4k count=$((256*100))
* Caches are dropped on the host and on the device before each run
Measurements on a Snowball board with ondemand_govenor active.
FSG_NUM_BUFFERS 2
104857600 bytes (105 MB) copied, 5.62173 s, 18.7 MB/s
104857600 bytes (105 MB) copied, 5.61811 s, 18.7 MB/s
104857600 bytes (105 MB) copied, 5.57817 s, 18.8 MB/s
FSG_NUM_BUFFERS 4
104857600 bytes (105 MB) copied, 5.26839 s, 19.9 MB/s
104857600 bytes (105 MB) copied, 5.2691 s, 19.9 MB/s
104857600 bytes (105 MB) copied, 5.2711 s, 19.9 MB/s
There may not be one optimal number for all boards. This is why
the number is added to Kconfig.
Signed-off-by: Per Forlin <per.forlin@linaro.org>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
---
Change log.
v2: Update after proofreading comments from Michal Nazarewicz
v3: Clarify the description of this patch based on input from Alan Stern
drivers/usb/gadget/Kconfig | 14 ++++++++++++++
drivers/usb/gadget/storage_common.c | 7 +++++--
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 029e288..24d3ef5 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -96,6 +96,20 @@ config USB_GADGET_VBUS_DRAW
This value will be used except for system-specific gadget
drivers that have more specific information.
+config USB_GADGET_STORAGE_NUM_BUFFERS
+ int "Number of storage pipeline buffers"
+ range 2 4
+ default 2
+ help
+ Usually 2 buffers are enough to establish a good buffering
+ pipeline. The number may be increased in order to compensate
+ for a bursty VFS behaviour. For instance there may be cpu wake up
+ latencies that makes the VFS to appear bursty in a system with
+ an cpu on-demand governor. Especially if DMA is doing IO to
+ offload the CPU. In this case the CPU will go into power
+ save often and spin up occasionally to move data within VFS.
+ If unsure, say 2.
+
config USB_GADGET_SELECTED
boolean
diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c
index 1fa4f70..683c972 100644
--- a/drivers/usb/gadget/storage_common.c
+++ b/drivers/usb/gadget/storage_common.c
@@ -262,8 +262,11 @@ static struct fsg_lun *fsg_lun_from_dev(struct device *dev)
#define EP0_BUFSIZE 256
#define DELAYED_STATUS (EP0_BUFSIZE + 999) /* An impossibly large value */
-/* Number of buffers we will use. 2 is enough for double-buffering */
-#define FSG_NUM_BUFFERS 2
+/*
+ * Number of buffers we will use.
+ * 2 is usually enough for good buffering pipeline
+ */
+#define FSG_NUM_BUFFERS CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS
/* Default size of buffer length. */
#define FSG_BUFLEN ((u32)16384)
--
1.7.4.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] usb: gadget: storage_common: make FSG_NUM_BUFFERS variable size
2011-08-08 21:43 [PATCH v3] usb: gadget: storage_common: make FSG_NUM_BUFFERS variable size Per Forlin
@ 2011-08-09 13:57 ` Alan Stern
2011-08-09 14:51 ` Felipe Balbi
2011-08-12 9:20 ` Felipe Balbi
1 sibling, 1 reply; 6+ messages in thread
From: Alan Stern @ 2011-08-09 13:57 UTC (permalink / raw)
To: Per Forlin
Cc: Felipe Balbi, Greg Kroah-Hartman, linux-usb, linux-kernel,
linaro-dev, Michal Nazarewicz
On Mon, 8 Aug 2011, Per Forlin wrote:
> FSG_NUM_BUFFERS is set to 2 as default.
> Usually 2 buffers are enough to establish a good buffering pipeline.
> The number may be increased in order to compensate a for bursty VFS
> behaviour.
>
> Here follows a description of system that may require more than
> 2 buffers.
> * CPU ondemand governor active
> * latency cost for wake up and/or frequency change
> * DMA for IO
>
> Use case description.
> * Data transfer from MMC via VFS to USB.
> * DMA shuffles data from MMC and to USB.
> * The CPU wakes up every now and then to pass data in and out from VFS,
> which cause the bursty VFS behaviour.
>
> Test set up
> * Running dd on the host reading from the mass storage device
> * cmdline: dd if=/dev/sdb of=/dev/null bs=4k count=$((256*100))
> * Caches are dropped on the host and on the device before each run
>
> Measurements on a Snowball board with ondemand_govenor active.
>
> FSG_NUM_BUFFERS 2
> 104857600 bytes (105 MB) copied, 5.62173 s, 18.7 MB/s
> 104857600 bytes (105 MB) copied, 5.61811 s, 18.7 MB/s
> 104857600 bytes (105 MB) copied, 5.57817 s, 18.8 MB/s
>
> FSG_NUM_BUFFERS 4
> 104857600 bytes (105 MB) copied, 5.26839 s, 19.9 MB/s
> 104857600 bytes (105 MB) copied, 5.2691 s, 19.9 MB/s
> 104857600 bytes (105 MB) copied, 5.2711 s, 19.9 MB/s
>
> There may not be one optimal number for all boards. This is why
> the number is added to Kconfig.
>
> Signed-off-by: Per Forlin <per.forlin@linaro.org>
> Acked-by: Michal Nazarewicz <mina86@mina86.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] usb: gadget: storage_common: make FSG_NUM_BUFFERS variable size
2011-08-09 13:57 ` Alan Stern
@ 2011-08-09 14:51 ` Felipe Balbi
0 siblings, 0 replies; 6+ messages in thread
From: Felipe Balbi @ 2011-08-09 14:51 UTC (permalink / raw)
To: Alan Stern
Cc: Per Forlin, Felipe Balbi, Greg Kroah-Hartman, linux-usb,
linux-kernel, linaro-dev, Michal Nazarewicz
[-- Attachment #1: Type: text/plain, Size: 2000 bytes --]
Hi,
On Tue, Aug 09, 2011 at 09:57:19AM -0400, Alan Stern wrote:
> On Mon, 8 Aug 2011, Per Forlin wrote:
>
> > FSG_NUM_BUFFERS is set to 2 as default.
> > Usually 2 buffers are enough to establish a good buffering pipeline.
> > The number may be increased in order to compensate a for bursty VFS
> > behaviour.
> >
> > Here follows a description of system that may require more than
> > 2 buffers.
> > * CPU ondemand governor active
> > * latency cost for wake up and/or frequency change
> > * DMA for IO
> >
> > Use case description.
> > * Data transfer from MMC via VFS to USB.
> > * DMA shuffles data from MMC and to USB.
> > * The CPU wakes up every now and then to pass data in and out from VFS,
> > which cause the bursty VFS behaviour.
> >
> > Test set up
> > * Running dd on the host reading from the mass storage device
> > * cmdline: dd if=/dev/sdb of=/dev/null bs=4k count=$((256*100))
> > * Caches are dropped on the host and on the device before each run
> >
> > Measurements on a Snowball board with ondemand_govenor active.
> >
> > FSG_NUM_BUFFERS 2
> > 104857600 bytes (105 MB) copied, 5.62173 s, 18.7 MB/s
> > 104857600 bytes (105 MB) copied, 5.61811 s, 18.7 MB/s
> > 104857600 bytes (105 MB) copied, 5.57817 s, 18.8 MB/s
> >
> > FSG_NUM_BUFFERS 4
> > 104857600 bytes (105 MB) copied, 5.26839 s, 19.9 MB/s
> > 104857600 bytes (105 MB) copied, 5.2691 s, 19.9 MB/s
> > 104857600 bytes (105 MB) copied, 5.2711 s, 19.9 MB/s
> >
> > There may not be one optimal number for all boards. This is why
> > the number is added to Kconfig.
> >
> > Signed-off-by: Per Forlin <per.forlin@linaro.org>
> > Acked-by: Michal Nazarewicz <mina86@mina86.com>
>
> Acked-by: Alan Stern <stern@rowland.harvard.edu>
Thanks.
Hijacking this thread for a small note. I'll be back on applying patches
this friday. Until then I'll be focussed on some other issues which
we're tracking down.
Thanks for understanding ;-)
--
balbi
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] usb: gadget: storage_common: make FSG_NUM_BUFFERS variable size
2011-08-08 21:43 [PATCH v3] usb: gadget: storage_common: make FSG_NUM_BUFFERS variable size Per Forlin
2011-08-09 13:57 ` Alan Stern
@ 2011-08-12 9:20 ` Felipe Balbi
2011-08-12 15:49 ` Alan Stern
1 sibling, 1 reply; 6+ messages in thread
From: Felipe Balbi @ 2011-08-12 9:20 UTC (permalink / raw)
To: Per Forlin
Cc: Felipe Balbi, Greg Kroah-Hartman, linux-usb, linux-kernel,
linaro-dev, Michal Nazarewicz, Alan Stern
[-- Attachment #1: Type: text/plain, Size: 1790 bytes --]
On Mon, Aug 08, 2011 at 11:43:35PM +0200, Per Forlin wrote:
> FSG_NUM_BUFFERS is set to 2 as default.
> Usually 2 buffers are enough to establish a good buffering pipeline.
> The number may be increased in order to compensate a for bursty VFS
> behaviour.
>
> Here follows a description of system that may require more than
> 2 buffers.
> * CPU ondemand governor active
> * latency cost for wake up and/or frequency change
> * DMA for IO
>
> Use case description.
> * Data transfer from MMC via VFS to USB.
> * DMA shuffles data from MMC and to USB.
> * The CPU wakes up every now and then to pass data in and out from VFS,
> which cause the bursty VFS behaviour.
>
> Test set up
> * Running dd on the host reading from the mass storage device
> * cmdline: dd if=/dev/sdb of=/dev/null bs=4k count=$((256*100))
> * Caches are dropped on the host and on the device before each run
>
> Measurements on a Snowball board with ondemand_govenor active.
>
> FSG_NUM_BUFFERS 2
> 104857600 bytes (105 MB) copied, 5.62173 s, 18.7 MB/s
> 104857600 bytes (105 MB) copied, 5.61811 s, 18.7 MB/s
> 104857600 bytes (105 MB) copied, 5.57817 s, 18.8 MB/s
>
> FSG_NUM_BUFFERS 4
> 104857600 bytes (105 MB) copied, 5.26839 s, 19.9 MB/s
> 104857600 bytes (105 MB) copied, 5.2691 s, 19.9 MB/s
> 104857600 bytes (105 MB) copied, 5.2711 s, 19.9 MB/s
>
> There may not be one optimal number for all boards. This is why
> the number is added to Kconfig.
>
> Signed-off-by: Per Forlin <per.forlin@linaro.org>
> Acked-by: Michal Nazarewicz <mina86@mina86.com>
would it make sense to have this as a module parameter so we don't need
to recompile the driver everytime we want to test the driver with a
different number of buffers ??
Alan ?
--
balbi
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] usb: gadget: storage_common: make FSG_NUM_BUFFERS variable size
2011-08-12 9:20 ` Felipe Balbi
@ 2011-08-12 15:49 ` Alan Stern
2011-08-17 9:50 ` Per Forlin
0 siblings, 1 reply; 6+ messages in thread
From: Alan Stern @ 2011-08-12 15:49 UTC (permalink / raw)
To: Felipe Balbi
Cc: Per Forlin, Greg Kroah-Hartman, linux-usb, linux-kernel,
linaro-dev, Michal Nazarewicz
On Fri, 12 Aug 2011, Felipe Balbi wrote:
> On Mon, Aug 08, 2011 at 11:43:35PM +0200, Per Forlin wrote:
> > FSG_NUM_BUFFERS is set to 2 as default.
> > Usually 2 buffers are enough to establish a good buffering pipeline.
> > The number may be increased in order to compensate a for bursty VFS
> > behaviour.
> would it make sense to have this as a module parameter so we don't need
> to recompile the driver everytime we want to test the driver with a
> different number of buffers ??
>
> Alan ?
People generally object to new module parameters unless there's a very
good reason for them.
Since people won't want to experiment with changing this value unless
they're debugging anyway, we might make it a conditional module
parameter -- don't define the parameter unless CONFIG_USB_DEBUG is
enabled.
Alan Stern
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] usb: gadget: storage_common: make FSG_NUM_BUFFERS variable size
2011-08-12 15:49 ` Alan Stern
@ 2011-08-17 9:50 ` Per Forlin
0 siblings, 0 replies; 6+ messages in thread
From: Per Forlin @ 2011-08-17 9:50 UTC (permalink / raw)
To: Alan Stern
Cc: Felipe Balbi, Greg Kroah-Hartman, linux-usb, linux-kernel,
linaro-dev, Michal Nazarewicz
On 12 August 2011 17:49, Alan Stern <stern@rowland.harvard.edu> wrote:
> On Fri, 12 Aug 2011, Felipe Balbi wrote:
>
>> On Mon, Aug 08, 2011 at 11:43:35PM +0200, Per Forlin wrote:
>> > FSG_NUM_BUFFERS is set to 2 as default.
>> > Usually 2 buffers are enough to establish a good buffering pipeline.
>> > The number may be increased in order to compensate a for bursty VFS
>> > behaviour.
>
>> would it make sense to have this as a module parameter so we don't need
>> to recompile the driver everytime we want to test the driver with a
>> different number of buffers ??
>>
>> Alan ?
>
> People generally object to new module parameters unless there's a very
> good reason for them.
>
> Since people won't want to experiment with changing this value unless
> they're debugging anyway, we might make it a conditional module
> parameter -- don't define the parameter unless CONFIG_USB_DEBUG is
> enabled.
>
I like this proposal. I'll send out a new version of this patch using
module_param instead of kconfig.
Thanks,
Per
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-08-17 9:50 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-08 21:43 [PATCH v3] usb: gadget: storage_common: make FSG_NUM_BUFFERS variable size Per Forlin
2011-08-09 13:57 ` Alan Stern
2011-08-09 14:51 ` Felipe Balbi
2011-08-12 9:20 ` Felipe Balbi
2011-08-12 15:49 ` Alan Stern
2011-08-17 9:50 ` Per Forlin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®