[OpenBIOS] [PATCH] Enforce physical alignment based upon size for the SPARC32 romvec obp_dumb_memalloc() function.
Mark Cave-Ayland
mark.cave-ayland at siriusit.co.uk
Wed Apr 6 22:48:18 CEST 2011
On 05/04/11 19:13, Blue Swirl wrote:
>> + /* Enforce a minimum alignment of CONFIG_OFMEM_MALLOC_ALIGN, and choose an alignment
>> + which is the next power of 2 higher than the specified size */
>> + align = size;
>> + if (align< CONFIG_OFMEM_MALLOC_ALIGN) {
>
> Since size or alignment of CONFIG_OFMEM_MALLOC_ALIGN (4 or 8) may be
> common, I'd change '<' to'<=' to avoid the loop.
Okay - although to be honest, most allocations seem to be a multiple of
PAGE_SIZE from what I can see so I don't think that would make much
difference? I've no objection to this though.
>> + align = CONFIG_OFMEM_MALLOC_ALIGN;
>> + } else {
>> + align--;
>> + for (i = 1; i< sizeof(unsigned int) * 8; i<<=1) {
>
> This should probably be sizeof(unsigned long) instead, so>4GB sizes
> on 64 bit targets are properly aligned ;-).
Okay ;)
> align |= align>> i?
Done. Thinking about this patch more, it could be that I am
over-engineering a simple problem. Maybe the romvec interface simply
insists that all allocations are aligned to an 8K boundary which would
fix the Solaris IOMMU problem, but also results in much less efficient
memory use? I think this is a reasonable starting point though.
ATB,
Mark.
--
Mark Cave-Ayland - Senior Technical Architect
PostgreSQL - PostGIS
Sirius Corporation plc - control through freedom
http://www.siriusit.co.uk
t: +44 870 608 0063
Sirius Labs: http://www.siriusit.co.uk/labs
More information about the OpenBIOS
mailing list