X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=lttng-events.c;h=1f2863945a74f977fcc38b2635020064b80f84aa;hb=1aa3298b3f14ea1c4fb918d994b67a3a425cbd2a;hp=1f34fbbc3341afd6ce8094c02fba4ed4b818bb70;hpb=43803cf2bdfe205fe0e426f7e93507d722ba1feb;p=lttng-modules.git diff --git a/lttng-events.c b/lttng-events.c index 1f34fbbc..1f286394 100644 --- a/lttng-events.c +++ b/lttng-events.c @@ -36,21 +36,21 @@ #include #include #include -#include "wrapper/file.h" +#include #include #include #include -#include "wrapper/uuid.h" -#include "wrapper/vmalloc.h" /* for wrapper_vmalloc_sync_all() */ -#include "wrapper/random.h" -#include "wrapper/tracepoint.h" -#include "wrapper/list.h" -#include "lttng-kernel-version.h" -#include "lttng-events.h" -#include "lttng-tracer.h" -#include "lttng-abi-old.h" -#include "wrapper/vzalloc.h" +#include +#include /* for wrapper_vmalloc_sync_all() */ +#include +#include +#include +#include +#include +#include +#include +#include #define METADATA_CACHE_DEFAULT_SIZE 4096 @@ -1085,17 +1085,22 @@ int lttng_session_list_tracker_pids(struct lttng_session *session) ret = PTR_ERR(tracker_pids_list_file); goto file_error; } + if (atomic_long_add_unless(&session->file->f_count, + 1, INT_MAX) == INT_MAX) { + goto refcount_error; + } ret = lttng_tracker_pids_list_fops.open(NULL, tracker_pids_list_file); if (ret < 0) goto open_error; m = tracker_pids_list_file->private_data; m->private = session; fd_install(file_fd, tracker_pids_list_file); - atomic_long_inc(&session->file->f_count); return file_fd; open_error: + atomic_long_dec(&session->file->f_count); +refcount_error: fput(tracker_pids_list_file); file_error: put_unused_fd(file_fd); @@ -2018,12 +2023,15 @@ int _lttng_event_header_declare(struct lttng_session *session) * taken at start of trace. * Yes, this is only an approximation. Yes, we can (and will) do better * in future versions. + * This function may return a negative offset. It may happen if the + * system sets the REALTIME clock to 0 after boot. */ static -uint64_t measure_clock_offset(void) +int64_t measure_clock_offset(void) { - uint64_t offset, monotonic[2], realtime; + uint64_t monotonic_avg, monotonic[2], realtime; uint64_t tcf = trace_clock_freq(); + int64_t offset; struct timespec rts = { 0, 0 }; unsigned long flags; @@ -2034,7 +2042,7 @@ uint64_t measure_clock_offset(void) monotonic[1] = trace_clock_read64(); local_irq_restore(flags); - offset = (monotonic[0] + monotonic[1]) >> 1; + monotonic_avg = (monotonic[0] + monotonic[1]) >> 1; realtime = (uint64_t) rts.tv_sec * tcf; if (tcf == NSEC_PER_SEC) { realtime += rts.tv_nsec; @@ -2044,7 +2052,7 @@ uint64_t measure_clock_offset(void) do_div(n, NSEC_PER_SEC); realtime += n; } - offset = realtime - offset; + offset = (int64_t) realtime - monotonic_avg; return offset; } @@ -2156,11 +2164,11 @@ int _lttng_session_metadata_statedump(struct lttng_session *session) " description = \"%s\";\n" " freq = %llu; /* Frequency, in Hz */\n" " /* clock value offset from Epoch is: offset * (1/freq) */\n" - " offset = %llu;\n" + " offset = %lld;\n" "};\n\n", trace_clock_description(), (unsigned long long) trace_clock_freq(), - (unsigned long long) measure_clock_offset() + (long long) measure_clock_offset() ); if (ret) goto end; @@ -2261,6 +2269,9 @@ static int __init lttng_events_init(void) if (ret) return ret; ret = wrapper_get_pfnblock_flags_mask_init(); + if (ret) + return ret; + ret = wrapper_get_pageblock_flags_mask_init(); if (ret) return ret; ret = lttng_context_init();