mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-20 21:31:28 +02:00
MINOR: trace: don't call strlen() on the function's name
Currently there's a small mistake in the way the trace function and macros. The calling function name is known as a constant until the macro and passed as-is to the __trace() function. That one needs to know its length and will call ist() on it, resulting in a real call to strlen() while that length was known before the call. Let's use an ist instead of a const char* for __trace() and __trace_enabled() so that we can now completely avoid calling strlen() during this operation. This has significantly reduced the importance of __trace_enabled() in perf top.
This commit is contained in:
parent
06fa9f717f
commit
361c227465
@ -79,37 +79,37 @@
|
|||||||
* TRACE_ENABLED() reports whether or not trace is enabled for the current
|
* TRACE_ENABLED() reports whether or not trace is enabled for the current
|
||||||
* source, level, mask and arguments.
|
* source, level, mask and arguments.
|
||||||
*/
|
*/
|
||||||
#define TRACE_ENABLED(level, mask, args...) (_trace_enabled((level), (mask), TRACE_SOURCE, ist(TRC_LOC), __FUNCTION__, ##args))
|
#define TRACE_ENABLED(level, mask, args...) (_trace_enabled((level), (mask), TRACE_SOURCE, ist(TRC_LOC), ist(__FUNCTION__), ##args))
|
||||||
|
|
||||||
#define TRACE(msg, mask, args...) \
|
#define TRACE(msg, mask, args...) \
|
||||||
_trace(TRACE_LEVEL, (mask), TRACE_SOURCE, ist(TRC_LOC), NULL, TRC_5ARGS(0,##args,0,0,0,0,0), ist(msg))
|
_trace(TRACE_LEVEL, (mask), TRACE_SOURCE, ist(TRC_LOC), IST_NULL, TRC_5ARGS(0,##args,0,0,0,0,0), ist(msg))
|
||||||
|
|
||||||
#define TRACE_ERROR(msg, mask, args...) \
|
#define TRACE_ERROR(msg, mask, args...) \
|
||||||
_trace(TRACE_LEVEL_ERROR, (mask), TRACE_SOURCE, ist(TRC_LOC), NULL, TRC_5ARGS(0,##args,0,0,0,0,0), ist(msg))
|
_trace(TRACE_LEVEL_ERROR, (mask), TRACE_SOURCE, ist(TRC_LOC), IST_NULL, TRC_5ARGS(0,##args,0,0,0,0,0), ist(msg))
|
||||||
|
|
||||||
#define TRACE_USER(msg, mask, args...) \
|
#define TRACE_USER(msg, mask, args...) \
|
||||||
_trace(TRACE_LEVEL_USER, (mask), TRACE_SOURCE, ist(TRC_LOC), NULL, TRC_5ARGS(0,##args,0,0,0,0,0), ist(msg))
|
_trace(TRACE_LEVEL_USER, (mask), TRACE_SOURCE, ist(TRC_LOC), IST_NULL, TRC_5ARGS(0,##args,0,0,0,0,0), ist(msg))
|
||||||
|
|
||||||
#define TRACE_DATA(msg, mask, args...) \
|
#define TRACE_DATA(msg, mask, args...) \
|
||||||
_trace(TRACE_LEVEL_DATA, (mask), TRACE_SOURCE, ist(TRC_LOC), NULL, TRC_5ARGS(0,##args,0,0,0,0,0), ist(msg))
|
_trace(TRACE_LEVEL_DATA, (mask), TRACE_SOURCE, ist(TRC_LOC), IST_NULL, TRC_5ARGS(0,##args,0,0,0,0,0), ist(msg))
|
||||||
|
|
||||||
#define TRACE_PROTO(msg, mask, args...) \
|
#define TRACE_PROTO(msg, mask, args...) \
|
||||||
_trace(TRACE_LEVEL_PROTO, (mask), TRACE_SOURCE, ist(TRC_LOC), NULL, TRC_5ARGS(0,##args,0,0,0,0,0), ist(msg))
|
_trace(TRACE_LEVEL_PROTO, (mask), TRACE_SOURCE, ist(TRC_LOC), IST_NULL, TRC_5ARGS(0,##args,0,0,0,0,0), ist(msg))
|
||||||
|
|
||||||
#define TRACE_STATE(msg, mask, args...) \
|
#define TRACE_STATE(msg, mask, args...) \
|
||||||
_trace(TRACE_LEVEL_STATE, (mask), TRACE_SOURCE, ist(TRC_LOC), NULL, TRC_5ARGS(0,##args,0,0,0,0,0), ist(msg))
|
_trace(TRACE_LEVEL_STATE, (mask), TRACE_SOURCE, ist(TRC_LOC), IST_NULL, TRC_5ARGS(0,##args,0,0,0,0,0), ist(msg))
|
||||||
|
|
||||||
#define TRACE_DEVEL(msg, mask, args...) \
|
#define TRACE_DEVEL(msg, mask, args...) \
|
||||||
_trace(TRACE_LEVEL_DEVELOPER, (mask), TRACE_SOURCE, ist(TRC_LOC), __FUNCTION__, TRC_5ARGS(0,##args,0,0,0,0,0), ist(msg))
|
_trace(TRACE_LEVEL_DEVELOPER, (mask), TRACE_SOURCE, ist(TRC_LOC), ist(__FUNCTION__), TRC_5ARGS(0,##args,0,0,0,0,0), ist(msg))
|
||||||
|
|
||||||
#define TRACE_ENTER(mask, args...) \
|
#define TRACE_ENTER(mask, args...) \
|
||||||
_trace(TRACE_LEVEL_DEVELOPER, (mask), TRACE_SOURCE, ist(TRC_LOC), __FUNCTION__, TRC_5ARGS(0,##args,0,0,0,0,0), ist("entering"))
|
_trace(TRACE_LEVEL_DEVELOPER, (mask), TRACE_SOURCE, ist(TRC_LOC), ist(__FUNCTION__), TRC_5ARGS(0,##args,0,0,0,0,0), ist("entering"))
|
||||||
|
|
||||||
#define TRACE_LEAVE(mask, args...) \
|
#define TRACE_LEAVE(mask, args...) \
|
||||||
_trace(TRACE_LEVEL_DEVELOPER, (mask), TRACE_SOURCE, ist(TRC_LOC), __FUNCTION__, TRC_5ARGS(0,##args,0,0,0,0,0), ist("leaving"))
|
_trace(TRACE_LEVEL_DEVELOPER, (mask), TRACE_SOURCE, ist(TRC_LOC), ist(__FUNCTION__), TRC_5ARGS(0,##args,0,0,0,0,0), ist("leaving"))
|
||||||
|
|
||||||
#define TRACE_POINT(mask, args...) \
|
#define TRACE_POINT(mask, args...) \
|
||||||
_trace(TRACE_LEVEL_DEVELOPER, (mask), TRACE_SOURCE, ist(TRC_LOC), __FUNCTION__, TRC_5ARGS(0,##args,0,0,0,0,0), ist("in"))
|
_trace(TRACE_LEVEL_DEVELOPER, (mask), TRACE_SOURCE, ist(TRC_LOC), ist(__FUNCTION__), TRC_5ARGS(0,##args,0,0,0,0,0), ist("in"))
|
||||||
|
|
||||||
/* This produces a printf-like trace at level <level> for event mask <mask> and
|
/* This produces a printf-like trace at level <level> for event mask <mask> and
|
||||||
* trace arguments <a1..a4>. All args mandatory, but may be zero. No output
|
* trace arguments <a1..a4>. All args mandatory, but may be zero. No output
|
||||||
@ -135,7 +135,7 @@
|
|||||||
if (_msg_len >= sizeof(_msg)) \
|
if (_msg_len >= sizeof(_msg)) \
|
||||||
_msg_len = sizeof(_msg) - 1; \
|
_msg_len = sizeof(_msg) - 1; \
|
||||||
_trace((level), (mask), TRACE_SOURCE, \
|
_trace((level), (mask), TRACE_SOURCE, \
|
||||||
trc_loc, func, a1, a2, a3, a4, \
|
trc_loc, ist(func), a1, a2, a3, a4, \
|
||||||
&trace_no_cb, ist2(_msg, _msg_len)); \
|
&trace_no_cb, ist2(_msg, _msg_len)); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
@ -172,12 +172,12 @@ extern struct list trace_sources;
|
|||||||
extern THREAD_LOCAL struct buffer trace_buf;
|
extern THREAD_LOCAL struct buffer trace_buf;
|
||||||
|
|
||||||
int __trace_enabled(enum trace_level level, uint64_t mask, struct trace_source *src,
|
int __trace_enabled(enum trace_level level, uint64_t mask, struct trace_source *src,
|
||||||
const struct ist where, const char *func,
|
const struct ist where, const struct ist ist_func,
|
||||||
const void *a1, const void *a2, const void *a3, const void *a4,
|
const void *a1, const void *a2, const void *a3, const void *a4,
|
||||||
const void **plockptr);
|
const void **plockptr);
|
||||||
|
|
||||||
void __trace(enum trace_level level, uint64_t mask, struct trace_source *src,
|
void __trace(enum trace_level level, uint64_t mask, struct trace_source *src,
|
||||||
const struct ist where, const char *func,
|
const struct ist where, const struct ist ist_func,
|
||||||
const void *a1, const void *a2, const void *a3, const void *a4,
|
const void *a1, const void *a2, const void *a3, const void *a4,
|
||||||
void (*cb)(enum trace_level level, uint64_t mask, const struct trace_source *src,
|
void (*cb)(enum trace_level level, uint64_t mask, const struct trace_source *src,
|
||||||
const struct ist where, const struct ist func,
|
const struct ist where, const struct ist func,
|
||||||
|
@ -87,7 +87,7 @@ static inline const void *trace_pick_arg(uint32_t arg_def, const void *a1, const
|
|||||||
* and check if the result is >0.
|
* and check if the result is >0.
|
||||||
*/
|
*/
|
||||||
int __trace_enabled(enum trace_level level, uint64_t mask, struct trace_source *src,
|
int __trace_enabled(enum trace_level level, uint64_t mask, struct trace_source *src,
|
||||||
const struct ist where, const char *func,
|
const struct ist where, const struct ist ist_func,
|
||||||
const void *a1, const void *a2, const void *a3, const void *a4,
|
const void *a1, const void *a2, const void *a3, const void *a4,
|
||||||
const void **plockptr)
|
const void **plockptr)
|
||||||
{
|
{
|
||||||
@ -252,7 +252,7 @@ int __trace_enabled(enum trace_level level, uint64_t mask, struct trace_source *
|
|||||||
|
|
||||||
/* write a message for the given trace source */
|
/* write a message for the given trace source */
|
||||||
void __trace(enum trace_level level, uint64_t mask, struct trace_source *src,
|
void __trace(enum trace_level level, uint64_t mask, struct trace_source *src,
|
||||||
const struct ist where, const char *func,
|
const struct ist where, const struct ist ist_func,
|
||||||
const void *a1, const void *a2, const void *a3, const void *a4,
|
const void *a1, const void *a2, const void *a3, const void *a4,
|
||||||
void (*cb)(enum trace_level level, uint64_t mask, const struct trace_source *src,
|
void (*cb)(enum trace_level level, uint64_t mask, const struct trace_source *src,
|
||||||
const struct ist where, const struct ist func,
|
const struct ist where, const struct ist func,
|
||||||
@ -260,14 +260,13 @@ void __trace(enum trace_level level, uint64_t mask, struct trace_source *src,
|
|||||||
const struct ist msg)
|
const struct ist msg)
|
||||||
{
|
{
|
||||||
const void *lockon_ptr;
|
const void *lockon_ptr;
|
||||||
struct ist ist_func = ist(func);
|
|
||||||
char tnum[4];
|
char tnum[4];
|
||||||
struct ist line[12];
|
struct ist line[12];
|
||||||
int words = 0;
|
int words = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
lockon_ptr = NULL;
|
lockon_ptr = NULL;
|
||||||
ret = __trace_enabled(level, mask, src, where, func, a1, a2, a3, a4, &lockon_ptr);
|
ret = __trace_enabled(level, mask, src, where, ist_func, a1, a2, a3, a4, &lockon_ptr);
|
||||||
if (lockon_ptr)
|
if (lockon_ptr)
|
||||||
HA_ATOMIC_STORE(&src->lockon_ptr, lockon_ptr);
|
HA_ATOMIC_STORE(&src->lockon_ptr, lockon_ptr);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user