public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: binutils@sourceware.org
Subject: [PATCH 0/3] Threads and BFD
Date: Thu, 26 Oct 2023 13:07:48 -0600	[thread overview]
Message-ID: <20231026191435.204144-1-tom@tromey.com> (raw)

gdb started using threads a while ago.  So far we've (mostly) avoided
doing anything BFD-related off the main thread, but I would like to
change that.

In particular, I'd like gdb to do most of its DWARF reading in the
background.  To achieve this, gdb only really needs threading on a
per-BFD basis.  That is, all access to any particular BFD will be from
a single thread at a given time.  However, due to DWO, gdb may also
need to create a new BFD from a worker thread.

For gdb's purposes, I think only BFD globals really need to be
protected.  There are a few spots to consider.

The first is BFD error handling.  In this series, I chose to make it
thread-local.  This approach seemed simple and straightforward.
Locking seemed impractical here.  Maybe moving the error into a BFD
would work, but I didn't serious investigate that.

The second set of globals involve opening and closing BFD, and also
the fd cache.  I went back and forth on ways to solve this.  In this
series I let the BFD client provide lock- and unlock-functions, and
change BFD to use these when needed.  I took this approach because it
means that current BFD clients don't need to be changed in any way.
(I do have a variant of this patch where BFD implements its own
locking using a POSIX or Windows mutex; I can send that if you'd
prefer.)

I have a larger patch series to implement the background reading in
gdb, based on these patches.  I've run this under TSAN quite a bit and
I think all the races (there were none in BFD, of course) and
deadlocks (I found one in my first draft of this patch) have been
ironed out.  Also, it's worth noting that the approach taken here
won't really affect single-threaded BFD users, i.e., everything except
gdb.

Let me know what you think.

Tom



             reply	other threads:[~2023-10-26 19:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-26 19:07 Tom Tromey [this message]
2023-10-26 19:07 ` [PATCH 1/3] Make _bfd_error_buf static Tom Tromey
2023-11-01 12:27   ` Nick Clifton
2023-10-26 19:07 ` [PATCH 2/3] Make various error-related globals thread-local Tom Tromey
2023-11-01 12:28   ` Nick Clifton
2023-10-26 19:07 ` [PATCH 3/3] Add minimal thread-safety to BFD Tom Tromey
2023-11-01 12:45   ` Nick Clifton
2023-11-01 20:08     ` Tom Tromey
2023-11-01 20:48       ` Tom Tromey
2023-11-02 12:14         ` Nick Clifton
2023-11-03 23:10           ` Tom Tromey
2023-11-01 12:26 ` [PATCH 0/3] Threads and BFD Nick Clifton

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=20231026191435.204144-1-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=binutils@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).