fatal-signal: Remove write-only variable fatal_signal_set.

Signed-off-by: Ben Pfaff <blp@nicira.com>
stress: Remove essentially unused library.

The "stress" library was introduced years ago.  We intended at the time to
start using it to provoke errors in testing, to make sure that Open vSwitch
was resilient against those errors.  The intention was good, but there were
few actual implementations of stress options, and the testing never
materialized.

Rather than adapt the stress library for thread safety, this seems like a
good opportunity to remove it, so this commit does so.

Signed-off-by: Ben Pfaff <blp@nicira.com>
netlink-socket: Simplify use of transactions and dumps.

This disentangles "struct nl_dump" from "struct nl_sock", clearing the way
to make the use of either one thread-safe in an obviously correct manner.

Signed-off-by: Ben Pfaff <blp@nicira.com>
netlink-socket: Make thread-safe.

The uses of vlog in this module are not thread-safe, because vlog itself
is not yet thread-safe.

Signed-off-by: Ben Pfaff <blp@nicira.com>
timeval: Always block SIGALRM in time_poll().

Until now, time_poll() has blocked SIGALRM lazily, only after waking up
once due to SIGALRM.  The rationale was that many calls to poll() wake up
quickly, before any SIGALRM would arrive, so that by only blocking it
lazily we saved two system calls (one to block SIGALRM, one to unblock it)
on most calls.

Adding multithreading to OVS seems to me to shift the balance a little
bit.  I expect that most of the new threads will often be idle.  It
seems counterintuitive to have them wake up after sleeping for a while.

Therefore, this commit changes time_poll() to block SIGALRM every time, not
just after a wakeup due to SIGALRM.  We use ppoll() instead of poll() to
reduce the overhead of blocking SIGALRM from two system calls to one.
(The usual reason for ppoll() is to ensure atomicity of changing the signal
mask and blocking, but time_poll() does not need atomicity.  Therefore,
even a userspace emulated ppoll() would work here in a race-free manner, if
the kernel does not support ppoll().)

Signed-off-by: Ben Pfaff <blp@nicira.com>
timeval: New function xclock_gettime().

Signed-off-by: Ben Pfaff <blp@nicira.com>
timeval: Make reading the current time thread-safe.

Signed-off-by: Ben Pfaff <blp@nicira.com>
timeval: Remove backtrace feature.

The backtrace feature of timeval is useful because it provides a "poor
man's profile" view of Open vSwitch.  But it is not likely to be useful in
a multithreaded process, because signal delivery doesn't necessarily follow
the profile when there is more than one thread.  (A signal in a
multithreaded process are delivered to an arbitrary thread.)

Another problem with the backtrace feature is that it is difficult for
format_backtraces() to synchronize properly with the signal handler in a
multithreaded process.  In a single-threaded process, it can just block
the signal handler, but in a multithreaded process this does not prevent
signal delivery to threads other than the one running format_backtrace().

Signed-off-by: Ben Pfaff <blp@nicira.com>
timeval: Fix typo in comment.

Signed-off-by: Ben Pfaff <blp@nicira.com>
timeval: Make CPU usage and wakeup tracking per-thread.

This should make the "timeval" module thread-safe, except for its
calls into vlog (because vlog is not yet thread-safe).

Signed-off-by: Ben Pfaff <blp@nicira.com>
poll-loop: Simplify and speed up polling.

The simplification comes from dropping support for canceling a
poll_waiter, which was a feature that was never used.  The speedup
comes from avoiding a malloc() for every call to poll_fd_wait().
(I doubt that this significantly improves performance.)

This prepares for making the polling structures per-thread in
the next commit.

Signed-off-by: Ben Pfaff <blp@nicira.com>
poll-loop: Make poll loop data structures per-thread.

Signed-off-by: Ben Pfaff <blp@nicira.com>
poll-loop: Fix typo in comment.

Signed-off-by: Ben Pfaff <blp@nicira.com>
vlog: Remove support for worker process.

The worker process implementation isn't thread-safe and, once OVS
itself is threaded, it doesn't make much sense to have a worker
process anyway.

Signed-off-by: Ben Pfaff <blp@nicira.com>
system-stats: Remove worker process support.

The worker process implementation isn't thread-safe and, once OVS
itself is threaded, it doesn't make much sense to have a worker
process anyway.

Signed-off-by: Ben Pfaff <blp@nicira.com>
worker: Delete library.

It had no remaining users.

Signed-off-by: Ben Pfaff <blp@nicira.com>
latch: New module for a thread-safe, signal-safe, pollable doorbell.

Signed-off-by: Ben Pfaff <blp@nicira.com>
system-stats: Move into separate thread.

Signed-off-by: Ben Pfaff <blp@nicira.com>
byteq: Make the queue size variable instead of fixed at BYTEQ_SIZE bytes.

Signed-off-by: Ben Pfaff <blp@nicira.com>
util: New macros ROUND_UP_POW2, ROUND_DOWN_POW2.

Signed-off-by: Ben Pfaff <blp@nicira.com>