[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <op.u9mjqvz87p4s8u@pikus>
Date: Mon, 15 Mar 2010 20:43:33 +0100
From: Michał Nazarewicz <m.nazarewicz@...sung.com>
To: me@...ipebalbi.com
Cc: linux-usb@...r.kernel.org,
David Brownell <dbrownell@...rs.sourceforge.net>,
gregkh@...e.de, linux-kernel@...r.kernel.org,
Marek Szyprowski <m.szyprowski@...sung.com>,
Kyungmin Park <kyungmin.park@...sung.com>
Subject: Re: [PATCH] USB: f_mass_storage: dynamic buffers for better alignment
> On Mon, Mar 15, 2010 at 08:20:08PM +0100, Micha?? Nazarewicz wrote:
>> Each buffer is 4 pages and there are two such buffers in struct
>> fsg_common therefore the size of the structure is 9 pages.
>>
>> I've been simply concerned about using kamlloc() for such big
>> structures so in the end decided to split it into 3 allocations.
>>
>> Maybe I'm overeating though? Or maybe vmalloc() would solve those
>> problems? But then again, vmalloc() could degrade DMA performance
>> on systems w/o scatter-gather.
On Mon, 15 Mar 2010 20:28:13 +0100, Felipe Balbi <me@...ipebalbi.com> wrote:
> I have no opinion anymore :-p
>
> I can only think about the devices I've been working on which would be a
> pain to allocate so much memory and would suffer if you use vmalloc()
> too, so both would be a no-no for me :-p
So here it is... I think allocating buffers dynamically via kmalloc()
is the safest way. :)
>> bh = common->buffhds;
>> rc = -ENOMEM;
>> i = FSG_NUM_BUFFERS;
>> for(;;) {
>> bh->buf = kmalloc(FSG_BUFLEN, GFP_KERNEL);
>> if (unlikely(!bh->buf))
>> goto error_release;
>> if (!--i)
>> break;
>> bh->next = bh + 1;
>> ++bh;
>> }
>> bh->next = common->buffhds;
> how about ?
>
> for (i = FSG_NUM_BUFFER; i; i--, ++bh) {
> bh->buf = kmalloc(FSG_BUFLEN, GFP_KERNEL);
> if (!bh->buf)
> goto error_release;
> }
bh->next cyclic buffer needs to be initialised. Otherwise I'd stick
with what you've posted.
--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michał "mina86" Nazarewicz (o o)
ooo +---[mina86@...a86.com]---[mina86@...ber.org]---ooO--(_)--Ooo--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists