This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] powerpc: New feature - HWCAP/HWCAP2 bits in the TCB
- From: Rich Felker <dalias at libc dot org>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: munroesj at linux dot vnet dot ibm dot com, OndÅej BÃlka <neleai at seznam dot cz>, Szabolcs Nagy <szabolcs dot nagy at arm dot com>, Carlos Eduardo Seo <cseo at linux dot vnet dot ibm dot com>, GLIBC Devel <libc-alpha at sourceware dot org>, Steve Munroe <sjmunroe at us dot ibm dot com>
- Date: Wed, 10 Jun 2015 11:32:41 -0400
- Subject: Re: [PATCH] powerpc: New feature - HWCAP/HWCAP2 bits in the TCB
- Authentication-results: sourceware.org; auth=none
- References: <55760314 dot 6070601 at linux dot vnet dot ibm dot com> <5576FC80 dot 1090806 at arm dot com> <1433862393 dot 21101 dot 9 dot camel at sjmunroe-ThinkPad-W500> <20150609154223 dot GA20028 at domone> <1433865684 dot 21101 dot 20 dot camel at sjmunroe-ThinkPad-W500> <55772EB2 dot 5080103 at redhat dot com> <20150609182636 dot GM17573 at brightrain dot aerifal dot cx> <5578032F dot 4040905 at redhat dot com>
On Wed, Jun 10, 2015 at 11:28:15AM +0200, Florian Weimer wrote:
> On 06/09/2015 08:26 PM, Rich Felker wrote:
> > On Tue, Jun 09, 2015 at 08:21:38PM +0200, Florian Weimer wrote:
> >> On 06/09/2015 06:01 PM, Steven Munroe wrote:
> >>
> >>> A Static variable would require a an indirect load via the TOC/GOT
> >>> (which can be megabytes for a large program/library). I really really
> >>> want the avoid that.
> >>
> >> Could you encode the information in the address itself? Then the
> >> indirection goes away.
> >
> > You mean using (unsigned long)&__hwcap_hack or similar as the hwcap
> > bits?
>
> Exactly.
>
> > I don't see how you could make that work for static linking,
> > where the linker is going to put the GOT in the read-only text
> > segment.
>
> Oh. Is this optimization relevant to statically-linked binaries?
Global data access is mildly expensive even in static binaries for
PPC, I think, because there are no 32-bit immediates. Maybe it could
use two 16-bit immediates and bypass the GOT but I'm not sure if it
does this. I suspect there are a lot of codegen improvements like this
that could be made on MIPS-like RISC targets with poor support for
immediates and data addressing which would be A LOT more worthwhile
than just hacking a few arbitrarily-privileged pieces of data into the
TCB...
> I suppose the static linking case could be addressed with a new
> relocation for the static linker, as long as it is possible to reach a
> writable page from the GOT base using an offset determined at linked
> time. Whether all this is worth the effort, I do not know. The entire
> mechanism might turn out generally useful for mostly-read global
> variables without strong consistency requirements.
In the case of huge programs with lots of GOTs that access hwcap from
lots of places, I think you'd have to make lots of pages writable.
In the case of programs that just access hwcap from some cold-path
init code, this whole discussion is pointless.
Rich