X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=liblttng-ust%2Flttng-context-vtid.c;h=8c9bbec56e67324bdaeeca71893197a58b571f38;hb=553bbf7f38652084ed7966c7817b8ccb372b14e1;hp=4b1da4f8e9b78541473f3e838352e04ac4461679;hpb=8c90a710949a214d87084ff67fc85f284bc93ef2;p=lttng-ust.git diff --git a/liblttng-ust/lttng-context-vtid.c b/liblttng-ust/lttng-context-vtid.c index 4b1da4f8..8c9bbec5 100644 --- a/liblttng-ust/lttng-context-vtid.c +++ b/liblttng-ust/lttng-context-vtid.c @@ -20,6 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#define _LGPL_SOURCE #include #include #include @@ -33,7 +34,7 @@ * We cache the result to ensure we don't trigger a system call for * each event. */ -static DEFINE_URCU_TLS(pid_t, cached_vtid); +static DEFINE_URCU_TLS_IE(pid_t, cached_vtid); /* * Upon fork or clone, the TID assigned to our thread is not the same as @@ -46,7 +47,7 @@ void lttng_context_vtid_reset(void) } static -size_t vtid_get_size(size_t offset) +size_t vtid_get_size(struct lttng_ctx_field *field, size_t offset) { size_t size = 0; @@ -67,6 +68,15 @@ void vtid_record(struct lttng_ctx_field *field, sizeof(URCU_TLS(cached_vtid))); } +static +void vtid_get_value(struct lttng_ctx_field *field, + struct lttng_ctx_value *value) +{ + if (caa_unlikely(!URCU_TLS(cached_vtid))) + URCU_TLS(cached_vtid) = gettid(); + value->u.s64 = URCU_TLS(cached_vtid); +} + int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx) { struct lttng_ctx_field *field; @@ -88,6 +98,8 @@ int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx) field->event_field.type.u.basic.integer.encoding = lttng_encode_none; field->get_size = vtid_get_size; field->record = vtid_record; + field->get_value = vtid_get_value; + lttng_context_update(*ctx); return 0; }