This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: HWCAP is method to determine cpu features, not selection mechanism.
- From: Steven Munroe <munroesj at linux dot vnet dot ibm dot com>
- To: OndÅej BÃlka <neleai at seznam dot cz>
- Cc: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>, Szabolcs Nagy <szabolcs dot nagy at arm dot com>, "libc-alpha at sourceware dot org" <libc-alpha at sourceware dot org>
- Date: Wed, 10 Jun 2015 13:58:27 -0500
- Subject: Re: HWCAP is method to determine cpu features, not selection mechanism.
- Authentication-results: sourceware.org; auth=none
- References: <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> <20150610125047 dot GA10861 at domone> <55783D2A dot 8050703 at linaro dot org> <557846D9 dot 3060909 at arm dot com> <55784802 dot 8070605 at linaro dot org> <20150610150944 dot GA11504 at domone> <5578567C dot 5020504 at linaro dot org> <20150610155354 dot GA12820 at domone>
- Reply-to: munroesj at linux dot vnet dot ibm dot com
On Wed, 2015-06-10 at 17:53 +0200, OndÅej BÃlka wrote:
> On Wed, Jun 10, 2015 at 12:23:40PM -0300, Adhemerval Zanella wrote:
> >
> >
> > On 10-06-2015 12:09, OndÅej BÃlka wrote:
> > > On Wed, Jun 10, 2015 at 11:21:54AM -0300, Adhemerval Zanella wrote:
> > >>
> > >>
> > >> On 10-06-2015 11:16, Szabolcs Nagy wrote:
> > >>> On 10/06/15 14:35, Adhemerval Zanella wrote:
> > >>>> I agree that adding an API to modify the current hwcap is not a good
> > >>>> approach. However the cost you are assuming here are *very* x86 biased,
> > >>>> where you have only on instruction (movl <variable>(%rip), %<destiny>)
> > >>>> to load an external variable defined in a shared library, where for
> > >>>> powerpc it is more costly:
> > >>>
> > >>> debian codesearch found 4 references to __builtin_cpu_supports
> > >>> all seem to avoid using it repeatedly.
> > >>>
> > >>> multiversioning dispatch only happens at startup (for a small
> > >>> number of functions according to existing practice).
> > >>>
> > >>> so why is hwcap expected to be used in hot loops?
> > >>>
> > >>
> snip
> > And my understanding is to optimize hwcap access to provide a 'better' way
> > to enable '__builtin_cpu_supports' for powerpc. IFUNC is another way to provide
> > function selection, but it does not exclude that accessing hwcap through
> > TLS is *faster* than current options. It is up to developer to decide to use
> > either IFUNC or __builtin_cpu_supports. If the developer will use it in
> > hot loops or not, it is up to them to profile and use another way.
> >
> > You can say the same about current x86 __builtin_cpu_supports support: you should
> > not use in loops, you should use ifunc, whatever.
>
> Sorry but no again. We are talking here on difference between variable
> access and tcb access. You forgot to count total cost. That includes
> initialization overhead per thread to initialize hwcap, increased
> per-thread memory usage, maintainance burden and increased cache misses.
> If you access hwcap only rarely as you should then per-thread copies
> would introduce cache miss that is more costy than GOT overhead. In GOT
> case it could be avoided as combined threads would access it more often.
>
Actually Adhemerval does have the knowledge, background, and experience
to understand this difference and accurately access the trade-offs.
> So if your multithreaded application access hwcap maybe 10 times per run
> you would likely harm performance.
>
Sorry this is not an accurate assessment as the proposed fields are in
the same cache line as other more frequently accessed fields of the TCB.
The proposal will not effectively increase the cache foot-print.
> I could from my head tell ten functions that with tcb entry lead to much
> bigger performance gains. So if this is applicable I will submit strspn
> improvement that keeps 32 bitmask and checks if second argument didn't
> changed. That would be better usage of tls than keeping hwcap data.
>
If you are suggestion saving results across strspn calls then a normal
TLS variable would be an appropriate choice.
This proposal covers a different situation.
/soap box
While I am no expert in all things and try not to comment on things
which I really don't have the expertise (especially other platforms), I
do know a lot about the POWER platform.
I am responsible for the overall delivery of the open source toolchain
for Linux on Power. GLIBC is just one component of many that needs to be
coordinated for delivery. I also get involved directly with Linux
customers and try to respond to issues they identify. As such I am in a
good position to see how all the pieces (hardware, software, ABIs, ...)
fit together and where they can be made better.
With this larger responsibility, I don't have much time to quibble over
the fine point of esoteric design. So I tend to short cut to conclusions
and support my team.
If you do catch me pontificating on some other platform, without basis
in fact, please feel free to call me out.
But lots people seem to want to provide their opinion based on their
experience with other platforms and point out where I might have
strayed. Fine, but I can and do try to point out that their argument
does not apply (to my platform).
But recent comments and responses have gone past the normal give and
take of a healthy community, and into accusations and attacks.
That is going too far should not be tolerated.
\soap box