This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Remove unnecessary IFUNC dispatch for __memset_chk.
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: Zack Weinberg <zackw at panix dot com>, "H.J. Lu" <hjl dot tools at gmail dot com>, Andreas Schwab <schwab at linux-m68k dot org>, GNU C Library <libc-alpha at sourceware dot org>
- Date: Mon, 10 Aug 2015 23:12:00 +0200
- Subject: Re: [PATCH] Remove unnecessary IFUNC dispatch for __memset_chk.
- Authentication-results: sourceware.org; auth=none
- References: <20150809013434 dot 0B16814B9A at panix1 dot panix dot com> <m28u9lotfk dot fsf at linux-m68k dot org> <55C76FCD dot 5020607 at panix dot com> <CAMe9rOoAWjRma_mG_FazVh3FGOyiGJ=g82=bsfGqa-COnt5p1g at mail dot gmail dot com> <55C78525 dot 40402 at panix dot com> <CAMe9rOrKg8nzB67+OCXz5n1u7ZLnJncpX7J6KkEXqe0Bra843w at mail dot gmail dot com> <55C79AD8 dot 3070301 at panix dot com> <20150810030920 dot GE23550 at vapier>
On Sun, Aug 09, 2015 at 11:09:20PM -0400, Mike Frysinger wrote:
> On 09 Aug 2015 14:24, Zack Weinberg wrote:
> > Is an IFUNC's variant-selecting function called only once per process,
> > or every time?
>
> it's once-per-process. if it were every time, it'd defeat the point of the
> optimization.
>
No, its once per each shared library.
> > If we sent libc.so-internal calls to 'memset' through the PLT (as is
> > currently done for 'malloc') would that mean they were subject to IFUNC
> > dispatch?
>
> it's a double edge sword. we specifically want to avoid the PLT for two
> reasons:
> (1) speed (PLT is slow)
> (2) interposition (we don't want someone exporting a memset symbol and then
> internal glibc code calling that instead of our own version)
>
No, as I wrote in
[PATCH] x86-64: Remove plt bypassing of ifuncs.
thats completely flawed analysis. In best case you could save few
cycles. As I looked on functions you would for most functions lose
at leat twenty cycles as differences between implementations are that
big.
But even best case is mistake. You completely forgotten cache effects
and for memset you maybe save few cycles but add kilobyte to instruction
cache footprint that causes more significant slowdown.
> > Is there any *other* way (that already exists - nothing that would
> > require binutils changes) to cause libc.so-internal calls to 'memset' to
> > be subject to IFUNC dispatch? Compared to using the PLT, what are the
> > costs and benefits of doing it that way?
>
> since IFUNC only exists to handle the PLT slot, doing IFUNC w/out PLT
> fundamentally doesn't make sense.