All of lore.kernel.org
 help / color / mirror / Atom feed
* Function pointer alignment
@ 2017-12-22  3:55 Matthew Wilcox
  2017-12-22 12:28   ` Geert Uytterhoeven
  0 siblings, 1 reply; 8+ messages in thread
From: Matthew Wilcox @ 2017-12-22  3:55 UTC (permalink / raw)
  To: linux-arch


What alignment can we rely on for function pointers?

Most architectures seem to have settled on 4-byte aligned instructions.

While x86 is only byte-aligned, at least x86-64 aligns functions on a
16-byte boundary.  I know s390 has 2-byte alignment on instructions,
but does it have greater alignment on functions?

The three architectures with function descriptors (parisc, ia64, ppc64)
all seem like they'll be 8-byte aligned.

(I'm looking to steal the bottom two bits of a function pointer, so
that's where my interest comes from).

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Function pointer alignment
@ 2017-12-22 12:28   ` Geert Uytterhoeven
  0 siblings, 0 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2017-12-22 12:28 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: Linux-Arch

Hi Willy,

On Fri, Dec 22, 2017 at 4:55 AM, Matthew Wilcox <willy@infradead.org> wrote:
> What alignment can we rely on for function pointers?
>
> Most architectures seem to have settled on 4-byte aligned instructions.
>
> While x86 is only byte-aligned, at least x86-64 aligns functions on a
> 16-byte boundary.  I know s390 has 2-byte alignment on instructions,
> but does it have greater alignment on functions?
>
> The three architectures with function descriptors (parisc, ia64, ppc64)
> all seem like they'll be 8-byte aligned.
>
> (I'm looking to steal the bottom two bits of a function pointer, so
> that's where my interest comes from).

Only one bit to steal on m68k...

Gr{oetje,eeting}s,

                        Geert

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Function pointer alignment
@ 2017-12-22 12:28   ` Geert Uytterhoeven
  0 siblings, 0 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2017-12-22 12:28 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: Linux-Arch

Hi Willy,

On Fri, Dec 22, 2017 at 4:55 AM, Matthew Wilcox <willy@infradead.org> wrote:
> What alignment can we rely on for function pointers?
>
> Most architectures seem to have settled on 4-byte aligned instructions.
>
> While x86 is only byte-aligned, at least x86-64 aligns functions on a
> 16-byte boundary.  I know s390 has 2-byte alignment on instructions,
> but does it have greater alignment on functions?
>
> The three architectures with function descriptors (parisc, ia64, ppc64)
> all seem like they'll be 8-byte aligned.
>
> (I'm looking to steal the bottom two bits of a function pointer, so
> that's where my interest comes from).

Only one bit to steal on m68k...

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Function pointer alignment
@ 2017-12-22 12:30     ` Geert Uytterhoeven
  0 siblings, 0 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2017-12-22 12:30 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: Linux-Arch

On Fri, Dec 22, 2017 at 1:28 PM, Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> On Fri, Dec 22, 2017 at 4:55 AM, Matthew Wilcox <willy@infradead.org> wrote:
>> What alignment can we rely on for function pointers?
>>
>> Most architectures seem to have settled on 4-byte aligned instructions.
>>
>> While x86 is only byte-aligned, at least x86-64 aligns functions on a
>> 16-byte boundary.  I know s390 has 2-byte alignment on instructions,
>> but does it have greater alignment on functions?
>>
>> The three architectures with function descriptors (parisc, ia64, ppc64)
>> all seem like they'll be 8-byte aligned.
>>
>> (I'm looking to steal the bottom two bits of a function pointer, so
>> that's where my interest comes from).
>
> Only one bit to steal on m68k...

Same on SH.

Gr{oetje,eeting}s,

                        Geert

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Function pointer alignment
@ 2017-12-22 12:30     ` Geert Uytterhoeven
  0 siblings, 0 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2017-12-22 12:30 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: Linux-Arch

On Fri, Dec 22, 2017 at 1:28 PM, Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> On Fri, Dec 22, 2017 at 4:55 AM, Matthew Wilcox <willy@infradead.org> wrote:
>> What alignment can we rely on for function pointers?
>>
>> Most architectures seem to have settled on 4-byte aligned instructions.
>>
>> While x86 is only byte-aligned, at least x86-64 aligns functions on a
>> 16-byte boundary.  I know s390 has 2-byte alignment on instructions,
>> but does it have greater alignment on functions?
>>
>> The three architectures with function descriptors (parisc, ia64, ppc64)
>> all seem like they'll be 8-byte aligned.
>>
>> (I'm looking to steal the bottom two bits of a function pointer, so
>> that's where my interest comes from).
>
> Only one bit to steal on m68k...

Same on SH.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Function pointer alignment
  2017-12-22 12:30     ` Geert Uytterhoeven
  (?)
@ 2017-12-22 13:09     ` Matthew Wilcox
  2017-12-22 13:58         ` Geert Uytterhoeven
  -1 siblings, 1 reply; 8+ messages in thread
From: Matthew Wilcox @ 2017-12-22 13:09 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Linux-Arch

On Fri, Dec 22, 2017 at 01:30:51PM +0100, Geert Uytterhoeven wrote:
> On Fri, Dec 22, 2017 at 1:28 PM, Geert Uytterhoeven
> <geert@linux-m68k.org> wrote:
> > On Fri, Dec 22, 2017 at 4:55 AM, Matthew Wilcox <willy@infradead.org> wrote:
> >> What alignment can we rely on for function pointers?
> >
> > Only one bit to steal on m68k...
> 
> Same on SH.

How much damage would we do by adding -falign-functions=4 to CFLAGS
on m68k?  Can you measure that for me?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Function pointer alignment
@ 2017-12-22 13:58         ` Geert Uytterhoeven
  0 siblings, 0 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2017-12-22 13:58 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: Linux-Arch

Hi Willy,

On Fri, Dec 22, 2017 at 2:09 PM, Matthew Wilcox <willy@infradead.org> wrote:
> On Fri, Dec 22, 2017 at 01:30:51PM +0100, Geert Uytterhoeven wrote:
>> On Fri, Dec 22, 2017 at 1:28 PM, Geert Uytterhoeven
>> <geert@linux-m68k.org> wrote:
>> > On Fri, Dec 22, 2017 at 4:55 AM, Matthew Wilcox <willy@infradead.org> wrote:
>> >> What alignment can we rely on for function pointers?
>> >
>> > Only one bit to steal on m68k...
>>
>> Same on SH.
>
> How much damage would we do by adding -falign-functions=4 to CFLAGS
> on m68k?  Can you measure that for me?

With defconfig (aka multi_defconfig) and gcc 4.1.2:

   text    data     bss     dec     hex filename
3594487 959460 186492 4740439 485557 vmlinux.old
3611159 959484 185724 4756367 48938f vmlinux

text +16672
data +24
bss -768 (why?)
total +15928

Given kernel size increased on average almost 50 KiB between
v4.x and v4.(x+1), the damage wouldn't be that bad ;-)

Note that this aligned C functions only.  Assembler code (incl. the '040 and
'060 integer/floating point support packages) still has to be fixed.

Gr{oetje,eeting}s,

                        Geert

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Function pointer alignment
@ 2017-12-22 13:58         ` Geert Uytterhoeven
  0 siblings, 0 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2017-12-22 13:58 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: Linux-Arch

Hi Willy,

On Fri, Dec 22, 2017 at 2:09 PM, Matthew Wilcox <willy@infradead.org> wrote:
> On Fri, Dec 22, 2017 at 01:30:51PM +0100, Geert Uytterhoeven wrote:
>> On Fri, Dec 22, 2017 at 1:28 PM, Geert Uytterhoeven
>> <geert@linux-m68k.org> wrote:
>> > On Fri, Dec 22, 2017 at 4:55 AM, Matthew Wilcox <willy@infradead.org> wrote:
>> >> What alignment can we rely on for function pointers?
>> >
>> > Only one bit to steal on m68k...
>>
>> Same on SH.
>
> How much damage would we do by adding -falign-functions=4 to CFLAGS
> on m68k?  Can you measure that for me?

With defconfig (aka multi_defconfig) and gcc 4.1.2:

   text    data     bss     dec     hex filename
3594487 959460 186492 4740439 485557 vmlinux.old
3611159 959484 185724 4756367 48938f vmlinux

text +16672
data +24
bss -768 (why?)
total +15928

Given kernel size increased on average almost 50 KiB between
v4.x and v4.(x+1), the damage wouldn't be that bad ;-)

Note that this aligned C functions only.  Assembler code (incl. the '040 and
'060 integer/floating point support packages) still has to be fixed.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-12-22 13:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-22  3:55 Function pointer alignment Matthew Wilcox
2017-12-22 12:28 ` Geert Uytterhoeven
2017-12-22 12:28   ` Geert Uytterhoeven
2017-12-22 12:30   ` Geert Uytterhoeven
2017-12-22 12:30     ` Geert Uytterhoeven
2017-12-22 13:09     ` Matthew Wilcox
2017-12-22 13:58       ` Geert Uytterhoeven
2017-12-22 13:58         ` Geert Uytterhoeven

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.