I've been thinking about the way we allocate URBs and other data
structures.

Occasionally (over the last indeterminate time period), I've seen bugs crop
up which are basically caused by problematic memory allocations.  This
tends to bite usb-storage more than anyone else because usb-storage is tied
to the block subsystem, which is (in turn) tied into memory management.

The 'fix' for this seems to have been to pass "allocation flags"
everywhere.  GFP_NOIO and it's cousins help us out here.  In fact, GFP_NOIO
is _all_over_the_place_, and that's a bad sign to me.

But, it occurs to me, that perhaps this isn't the right solution.  I mean,
the entire concept of even trying to make an allocation in usb_sg_init(),
which (in turn) happens when we may be under some memory pressure, seems
like a bad idea (regardless of what GFP_* we use).

So, why not make some allocations earlier?  If I allocate enough URBs for a
sg-list of such-and-such size, then tell the SCSI layer that my maximum
sg-list length is such-and-such size, then I should be able to avoid that
allocation.  Pre-allocating URBs at device init time (before it's attached
to the SCSI subsystem) doens't bother me (much).

Sounds good, yes?  But (and here's the kicker) what about things like the
HCDs?

I'm no HCD expert, but it looks to me (doing a quick browse through the
code) like there might be a few places in the core or the HCDs which
allocate memory once they receive the URB to process.  That blows the
entire point of this exercise out of the water.  Unless....

The only idea I had was to force URBs to be allocated in a manner such that
they are associated with a device (and thus, by implication, with a
particular controller and it's DMA pool).  Then, we can make any
allocations that the core or HCD might need at that time.

This would complicate URB management for higher-level drivers.  But really,
what driver right now has a pool of URBs which are shared among multiple
devices?  I just don't see this as a large hurdle....

Comments?

Matt

-- 
Matthew Dharm                              Home: [EMAIL PROTECTED] 
Maintainer, Linux USB Mass Storage Driver

What, are you one of those Microsoft-bashing Linux freaks?
                                        -- Customer to Greg
User Friendly, 2/10/1999

Attachment: pgpf9McsH5WEM.pgp
Description: PGP signature

Reply via email to