2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-29 21:38:13 +00:00

34 Commits

Author SHA1 Message Date
Ben Pfaff
888e0cf441 async-append: Refactor to avoid requiring enabling while single threaded.
Until now, the async append interface has required async_append_enable()
to be called while the process was still single-threaded, with the
rationale being that async_append_enable() could race with
async_append_write() on some existing async_append object.  This was a
difficult problem when the async append interface was introduced, because
at the time Open vSwitch did not have any infrastructure for inter-thread
synchronization.

Now it is easy to solve, by introducing synchronization into the
async append module.  However, that's more or less wasted, because the
client is already required to serialize access to async append objects.
Moreover, vlog, the only existing client, needs to serialize access for
other reasons, so it wouldn't even be possible to just drop the client's
synchronization.

This commit therefore takes another approach.  It drops the
async_append_enable() interface entirely.  Now any existing async_append
object is always enabled.  The responsibility for "enabling", then, now
rests in whether the client creates and uses an async_append object, and
so vlog now takes care of that by itself.  Also, since vlog now has to
deal with sometimes having an async_append and sometimes not having one,
we might as well allow creating an async_append to fail, thereby slightly
simplifying the "no async I/O" implementation from "write synchronously"
to "always fail creating an async_append".

Reported-by: Shih-Hao Li <shihli@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-08-02 20:03:52 -07:00
Ethan Jackson
97be153858 clang: Add annotations for thread safety check.
This commit adds annotations for thread safety check. And the
check can be conducted by using -Wthread-safety flag in clang.

Co-authored-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-07-30 21:30:45 -07:00
Ben Pfaff
79f3d50d7c vlog: Mark vlog_module_ptr_* as const.
This makes them more obviously thread-safe.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-07-23 11:38:22 -07:00
Ben Pfaff
81d6495fd9 vlog: Make thread-safe.
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-07-18 16:00:59 -07:00
Ben Pfaff
f1de299e0c vlog: Make VLOG_ONCE thread-safe.
Of course, the code it calls into isn't thread-safe itself yet.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-07-17 11:46:56 -07:00
Ben Pfaff
c66ee51484 vlog: Remove unused function vlog_exit().
This is harder to implement once threads are introduced.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ed Maste <emaste@freebsd.org>
2013-07-12 14:31:47 -07:00
Ben Pfaff
1b22cc5513 vlog: Remove unused function vlog_get_log_file().
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ed Maste <emaste@freebsd.org>
2013-07-12 14:31:44 -07:00
Ben Pfaff
fda280145c vlog: Make vlog_should_drop() thread-safe.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ed Maste <emaste@freebsd.org>
2013-07-12 14:31:35 -07:00
Romain Lenglet
ca03aae04a vlog: extend syslog format to make OVS logs easier to filter
Prepend "ovs|" to syslog logs to make them easier to filter out of all
LOG_DAEMON logs.

Signed-off-by: Romain Lenglet <rlenglet@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-04-05 09:00:22 -05:00
Ben Pfaff
316bd0f822 vlog: New function vlog_set_levels_from_string_assert().
Two of the users of vlog_set_levels_from_string() in the tests could have
silently failed, if their arguments were invalid.  This avoids that problem
(and a memory leak).

Found by Coverity.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
2013-02-01 14:26:46 -08:00
Ben Pfaff
93161ce949 vlog: New vlog/enable-rate-limit and vlog/disable-rate-limit commands.
A few times while troubleshooting it would have been useful to get
complete logs, rather than post-rate-limiting snapshots of them.  These
ovs-appctl commands make that possible.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-12-08 12:23:08 -08:00
Ben Pfaff
d41d4b714d vlog: Add VLOG_ABORT() to log and call abort().
Whereas VLOG_FATAL() eventually calls exit(1), VLOG_ABORT()
eventually calls abort().  The key difference is that abort()
will cause a "monitor" process to restart, where exit(1) will
cause it to exit along with the monitored process.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-07-18 10:30:49 -07:00
Ben Pfaff
781dee0835 util: Introduce "subprogram_name" to identify subprocesses and threads.
This will be more useful later when we introduces "worker" subprocesses.
I don't have any current plans to introduce threading, but I can't
think of a disadvantage to wording this in a general manner.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-07-18 10:30:47 -07:00
Ben Pfaff
648f4f1fe4 token-bucket: New library for generic rate-limiting.
This commit converts two rate-limiters in the tree to use the library.
I intend to use the library elsewhere in the future.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-06-21 08:00:07 -07:00
Raju Subramanian
e0edde6fee Global replace of Nicira Networks.
Replaced all instances of Nicira Networks(, Inc) to Nicira, Inc.

Feature #10593
Signed-off-by: Raju Subramanian <rsubramanian@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-05-02 17:08:02 -07:00
Gurucharan Shetty
b5d29991cc vlog: Change the default timestamp structure.
Change the default timestamp for console and file logs to
UTC in a format that satisfies timestamp requirements in RFC 5424.

Also, add the ability for ovs-appctl to log timestamps in UTC.

Bug #9052.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
2012-01-27 16:56:12 -08:00
Ben Pfaff
7d110e9602 vlog: Move log level definitions from source code to user documentation.
Users should be able to find out what a log level means without reading
source code comments, so this seems like a better place for it.

Reported-by: David Tsai <dtsai@nicira.com>
2011-08-01 13:25:23 -07:00
Ben Pfaff
c1a543a8d6 vlog: Add a new log level "off".
Until now, "emer" has effectively been "off" because no messages were ever
logged at "emer" level.  Justin points out that it is useful to use "emer"
for messages that indicate a fatal error.  This commit makes that change
and adds a new "off" level to really turn off all logging to a facility.
2011-08-01 13:23:19 -07:00
Ben Pfaff
8a3d2fef97 vlog: Fix typo in VLOG_IS_ERR_ENABLED macro definition.
This does not fix any real bug because VLOG_IS_ERR_ENABLED is not used
anywhere in the tree.
2011-07-28 09:45:02 -07:00
Ben Pfaff
e2eed6a758 vlog: Add a little more detail to ratelimit messages
When a message is suppressed by vlog ratelimiting, and then that message
occurs again much later, sometimes we get messages like this:

   Dropped 4 log messages in last 8695 seconds due to excessive rate

It seems pretty clear in this case that in fact we just didn't get that
kind of message for most of that 8695 seconds.  This commit improves the
message by adding a little more detail, e.g.:

   Dropped 4 log messages in last 8695 seconds (most recently, 6697 seconds
   ago) due to excessive rate.

Bug #2144.
2011-06-21 15:09:08 -07:00
Ben Pfaff
f4070db7e5 Suppress sparse warnings for global variables initialized in headers.
sparse warns if a non-static variable with external linkage has an
initializer at first declaration, because it suspects that it should be
static instead.  Generally it's correct, but not in these cases, so add
a redundant declaration to suppress the warning.

The suppress warnings look like:
../ofproto/connmgr.c:40:1: warning: symbol 'VLM_connmgr' was not declared. Should it be static?
../ofproto/collectors.c:31:1: warning: symbol 'vlog_module_ptr_collectors' was not declared. Should it be static?
../ofproto/connmgr.c:43:1: warning: symbol 'counter_ofconn_stuck' was not declared. Should it be static?
2011-05-16 13:40:48 -07:00
Ben Pfaff
e3c1773370 Consistently write null pointer constants as NULL instead of 0.
Found with sparse.
2011-05-16 13:40:47 -07:00
Ben Pfaff
45704b243a vlog: Fix VLOG and VLOG_RL macros' treatment of LEVEL argument.
These macros expanded the LEVEL argument without protecting it with
parentheses, which meant that an argument like 'cond ? VLL_DBG : VLL_WARN'
did not have the desired effect (and caused a GCC warning).

This commit fixes the problem and avoids expanding LEVEL more than once,
too.
2011-04-19 09:32:18 -07:00
Ben Pfaff
279c9e0308 Log anything that could prevent a daemon from starting.
If a daemon doesn't start, we need to know why.  Being able to
consistently consult the log to find out is helpful.
2011-04-04 10:58:55 -07:00
Ben Pfaff
1c5a216a80 vlog: Use PRINTF_FORMAT macro from compiler.h.
PRINTF_FORMAT is more portable than raw __attribute__.  We use it
elsewhere, I don't know why it wasn't used here.
2011-04-04 10:58:54 -07:00
Ben Pfaff
c7981f8ca2 vlog: Add comment describing the purpose of each log level.
Based on descriptions from internal wiki.
2011-03-18 11:37:32 -07:00
Ben Pfaff
d98e600755 vlog: Make client supply semicolon for VLOG_DEFINE_THIS_MODULE.
It's kind of odd for VLOG_DEFINE_THIS_MODULE to supply its own semicolon,
so this commit switches to the more common form.
2010-10-29 09:48:47 -07:00
Ben Pfaff
5136364f41 vlog: Add VLOG_WARN_ONCE() and similar macros. 2010-09-23 11:45:34 -07:00
Joe Perches
d295e8e97a treewide: Remove trailing whitespace
Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Jesse Gross <jesse@nicira.com>
2010-08-30 13:23:08 -07:00
Ben Pfaff
480ce8abca vlog: Make the vlog module catalog program-specific.
Until now, the collection of vlog modules supported by a given OVS program
was not specific to that program.  That means that, for example, even
though ovs-dpctl does not have anything to do with jsonrpc, it still has
a vlog module for it.  This is confusing, at best.

This commit fixes the problem on some systems, in particular on ones that
use GCC and the GNU linker.  It uses the feature of the GNU linker
described in its manual as:

    If an orphaned section's name is representable as a C identifier then
    the linker will automatically see PROVIDE two symbols: __start_SECNAME
    and __end_SECNAME, where SECNAME is the name of the section.  These
    indicate the start address and end address of the orphaned section
    respectively.

Systems that don't support these features retain the earlier behavior.

This commit also fixes the annoyance that modifying lib/vlog-modules.def
causes all sources files that #include "vlog.h" to recompile.
2010-07-21 15:47:09 -07:00
Ben Pfaff
5136ce492c vlog: Introduce VLOG_DEFINE_THIS_MODULE for declaring vlog module in use.
Adding a macro to define the vlog module in use adds a level of
indirection, which makes it easier to change how the vlog module must be
defined.  A followup commit needs to do that, so getting these widespread
changes out of the way first should make that commit easier to review.
2010-07-21 15:47:09 -07:00
Jesse Gross
f4ade10529 Add extern "C" to more header files.
From partner.
2010-03-05 18:32:40 -05:00
Ben Pfaff
a14bc59fb8 Update primary code license to Apache 2.0. 2009-06-15 15:11:30 -07:00
Ben Pfaff
064af42167 Import from old repository commit 61ef2b42a9c4ba8e1600f15bb0236765edc2ad45. 2009-07-08 13:19:16 -07:00