Re:Kernel programming Q: new aligned memory

Inaky Perez Gonzalez (inaky@peloncho.fis.ucm.es)
Sat, 5 Sep 1998 21:10:47 +0200


>>>>> "Gerard" == Gerard Roudier <groudier@club-internet.fr> writes:

Hi

Gerard> Linux-2.0 kernel allocator does not provide such power of 2
Gerard> alignments.

I'm safe from that [excerpt from uusbd/README]

uusbd/README> I'm using 2.1.116 to run this.. 2.0.x won't
uusbd/README> work, nor I intend too, as 2.2 is forthcoming shortly
uusbd/README> (in stereo where available).

I don't plan to support 2.0 in the USB stack. Too much changes
to be aware of and it is still too alpha for ppl to use it ...

However, u r right, most drivers must work :)

Gerard> [ 5 minutes code removed ]

>> The point is, if the size of the object is smaller then the
>> alignment, ask for a chunk sized as the alignment, else the
>> size. The rounding to the next power of two will do the same when
>> allocating.

Gerard> If you want to align a object on a power of 2 greater than the
Gerard> lowest power of 2 greater than the object size, then you just
Gerard> want to waste memory, in my opinion. Do you really need that ?

Yes I do. The UHCI and OHCI USB controllers expect a lot of
its structures to be aligned (most to 16, some at 32, one for OHCI at
256). It's neccessary in order to save a lot of bits in
descriptors. However, it is also doable, as most OSs do power-of-two
allocation. I see sense on it.

>> It's dirty, could be optimized, etc, etc ... but hey, I did it in
>> five minutes :)

Gerard> Most of things we did in five minutes or less generally donnot
Gerard> smell good. :-))

Well, it seems to work, so I won't worry anymore until it
really needs my attention :]. There are funnier things to do!

Cheers

Linux-USB! http://peloncho.fis.ucm.es/~inaky/USB.html -
-
Inaky Perez Gonzalez -- PGP pubkey fingerprint -
inaky@peloncho.fis.ucm.es -- 8E 34 3A 62 64 99 E2 44 -
http://peloncho.fis.ucm.es/~inaky -- AD 7B 30 D9 DD FF 3E 4C -
--------------------------------- -- ----------------------- -
The loneliness of the long distance runner .....

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/faq.html