From: Mathieu Desnoyers Date: Fri, 7 May 2021 18:33:58 +0000 (-0400) Subject: Move alignment into event write callback X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=f5ffbd770ec2b9d1ac9b7059eb33a01432043bce;p=lttng-modules.git Move alignment into event write callback Signed-off-by: Mathieu Desnoyers Change-Id: I7563cdd07163fc22e2269627879a83e871c4eb01 --- diff --git a/include/lttng/events.h b/include/lttng/events.h index 0f6b5ab9..9d07d7ed 100644 --- a/include/lttng/events.h +++ b/include/lttng/events.h @@ -383,9 +383,9 @@ struct lttng_kernel_channel_buffer_ops { int (*event_reserve)(struct lttng_kernel_ring_buffer_ctx *ctx); void (*event_commit)(struct lttng_kernel_ring_buffer_ctx *ctx); void (*event_write)(struct lttng_kernel_ring_buffer_ctx *ctx, const void *src, - size_t len); + size_t len, size_t alignment); void (*event_write_from_user)(struct lttng_kernel_ring_buffer_ctx *ctx, - const void *src, size_t len); + const void *src, size_t len, size_t alignment); void (*event_memset)(struct lttng_kernel_ring_buffer_ctx *ctx, int c, size_t len); void (*event_strcpy)(struct lttng_kernel_ring_buffer_ctx *ctx, const char *src, diff --git a/include/lttng/tracepoint-event-impl.h b/include/lttng/tracepoint-event-impl.h index ce41fcb6..e3a858a3 100644 --- a/include/lttng/tracepoint-event-impl.h +++ b/include/lttng/tracepoint-event-impl.h @@ -813,8 +813,7 @@ static inline size_t __event_get_align__##_name(void *__tp_locvar) \ #define _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite) \ { \ _type __tmp = _src; \ - lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__tmp));\ - __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp));\ + __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp), lttng_alignof(__tmp)); \ } #undef _ctf_integer_ext_isuser0 @@ -840,21 +839,19 @@ static inline size_t __event_get_align__##_name(void *__tp_locvar) \ #undef _ctf_array_encoded #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \ - lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \ if (_user) { \ - __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length)); \ + __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length), lttng_alignof(_type)); \ } else { \ - __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); \ + __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length), lttng_alignof(_type)); \ } #if (__BYTE_ORDER == __LITTLE_ENDIAN) #undef _ctf_array_bitfield #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \ - lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \ if (_user) { \ - __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length)); \ + __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length), lttng_alignof(_type)); \ } else { \ - __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); \ + __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length), lttng_alignof(_type)); \ } #else /* #if (__BYTE_ORDER == __LITTLE_ENDIAN) */ /* @@ -890,7 +887,7 @@ static inline size_t __event_get_align__##_name(void *__tp_locvar) \ default: \ BUG_ON(1); \ } \ - __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type)); \ + __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type), 1); \ } \ } #endif /* #else #if (__BYTE_ORDER == __LITTLE_ENDIAN) */ @@ -900,16 +897,14 @@ static inline size_t __event_get_align__##_name(void *__tp_locvar) \ _src_length, _encoding, _byte_order, _base, _user, _nowrite) \ { \ _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx]; \ - lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\ - __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\ + __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type), lttng_alignof(_length_type));\ } \ - lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \ if (_user) { \ __chan->ops->event_write_from_user(&__ctx, _src, \ - sizeof(_type) * __get_dynamic_len(dest)); \ + sizeof(_type) * __get_dynamic_len(dest), lttng_alignof(_type)); \ } else { \ __chan->ops->event_write(&__ctx, _src, \ - sizeof(_type) * __get_dynamic_len(dest)); \ + sizeof(_type) * __get_dynamic_len(dest), lttng_alignof(_type)); \ } #if (__BYTE_ORDER == __LITTLE_ENDIAN) @@ -919,16 +914,14 @@ static inline size_t __event_get_align__##_name(void *__tp_locvar) \ _user, _nowrite) \ { \ _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx] * sizeof(_type) * CHAR_BIT; \ - lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\ - __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\ + __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type), lttng_alignof(_length_type)); \ } \ - lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \ if (_user) { \ __chan->ops->event_write_from_user(&__ctx, _src, \ - sizeof(_type) * __get_dynamic_len(dest)); \ + sizeof(_type) * __get_dynamic_len(dest), lttng_alignof(_type)); \ } else { \ __chan->ops->event_write(&__ctx, _src, \ - sizeof(_type) * __get_dynamic_len(dest)); \ + sizeof(_type) * __get_dynamic_len(dest), lttng_alignof(_type)); \ } #else /* #if (__BYTE_ORDER == __LITTLE_ENDIAN) */ /* @@ -940,8 +933,7 @@ static inline size_t __event_get_align__##_name(void *__tp_locvar) \ _user, _nowrite) \ { \ _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx] * sizeof(_type) * CHAR_BIT; \ - lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\ - __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\ + __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type), lttng_alignof(_length_type)); \ } \ lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \ { \ @@ -972,7 +964,7 @@ static inline size_t __event_get_align__##_name(void *__tp_locvar) \ default: \ BUG_ON(1); \ } \ - __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type)); \ + __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type), 1); \ } \ } #endif /* #else #if (__BYTE_ORDER == __LITTLE_ENDIAN) */ diff --git a/src/lttng-context-callstack-legacy-impl.h b/src/lttng-context-callstack-legacy-impl.h index 03409291..833443d6 100644 --- a/src/lttng-context-callstack-legacy-impl.h +++ b/src/lttng-context-callstack-legacy-impl.h @@ -197,7 +197,6 @@ void lttng_callstack_length_record(void *priv, struct lttng_kernel_probe_ctx *pr struct stack_trace *trace = stack_trace_context(fdata, cpu); unsigned int nr_seq_entries; - lib_ring_buffer_align_ctx(ctx, lttng_alignof(unsigned int)); if (unlikely(!trace)) { nr_seq_entries = 0; } else { @@ -205,7 +204,7 @@ void lttng_callstack_length_record(void *priv, struct lttng_kernel_probe_ctx *pr if (trace->nr_entries == trace->max_entries) nr_seq_entries++; } - chan->ops->event_write(ctx, &nr_seq_entries, sizeof(unsigned int)); + chan->ops->event_write(ctx, &nr_seq_entries, sizeof(unsigned int), lttng_alignof(unsigned int)); } static void lttng_callstack_sequence_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, @@ -217,19 +216,19 @@ void lttng_callstack_sequence_record(void *priv, struct lttng_kernel_probe_ctx * struct stack_trace *trace = stack_trace_context(fdata, cpu); unsigned int nr_seq_entries; - lib_ring_buffer_align_ctx(ctx, lttng_alignof(unsigned long)); if (unlikely(!trace)) { + lib_ring_buffer_align_ctx(ctx, lttng_alignof(unsigned long)); return; } nr_seq_entries = trace->nr_entries; if (trace->nr_entries == trace->max_entries) nr_seq_entries++; chan->ops->event_write(ctx, trace->entries, - sizeof(unsigned long) * trace->nr_entries); + sizeof(unsigned long) * trace->nr_entries, lttng_alignof(unsigned long)); /* Add our own ULONG_MAX delimiter to show incomplete stack. */ if (trace->nr_entries == trace->max_entries) { unsigned long delim = ULONG_MAX; - chan->ops->event_write(ctx, &delim, sizeof(unsigned long)); + chan->ops->event_write(ctx, &delim, sizeof(unsigned long), 1); } } diff --git a/src/lttng-context-callstack-stackwalk-impl.h b/src/lttng-context-callstack-stackwalk-impl.h index 2452804d..e73d1156 100644 --- a/src/lttng-context-callstack-stackwalk-impl.h +++ b/src/lttng-context-callstack-stackwalk-impl.h @@ -202,7 +202,6 @@ void lttng_callstack_length_record(void *priv, struct lttng_kernel_probe_ctx *pr struct lttng_stack_trace *trace = stack_trace_context(fdata, cpu); unsigned int nr_seq_entries; - lib_ring_buffer_align_ctx(ctx, lttng_alignof(unsigned int)); if (unlikely(!trace)) { nr_seq_entries = 0; } else { @@ -210,7 +209,7 @@ void lttng_callstack_length_record(void *priv, struct lttng_kernel_probe_ctx *pr if (trace->nr_entries == MAX_ENTRIES) nr_seq_entries++; } - chan->ops->event_write(ctx, &nr_seq_entries, sizeof(unsigned int)); + chan->ops->event_write(ctx, &nr_seq_entries, sizeof(unsigned int), lttng_alignof(unsigned int)); } static @@ -223,19 +222,20 @@ void lttng_callstack_sequence_record(void *priv, struct lttng_kernel_probe_ctx * struct lttng_stack_trace *trace = stack_trace_context(fdata, cpu); unsigned int nr_seq_entries; - lib_ring_buffer_align_ctx(ctx, lttng_alignof(unsigned long)); if (unlikely(!trace)) { + /* We need to align even if there are 0 elements. */ + lib_ring_buffer_align_ctx(ctx, lttng_alignof(unsigned long)); return; } nr_seq_entries = trace->nr_entries; if (trace->nr_entries == MAX_ENTRIES) nr_seq_entries++; chan->ops->event_write(ctx, trace->entries, - sizeof(unsigned long) * trace->nr_entries); + sizeof(unsigned long) * trace->nr_entries, lttng_alignof(unsigned long)); /* Add our own ULONG_MAX delimiter to show incomplete stack. */ if (trace->nr_entries == MAX_ENTRIES) { unsigned long delim = ULONG_MAX; - chan->ops->event_write(ctx, &delim, sizeof(unsigned long)); + chan->ops->event_write(ctx, &delim, sizeof(unsigned long), 1); } } diff --git a/src/lttng-context-cgroup-ns.c b/src/lttng-context-cgroup-ns.c index 6cab3153..3a7f574c 100644 --- a/src/lttng-context-cgroup-ns.c +++ b/src/lttng-context-cgroup-ns.c @@ -51,8 +51,7 @@ void cgroup_ns_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, if (current->nsproxy) cgroup_ns_inum = current->nsproxy->cgroup_ns->lttng_ns_inum; - lib_ring_buffer_align_ctx(ctx, lttng_alignof(cgroup_ns_inum)); - chan->ops->event_write(ctx, &cgroup_ns_inum, sizeof(cgroup_ns_inum)); + chan->ops->event_write(ctx, &cgroup_ns_inum, sizeof(cgroup_ns_inum), lttng_alignof(cgroup_ns_inum)); } static diff --git a/src/lttng-context-cpu-id.c b/src/lttng-context-cpu-id.c index 24241dee..30247c31 100644 --- a/src/lttng-context-cpu-id.c +++ b/src/lttng-context-cpu-id.c @@ -34,8 +34,7 @@ void cpu_id_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, int cpu; cpu = ctx->priv.reserve_cpu; - lib_ring_buffer_align_ctx(ctx, lttng_alignof(cpu)); - chan->ops->event_write(ctx, &cpu, sizeof(cpu)); + chan->ops->event_write(ctx, &cpu, sizeof(cpu), lttng_alignof(cpu)); } static diff --git a/src/lttng-context-egid.c b/src/lttng-context-egid.c index 6eaa758e..1473688b 100644 --- a/src/lttng-context-egid.c +++ b/src/lttng-context-egid.c @@ -36,8 +36,7 @@ void egid_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, gid_t egid; egid = lttng_current_egid(); - lib_ring_buffer_align_ctx(ctx, lttng_alignof(egid)); - chan->ops->event_write(ctx, &egid, sizeof(egid)); + chan->ops->event_write(ctx, &egid, sizeof(egid), lttng_alignof(egid)); } static diff --git a/src/lttng-context-euid.c b/src/lttng-context-euid.c index 90a6dd3c..7d344b1f 100644 --- a/src/lttng-context-euid.c +++ b/src/lttng-context-euid.c @@ -36,8 +36,7 @@ void euid_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, uid_t euid; euid = lttng_current_euid(); - lib_ring_buffer_align_ctx(ctx, lttng_alignof(euid)); - chan->ops->event_write(ctx, &euid, sizeof(euid)); + chan->ops->event_write(ctx, &euid, sizeof(euid), lttng_alignof(euid)); } static diff --git a/src/lttng-context-gid.c b/src/lttng-context-gid.c index f0084079..17f637d7 100644 --- a/src/lttng-context-gid.c +++ b/src/lttng-context-gid.c @@ -36,8 +36,7 @@ void gid_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, gid_t gid; gid = lttng_current_gid(); - lib_ring_buffer_align_ctx(ctx, lttng_alignof(gid)); - chan->ops->event_write(ctx, &gid, sizeof(gid)); + chan->ops->event_write(ctx, &gid, sizeof(gid), lttng_alignof(gid)); } static diff --git a/src/lttng-context-hostname.c b/src/lttng-context-hostname.c index 8956e540..96320ad3 100644 --- a/src/lttng-context-hostname.c +++ b/src/lttng-context-hostname.c @@ -46,7 +46,7 @@ void hostname_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, ns = nsproxy->uts_ns; hostname = ns->name.nodename; chan->ops->event_write(ctx, hostname, - LTTNG_HOSTNAME_CTX_LEN); + LTTNG_HOSTNAME_CTX_LEN, 1); } else { chan->ops->event_memset(ctx, 0, LTTNG_HOSTNAME_CTX_LEN); diff --git a/src/lttng-context-interruptible.c b/src/lttng-context-interruptible.c index bf2589da..48ff7efe 100644 --- a/src/lttng-context-interruptible.c +++ b/src/lttng-context-interruptible.c @@ -39,8 +39,7 @@ void interruptible_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, struct lttng_kernel_probe_ctx *lttng_probe_ctx = ctx->probe_ctx; int8_t interruptible = lttng_probe_ctx->interruptible; - lib_ring_buffer_align_ctx(ctx, lttng_alignof(interruptible)); - chan->ops->event_write(ctx, &interruptible, sizeof(interruptible)); + chan->ops->event_write(ctx, &interruptible, sizeof(interruptible), lttng_alignof(interruptible)); } static diff --git a/src/lttng-context-ipc-ns.c b/src/lttng-context-ipc-ns.c index c578fea8..d5d0608f 100644 --- a/src/lttng-context-ipc-ns.c +++ b/src/lttng-context-ipc-ns.c @@ -50,8 +50,7 @@ void ipc_ns_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, if (current->nsproxy) ipc_ns_inum = current->nsproxy->ipc_ns->lttng_ns_inum; - lib_ring_buffer_align_ctx(ctx, lttng_alignof(ipc_ns_inum)); - chan->ops->event_write(ctx, &ipc_ns_inum, sizeof(ipc_ns_inum)); + chan->ops->event_write(ctx, &ipc_ns_inum, sizeof(ipc_ns_inum), lttng_alignof(ipc_ns_inum)); } static diff --git a/src/lttng-context-migratable.c b/src/lttng-context-migratable.c index e2f6bfd9..82d3dba0 100644 --- a/src/lttng-context-migratable.c +++ b/src/lttng-context-migratable.c @@ -34,8 +34,7 @@ void migratable_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, { uint8_t migratable = !current->migrate_disable; - lib_ring_buffer_align_ctx(ctx, lttng_alignof(migratable)); - chan->ops->event_write(ctx, &migratable, sizeof(migratable)); + chan->ops->event_write(ctx, &migratable, sizeof(migratable), lttng_alignof(migratable)); } static diff --git a/src/lttng-context-mnt-ns.c b/src/lttng-context-mnt-ns.c index 030a7f25..7853c94b 100644 --- a/src/lttng-context-mnt-ns.c +++ b/src/lttng-context-mnt-ns.c @@ -52,8 +52,7 @@ void mnt_ns_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, if (current->nsproxy) mnt_ns_inum = current->nsproxy->mnt_ns->lttng_ns_inum; - lib_ring_buffer_align_ctx(ctx, lttng_alignof(mnt_ns_inum)); - chan->ops->event_write(ctx, &mnt_ns_inum, sizeof(mnt_ns_inum)); + chan->ops->event_write(ctx, &mnt_ns_inum, sizeof(mnt_ns_inum), lttng_alignof(mnt_ns_inum)); } static diff --git a/src/lttng-context-need-reschedule.c b/src/lttng-context-need-reschedule.c index 42cf11db..0ccbfc78 100644 --- a/src/lttng-context-need-reschedule.c +++ b/src/lttng-context-need-reschedule.c @@ -34,8 +34,7 @@ void need_reschedule_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx { uint8_t need_reschedule = test_tsk_need_resched(current); - lib_ring_buffer_align_ctx(ctx, lttng_alignof(need_reschedule)); - chan->ops->event_write(ctx, &need_reschedule, sizeof(need_reschedule)); + chan->ops->event_write(ctx, &need_reschedule, sizeof(need_reschedule), lttng_alignof(need_reschedule)); } static diff --git a/src/lttng-context-net-ns.c b/src/lttng-context-net-ns.c index 1262178b..2d8994af 100644 --- a/src/lttng-context-net-ns.c +++ b/src/lttng-context-net-ns.c @@ -51,8 +51,7 @@ void net_ns_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, if (current->nsproxy) net_ns_inum = current->nsproxy->net_ns->lttng_ns_inum; - lib_ring_buffer_align_ctx(ctx, lttng_alignof(net_ns_inum)); - chan->ops->event_write(ctx, &net_ns_inum, sizeof(net_ns_inum)); + chan->ops->event_write(ctx, &net_ns_inum, sizeof(net_ns_inum), lttng_alignof(net_ns_inum)); } static diff --git a/src/lttng-context-nice.c b/src/lttng-context-nice.c index a6847705..91feb8d1 100644 --- a/src/lttng-context-nice.c +++ b/src/lttng-context-nice.c @@ -34,8 +34,7 @@ void nice_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, int nice; nice = task_nice(current); - lib_ring_buffer_align_ctx(ctx, lttng_alignof(nice)); - chan->ops->event_write(ctx, &nice, sizeof(nice)); + chan->ops->event_write(ctx, &nice, sizeof(nice), lttng_alignof(nice)); } static diff --git a/src/lttng-context-perf-counters.c b/src/lttng-context-perf-counters.c index 0b466363..b0227d47 100644 --- a/src/lttng-context-perf-counters.c +++ b/src/lttng-context-perf-counters.c @@ -57,8 +57,7 @@ void perf_counter_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, */ value = 0; } - lib_ring_buffer_align_ctx(ctx, lttng_alignof(value)); - chan->ops->event_write(ctx, &value, sizeof(value)); + chan->ops->event_write(ctx, &value, sizeof(value), lttng_alignof(value)); } #if defined(CONFIG_PERF_EVENTS) && (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,1,0)) diff --git a/src/lttng-context-pid-ns.c b/src/lttng-context-pid-ns.c index f99fec9a..fdf91bb8 100644 --- a/src/lttng-context-pid-ns.c +++ b/src/lttng-context-pid-ns.c @@ -51,8 +51,7 @@ void pid_ns_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, if (ns) pid_ns_inum = ns->lttng_ns_inum; - lib_ring_buffer_align_ctx(ctx, lttng_alignof(pid_ns_inum)); - chan->ops->event_write(ctx, &pid_ns_inum, sizeof(pid_ns_inum)); + chan->ops->event_write(ctx, &pid_ns_inum, sizeof(pid_ns_inum), lttng_alignof(pid_ns_inum)); } static diff --git a/src/lttng-context-pid.c b/src/lttng-context-pid.c index 5bf9dfd1..5bcbe00c 100644 --- a/src/lttng-context-pid.c +++ b/src/lttng-context-pid.c @@ -34,8 +34,7 @@ void pid_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, pid_t pid; pid = task_tgid_nr(current); - lib_ring_buffer_align_ctx(ctx, lttng_alignof(pid)); - chan->ops->event_write(ctx, &pid, sizeof(pid)); + chan->ops->event_write(ctx, &pid, sizeof(pid), lttng_alignof(pid)); } static diff --git a/src/lttng-context-ppid.c b/src/lttng-context-ppid.c index 8d359390..1286c376 100644 --- a/src/lttng-context-ppid.c +++ b/src/lttng-context-ppid.c @@ -44,8 +44,7 @@ void ppid_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, rcu_read_lock(); ppid = task_tgid_nr(current->real_parent); rcu_read_unlock(); - lib_ring_buffer_align_ctx(ctx, lttng_alignof(ppid)); - chan->ops->event_write(ctx, &ppid, sizeof(ppid)); + chan->ops->event_write(ctx, &ppid, sizeof(ppid), lttng_alignof(ppid)); } static diff --git a/src/lttng-context-preemptible.c b/src/lttng-context-preemptible.c index 548e79f4..11c15792 100644 --- a/src/lttng-context-preemptible.c +++ b/src/lttng-context-preemptible.c @@ -46,8 +46,7 @@ void preemptible_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, WARN_ON_ONCE(pc < LTTNG_PREEMPT_DISABLE_NESTING); if (pc == LTTNG_PREEMPT_DISABLE_NESTING) preemptible = 1; - lib_ring_buffer_align_ctx(ctx, lttng_alignof(preemptible)); - chan->ops->event_write(ctx, &preemptible, sizeof(preemptible)); + chan->ops->event_write(ctx, &preemptible, sizeof(preemptible), lttng_alignof(preemptible)); } static diff --git a/src/lttng-context-prio.c b/src/lttng-context-prio.c index 27a0ab8a..ea1a5ea6 100644 --- a/src/lttng-context-prio.c +++ b/src/lttng-context-prio.c @@ -61,8 +61,7 @@ void prio_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, int prio; prio = wrapper_task_prio_sym(current); - lib_ring_buffer_align_ctx(ctx, lttng_alignof(prio)); - chan->ops->event_write(ctx, &prio, sizeof(prio)); + chan->ops->event_write(ctx, &prio, sizeof(prio), lttng_alignof(prio)); } static diff --git a/src/lttng-context-procname.c b/src/lttng-context-procname.c index aaefef84..a2e07453 100644 --- a/src/lttng-context-procname.c +++ b/src/lttng-context-procname.c @@ -37,7 +37,7 @@ void procname_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, struct lttng_kernel_ring_buffer_ctx *ctx, struct lttng_kernel_channel_buffer *chan) { - chan->ops->event_write(ctx, current->comm, sizeof(current->comm)); + chan->ops->event_write(ctx, current->comm, sizeof(current->comm), 1); } static diff --git a/src/lttng-context-sgid.c b/src/lttng-context-sgid.c index bffe9308..dde6f713 100644 --- a/src/lttng-context-sgid.c +++ b/src/lttng-context-sgid.c @@ -36,8 +36,7 @@ void sgid_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, gid_t sgid; sgid = lttng_current_sgid(); - lib_ring_buffer_align_ctx(ctx, lttng_alignof(sgid)); - chan->ops->event_write(ctx, &sgid, sizeof(sgid)); + chan->ops->event_write(ctx, &sgid, sizeof(sgid), lttng_alignof(sgid)); } static diff --git a/src/lttng-context-suid.c b/src/lttng-context-suid.c index 37ef7c3b..214de9ac 100644 --- a/src/lttng-context-suid.c +++ b/src/lttng-context-suid.c @@ -36,8 +36,7 @@ void suid_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, uid_t suid; suid = lttng_current_suid(); - lib_ring_buffer_align_ctx(ctx, lttng_alignof(suid)); - chan->ops->event_write(ctx, &suid, sizeof(suid)); + chan->ops->event_write(ctx, &suid, sizeof(suid), lttng_alignof(suid)); } static diff --git a/src/lttng-context-tid.c b/src/lttng-context-tid.c index 538a2a58..5ca7346c 100644 --- a/src/lttng-context-tid.c +++ b/src/lttng-context-tid.c @@ -34,8 +34,7 @@ void tid_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, pid_t tid; tid = task_pid_nr(current); - lib_ring_buffer_align_ctx(ctx, lttng_alignof(tid)); - chan->ops->event_write(ctx, &tid, sizeof(tid)); + chan->ops->event_write(ctx, &tid, sizeof(tid), lttng_alignof(tid)); } static diff --git a/src/lttng-context-time-ns.c b/src/lttng-context-time-ns.c index 72f0f1c4..fe29e206 100644 --- a/src/lttng-context-time-ns.c +++ b/src/lttng-context-time-ns.c @@ -50,8 +50,7 @@ void time_ns_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, if (current->nsproxy) time_ns_inum = current->nsproxy->time_ns->lttng_ns_inum; - lib_ring_buffer_align_ctx(ctx, lttng_alignof(time_ns_inum)); - chan->ops->event_write(ctx, &time_ns_inum, sizeof(time_ns_inum)); + chan->ops->event_write(ctx, &time_ns_inum, sizeof(time_ns_inum), lttng_alignof(time_ns_inum)); } static diff --git a/src/lttng-context-uid.c b/src/lttng-context-uid.c index 0bdc2ece..b4b5b6ce 100644 --- a/src/lttng-context-uid.c +++ b/src/lttng-context-uid.c @@ -36,8 +36,7 @@ void uid_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, uid_t uid; uid = lttng_current_uid(); - lib_ring_buffer_align_ctx(ctx, lttng_alignof(uid)); - chan->ops->event_write(ctx, &uid, sizeof(uid)); + chan->ops->event_write(ctx, &uid, sizeof(uid), lttng_alignof(uid)); } static diff --git a/src/lttng-context-user-ns.c b/src/lttng-context-user-ns.c index b497754b..b921f2aa 100644 --- a/src/lttng-context-user-ns.c +++ b/src/lttng-context-user-ns.c @@ -43,8 +43,7 @@ void user_ns_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, if (current_user_ns()) user_ns_inum = current_user_ns()->lttng_ns_inum; - lib_ring_buffer_align_ctx(ctx, lttng_alignof(user_ns_inum)); - chan->ops->event_write(ctx, &user_ns_inum, sizeof(user_ns_inum)); + chan->ops->event_write(ctx, &user_ns_inum, sizeof(user_ns_inum), lttng_alignof(user_ns_inum)); } static diff --git a/src/lttng-context-uts-ns.c b/src/lttng-context-uts-ns.c index afa61ab9..1c34ae21 100644 --- a/src/lttng-context-uts-ns.c +++ b/src/lttng-context-uts-ns.c @@ -50,8 +50,7 @@ void uts_ns_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, if (current->nsproxy) uts_ns_inum = current->nsproxy->uts_ns->lttng_ns_inum; - lib_ring_buffer_align_ctx(ctx, lttng_alignof(uts_ns_inum)); - chan->ops->event_write(ctx, &uts_ns_inum, sizeof(uts_ns_inum)); + chan->ops->event_write(ctx, &uts_ns_inum, sizeof(uts_ns_inum), lttng_alignof(uts_ns_inum)); } static diff --git a/src/lttng-context-vegid.c b/src/lttng-context-vegid.c index 9abd29b8..6aee7cbc 100644 --- a/src/lttng-context-vegid.c +++ b/src/lttng-context-vegid.c @@ -36,8 +36,7 @@ void vegid_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, gid_t vegid; vegid = lttng_current_vegid(); - lib_ring_buffer_align_ctx(ctx, lttng_alignof(vegid)); - chan->ops->event_write(ctx, &vegid, sizeof(vegid)); + chan->ops->event_write(ctx, &vegid, sizeof(vegid), lttng_alignof(vegid)); } static diff --git a/src/lttng-context-veuid.c b/src/lttng-context-veuid.c index 9113578e..30ace857 100644 --- a/src/lttng-context-veuid.c +++ b/src/lttng-context-veuid.c @@ -36,8 +36,7 @@ void veuid_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, uid_t veuid; veuid = lttng_current_veuid(); - lib_ring_buffer_align_ctx(ctx, lttng_alignof(veuid)); - chan->ops->event_write(ctx, &veuid, sizeof(veuid)); + chan->ops->event_write(ctx, &veuid, sizeof(veuid), lttng_alignof(veuid)); } static diff --git a/src/lttng-context-vgid.c b/src/lttng-context-vgid.c index 0b7516e2..eb05d30a 100644 --- a/src/lttng-context-vgid.c +++ b/src/lttng-context-vgid.c @@ -36,8 +36,7 @@ void vgid_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, gid_t vgid; vgid = lttng_current_vgid(); - lib_ring_buffer_align_ctx(ctx, lttng_alignof(vgid)); - chan->ops->event_write(ctx, &vgid, sizeof(vgid)); + chan->ops->event_write(ctx, &vgid, sizeof(vgid), lttng_alignof(vgid)); } static diff --git a/src/lttng-context-vpid.c b/src/lttng-context-vpid.c index f631f6e0..3aff90f4 100644 --- a/src/lttng-context-vpid.c +++ b/src/lttng-context-vpid.c @@ -40,8 +40,7 @@ void vpid_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, vpid = 0; else vpid = task_tgid_vnr(current); - lib_ring_buffer_align_ctx(ctx, lttng_alignof(vpid)); - chan->ops->event_write(ctx, &vpid, sizeof(vpid)); + chan->ops->event_write(ctx, &vpid, sizeof(vpid), lttng_alignof(vpid)); } static diff --git a/src/lttng-context-vppid.c b/src/lttng-context-vppid.c index d6823643..55a84c2e 100644 --- a/src/lttng-context-vppid.c +++ b/src/lttng-context-vppid.c @@ -55,8 +55,7 @@ void vppid_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, else vppid = task_tgid_vnr(parent); rcu_read_unlock(); - lib_ring_buffer_align_ctx(ctx, lttng_alignof(vppid)); - chan->ops->event_write(ctx, &vppid, sizeof(vppid)); + chan->ops->event_write(ctx, &vppid, sizeof(vppid), lttng_alignof(vppid)); } static diff --git a/src/lttng-context-vsgid.c b/src/lttng-context-vsgid.c index 09c5c139..08ee829b 100644 --- a/src/lttng-context-vsgid.c +++ b/src/lttng-context-vsgid.c @@ -36,8 +36,7 @@ void vsgid_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, gid_t vsgid; vsgid = lttng_current_vsgid(); - lib_ring_buffer_align_ctx(ctx, lttng_alignof(vsgid)); - chan->ops->event_write(ctx, &vsgid, sizeof(vsgid)); + chan->ops->event_write(ctx, &vsgid, sizeof(vsgid), lttng_alignof(vsgid)); } static diff --git a/src/lttng-context-vsuid.c b/src/lttng-context-vsuid.c index 0f748983..36d562d1 100644 --- a/src/lttng-context-vsuid.c +++ b/src/lttng-context-vsuid.c @@ -36,8 +36,7 @@ void vsuid_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, uid_t vsuid; vsuid = lttng_current_vsuid(); - lib_ring_buffer_align_ctx(ctx, lttng_alignof(vsuid)); - chan->ops->event_write(ctx, &vsuid, sizeof(vsuid)); + chan->ops->event_write(ctx, &vsuid, sizeof(vsuid), lttng_alignof(vsuid)); } static diff --git a/src/lttng-context-vtid.c b/src/lttng-context-vtid.c index f4273463..9f1a399a 100644 --- a/src/lttng-context-vtid.c +++ b/src/lttng-context-vtid.c @@ -40,8 +40,7 @@ void vtid_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, vtid = 0; else vtid = task_pid_vnr(current); - lib_ring_buffer_align_ctx(ctx, lttng_alignof(vtid)); - chan->ops->event_write(ctx, &vtid, sizeof(vtid)); + chan->ops->event_write(ctx, &vtid, sizeof(vtid), lttng_alignof(vtid)); } static diff --git a/src/lttng-context-vuid.c b/src/lttng-context-vuid.c index 817800e4..9ffc2cdf 100644 --- a/src/lttng-context-vuid.c +++ b/src/lttng-context-vuid.c @@ -36,8 +36,7 @@ void vuid_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, uid_t vuid; vuid = lttng_current_vuid(); - lib_ring_buffer_align_ctx(ctx, lttng_alignof(vuid)); - chan->ops->event_write(ctx, &vuid, sizeof(vuid)); + chan->ops->event_write(ctx, &vuid, sizeof(vuid), lttng_alignof(vuid)); } static diff --git a/src/lttng-event-notifier-notification.c b/src/lttng-event-notifier-notification.c index 1e4aa777..811dc50a 100644 --- a/src/lttng-event-notifier-notification.c +++ b/src/lttng-event-notifier-notification.c @@ -408,18 +408,16 @@ void notification_send(struct lttng_event_notifier_notification *notif, return; } - lib_ring_buffer_align_ctx(&ctx, lttng_alignof(kernel_notif)); - /* Write the notif structure. */ event_notifier_group->ops->event_write(&ctx, &kernel_notif, - sizeof(kernel_notif)); + sizeof(kernel_notif), lttng_alignof(kernel_notif)); /* * Write the capture buffer. No need to realigned as the below is a raw * char* buffer. */ event_notifier_group->ops->event_write(&ctx, ¬if->capture_buf, - capture_buffer_content_len); + capture_buffer_content_len, 1); event_notifier_group->ops->event_commit(&ctx); irq_work_queue(&event_notifier_group->wakeup_pending); diff --git a/src/lttng-events.c b/src/lttng-events.c index 8d2bf469..89257bd6 100644 --- a/src/lttng-events.c +++ b/src/lttng-events.c @@ -2924,7 +2924,7 @@ int lttng_metadata_output_channel(struct lttng_metadata_stream *stream, } stream->transport->ops.event_write(&ctx, stream->metadata_cache->data + stream->metadata_in, - reserve_len); + reserve_len, 1); stream->transport->ops.event_commit(&ctx); stream->metadata_in += reserve_len; if (reserve_len < len) diff --git a/src/lttng-ring-buffer-client.h b/src/lttng-ring-buffer-client.h index 2eee81a1..f3c19358 100644 --- a/src/lttng-ring-buffer-client.h +++ b/src/lttng-ring-buffer-client.h @@ -657,15 +657,17 @@ void lttng_event_commit(struct lttng_kernel_ring_buffer_ctx *ctx) static void lttng_event_write(struct lttng_kernel_ring_buffer_ctx *ctx, const void *src, - size_t len) + size_t len, size_t alignment) { + lib_ring_buffer_align_ctx(ctx, alignment); lib_ring_buffer_write(&client_config, ctx, src, len); } static void lttng_event_write_from_user(struct lttng_kernel_ring_buffer_ctx *ctx, - const void __user *src, size_t len) + const void __user *src, size_t len, size_t alignment) { + lib_ring_buffer_align_ctx(ctx, alignment); lib_ring_buffer_copy_from_user_inatomic(&client_config, ctx, src, len); } diff --git a/src/lttng-ring-buffer-event-notifier-client.h b/src/lttng-ring-buffer-event-notifier-client.h index 17f9791a..ccd3a020 100644 --- a/src/lttng-ring-buffer-event-notifier-client.h +++ b/src/lttng-ring-buffer-event-notifier-client.h @@ -328,15 +328,17 @@ void lttng_event_commit(struct lttng_kernel_ring_buffer_ctx *ctx) static void lttng_event_write(struct lttng_kernel_ring_buffer_ctx *ctx, const void *src, - size_t len) + size_t len, size_t alignment) { + lib_ring_buffer_align_ctx(ctx, alignment); lib_ring_buffer_write(&client_config, ctx, src, len); } static void lttng_event_write_from_user(struct lttng_kernel_ring_buffer_ctx *ctx, - const void __user *src, size_t len) + const void __user *src, size_t len, size_t alignment) { + lib_ring_buffer_align_ctx(ctx, alignment); lib_ring_buffer_copy_from_user_inatomic(&client_config, ctx, src, len); } diff --git a/src/lttng-ring-buffer-metadata-client.h b/src/lttng-ring-buffer-metadata-client.h index 6c7f64c2..bd2ca475 100644 --- a/src/lttng-ring-buffer-metadata-client.h +++ b/src/lttng-ring-buffer-metadata-client.h @@ -326,15 +326,17 @@ void lttng_event_commit(struct lttng_kernel_ring_buffer_ctx *ctx) static void lttng_event_write(struct lttng_kernel_ring_buffer_ctx *ctx, const void *src, - size_t len) + size_t len, size_t alignment) { + lib_ring_buffer_align_ctx(ctx, alignment); lib_ring_buffer_write(&client_config, ctx, src, len); } static void lttng_event_write_from_user(struct lttng_kernel_ring_buffer_ctx *ctx, - const void __user *src, size_t len) + const void __user *src, size_t len, size_t alignment) { + lib_ring_buffer_align_ctx(ctx, alignment); lib_ring_buffer_copy_from_user_inatomic(&client_config, ctx, src, len); } diff --git a/src/probes/lttng-kprobes.c b/src/probes/lttng-kprobes.c index a279b19d..12de611a 100644 --- a/src/probes/lttng-kprobes.c +++ b/src/probes/lttng-kprobes.c @@ -68,8 +68,7 @@ int lttng_kprobes_event_handler_pre(struct kprobe *p, struct pt_regs *regs) ret = chan->ops->event_reserve(&ctx); if (ret < 0) return 0; - lib_ring_buffer_align_ctx(&ctx, lttng_alignof(data)); - chan->ops->event_write(&ctx, &data, sizeof(data)); + chan->ops->event_write(&ctx, &data, sizeof(data), lttng_alignof(data)); chan->ops->event_commit(&ctx); break; } diff --git a/src/probes/lttng-kretprobes.c b/src/probes/lttng-kretprobes.c index e939a0ae..0fa6a1bf 100644 --- a/src/probes/lttng-kretprobes.c +++ b/src/probes/lttng-kretprobes.c @@ -86,8 +86,7 @@ int _lttng_kretprobes_handler(struct kretprobe_instance *krpi, ret = chan->ops->event_reserve(&ctx); if (ret < 0) return 0; - lib_ring_buffer_align_ctx(&ctx, lttng_alignof(payload)); - chan->ops->event_write(&ctx, &payload, sizeof(payload)); + chan->ops->event_write(&ctx, &payload, sizeof(payload), lttng_alignof(payload)); chan->ops->event_commit(&ctx); break; } diff --git a/src/probes/lttng-uprobes.c b/src/probes/lttng-uprobes.c index efb879be..fed3a1d5 100644 --- a/src/probes/lttng-uprobes.c +++ b/src/probes/lttng-uprobes.c @@ -78,8 +78,7 @@ int lttng_uprobes_event_handler_pre(struct uprobe_consumer *uc, struct pt_regs * /* Event payload. */ payload.ip = (unsigned long)instruction_pointer(regs); - lib_ring_buffer_align_ctx(&ctx, lttng_alignof(payload)); - chan->ops->event_write(&ctx, &payload, sizeof(payload)); + chan->ops->event_write(&ctx, &payload, sizeof(payload), lttng_alignof(payload)); chan->ops->event_commit(&ctx); break; }