Re: [PATCH 2/6] FRV: Fix FRV arch compile errors [try #3]
From: David Howells
Date: Thu Jul 06 2006 - 14:23:36 EST
Andrew Morton <akpm@xxxxxxxx> wrote:
> - The __init-style tags on declarations don't actually do anything and
> the compiler doesn't check for consistency with the definition - it's
> best to just omit it from the declaration.
Well, you're wrong. They *do* do something. They stop the compiler using the
register-relative addressing reserved for small data. If this isn't in there,
then the linker will spit out a relocation error.
On fixed-size instruction architectures, it takes several instructions to
dereference an absolute address, so you try and squeeze all your small data
into a section of its own, plonk a register in the middle of it, and use
indirect-addressing relative to that register. This saves you two or more
instructions and a register on each normal global variable access.
For instance, on FRV, it may change:
sethi.p %hi(nr_kernel_pages),gr4
setlo %lo(nr_kernel_pages),gr4
ld @(gr4,gr0),gr5
Into:
ld @(gr16,%gprel(nr_kernel_pages)),gr5
Small data is 1-byte, 2-byte, 4-byte or 8-byte values that aren't arrays or
const.
Setting a section marker on the variable *declaration* disables the
gp-relative addressing and forces the longer absolute addressing.
> - Setting nr_kernel_pages to be unloaded at free_initmem() seems risky.
That's nothing to do with my patch.
> - nr_kernel_pages is actually __meminitdata.
Okay, I'll fix my patch to be that instead.
David
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/