public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Threads and BFD
@ 2023-10-26 19:07 Tom Tromey
  2023-10-26 19:07 ` [PATCH 1/3] Make _bfd_error_buf static Tom Tromey
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Tom Tromey @ 2023-10-26 19:07 UTC (permalink / raw)
  To: binutils

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



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-11-03 23:09 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-26 19:07 [PATCH 0/3] Threads and BFD Tom Tromey
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

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).