projects
/
lttng-modules.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: handle negative clock offset
[lttng-modules.git]
/
lttng-events.c
diff --git
a/lttng-events.c
b/lttng-events.c
index c1dc1acbc5124fde9369b6045adb0f3c12ffa01f..bd6f44d977dba95e36c769f828b60e4fb9502c1f 100644
(file)
--- a/
lttng-events.c
+++ b/
lttng-events.c
@@
-1085,17
+1085,22
@@
int lttng_session_list_tracker_pids(struct lttng_session *session)
ret = PTR_ERR(tracker_pids_list_file);
goto file_error;
}
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);
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:
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);
fput(tracker_pids_list_file);
file_error:
put_unused_fd(file_fd);
@@
-1695,6
+1700,14
@@
int _lttng_field_statedump(struct lttng_session *session,
const struct lttng_basic_type *elem_type;
elem_type = &field->type.u.array.elem_type;
const struct lttng_basic_type *elem_type;
elem_type = &field->type.u.array.elem_type;
+ if (field->type.u.array.elem_alignment) {
+ ret = lttng_metadata_printf(session,
+ " struct { } align(%u) _%s_padding;\n",
+ field->type.u.array.elem_alignment * CHAR_BIT,
+ field->name);
+ if (ret)
+ return ret;
+ }
ret = lttng_metadata_printf(session,
" integer { size = %u; align = %u; signed = %u; encoding = %s; base = %u;%s } _%s[%u];\n",
elem_type->u.basic.integer.size,
ret = lttng_metadata_printf(session,
" integer { size = %u; align = %u; signed = %u; encoding = %s; base = %u;%s } _%s[%u];\n",
elem_type->u.basic.integer.size,
@@
-1741,6
+1754,14
@@
int _lttng_field_statedump(struct lttng_session *session,
if (ret)
return ret;
if (ret)
return ret;
+ if (field->type.u.sequence.elem_alignment) {
+ ret = lttng_metadata_printf(session,
+ " struct { } align(%u) _%s_padding;\n",
+ field->type.u.sequence.elem_alignment * CHAR_BIT,
+ field->name);
+ if (ret)
+ return ret;
+ }
ret = lttng_metadata_printf(session,
" integer { size = %u; align = %u; signed = %u; encoding = %s; base = %u;%s } _%s[ __%s_length ];\n",
elem_type->u.basic.integer.size,
ret = lttng_metadata_printf(session,
" integer { size = %u; align = %u; signed = %u; encoding = %s; base = %u;%s } _%s[ __%s_length ];\n",
elem_type->u.basic.integer.size,
@@
-2002,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.
* taken at start of trace.
* Yes, this is only an approximation. Yes, we can (and will) do better
* in future versions.
+ * Return 0 if offset is negative. It may happen if the system sets
+ * the REALTIME clock to 0 after boot.
*/
static
uint64_t measure_clock_offset(void)
{
*/
static
uint64_t measure_clock_offset(void)
{
- uint64_t
offset
, monotonic[2], realtime;
+ uint64_t
monotonic_avg
, monotonic[2], realtime;
uint64_t tcf = trace_clock_freq();
uint64_t tcf = trace_clock_freq();
+ int64_t offset;
struct timespec rts = { 0, 0 };
unsigned long flags;
struct timespec rts = { 0, 0 };
unsigned long flags;
@@
-2018,7
+2042,7
@@
uint64_t measure_clock_offset(void)
monotonic[1] = trace_clock_read64();
local_irq_restore(flags);
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;
realtime = (uint64_t) rts.tv_sec * tcf;
if (tcf == NSEC_PER_SEC) {
realtime += rts.tv_nsec;
@@
-2028,7
+2052,9
@@
uint64_t measure_clock_offset(void)
do_div(n, NSEC_PER_SEC);
realtime += n;
}
do_div(n, NSEC_PER_SEC);
realtime += n;
}
- offset = realtime - offset;
+ offset = (int64_t) realtime - monotonic_avg;
+ if (offset < 0)
+ return 0;
return offset;
}
return offset;
}
This page took
0.055602 seconds
and
4
git commands to generate.