public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dzmitry.konanka at karambasecurity dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug dynamic-link/27944] New: poor TLS performance in shared object after calling dlopen with another shared object that also contains TLS section
Date: Wed, 02 Jun 2021 23:46:04 +0000	[thread overview]
Message-ID: <bug-27944-131@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=27944

            Bug ID: 27944
           Summary: poor TLS performance in shared object after calling
                    dlopen with another shared object that also contains
                    TLS section
           Product: glibc
           Version: 2.28
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: dynamic-link
          Assignee: unassigned at sourceware dot org
          Reporter: dzmitry.konanka at karambasecurity dot com
  Target Milestone: ---

Created attachment 13482
  --> https://sourceware.org/bugzilla/attachment.cgi?id=13482&action=edit
thread local storage benchmark application and suggested glibc patch

Performance of accessing __thread variables is degraded in following scenario:
- __thread variable defined in shared object.
- dlopen invoked to load another shared object that has TLS section.
In this scenario synthetic benchmark application shown more than twice
performance degradation. Futher analyzis with gdb shown that each access to TLS
variable causes _dl_update_slotinfo to be called due to following condition
inside of __tls_get_addr always evaluates as true: if (__glibc_unlikely
(dtv[0].counter != GL(dl_tls_generation))) that doesn't look as designed
behavior.
Problem tested and found on x86-64 and ARM with glibc 2.19, 2.25, 2.27, 2.28
and likely will happen with recent glibc too.
I've made simple workaround that fixes problem, however i'm not sure in its
100% validity since related code is a little bit complicated. But at least it
confirms guessed problem's reason.
Both benchmark app and suggested glibc patch are inside of attached archive.
There you can also find readme.txt with info how to use benchmark.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

             reply	other threads:[~2021-06-02 23:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-02 23:46 dzmitry.konanka at karambasecurity dot com [this message]
2021-06-03  9:20 ` [Bug dynamic-link/27944] " dzmitry.konanka at karambasecurity dot com
2023-01-26  7:07 ` ville.heikkinen at nokia dot com
2024-06-03 15:06 ` fweimer at redhat dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-27944-131@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).