Skip to content

Commit

Permalink
Update for kernel 5.7: use vmalloc_sync_mappings on kernels >= 5.7
Browse files Browse the repository at this point in the history
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  • Loading branch information
compudj committed May 8, 2020
1 parent e3273c9 commit da0fcb1
Show file tree
Hide file tree
Showing 31 changed files with 85 additions and 42 deletions.
4 changes: 2 additions & 2 deletions lib/ringbuffer/ring_buffer_backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <linux/vmalloc.h>

#include <wrapper/mm.h>
#include <wrapper/vmalloc.h> /* for wrapper_vmalloc_sync_all() */
#include <wrapper/vmalloc.h> /* for wrapper_vmalloc_sync_mappings() */
#include <wrapper/ringbuffer/config.h>
#include <wrapper/ringbuffer/backend.h>
#include <wrapper/ringbuffer/frontend.h>
Expand Down Expand Up @@ -156,7 +156,7 @@ int lib_ring_buffer_backend_allocate(const struct lib_ring_buffer_config *config
* If kmalloc ever uses vmalloc underneath, make sure the buffer pages
* will not fault.
*/
wrapper_vmalloc_sync_all();
wrapper_vmalloc_sync_mappings();
wrapper_clear_current_oom_origin();
vfree(pages);
return 0;
Expand Down
4 changes: 2 additions & 2 deletions lttng-abi.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <linux/uaccess.h>
#include <linux/slab.h>
#include <linux/err.h>
#include <wrapper/vmalloc.h> /* for wrapper_vmalloc_sync_all() */
#include <wrapper/vmalloc.h> /* for wrapper_vmalloc_sync_mappings() */
#include <wrapper/ringbuffer/vfs.h>
#include <wrapper/ringbuffer/backend.h>
#include <wrapper/ringbuffer/frontend.h>
Expand Down Expand Up @@ -1832,7 +1832,7 @@ int __init lttng_abi_init(void)
{
int ret = 0;

wrapper_vmalloc_sync_all();
wrapper_vmalloc_sync_mappings();
lttng_clock_ref();

ret = lttng_tp_mempool_init();
Expand Down
2 changes: 1 addition & 1 deletion lttng-context-callstack.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ int __lttng_add_callstack_generic(struct lttng_ctx **ctx,
field->record = lttng_callstack_record;
field->priv = fdata;
field->destroy = lttng_callstack_destroy;
wrapper_vmalloc_sync_all();
wrapper_vmalloc_sync_mappings();
return 0;

error_create:
Expand Down
2 changes: 1 addition & 1 deletion lttng-context-cpu-id.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int lttng_add_cpu_id_to_ctx(struct lttng_ctx **ctx)
field->record = cpu_id_record;
field->get_value = cpu_id_get_value;
lttng_context_update(*ctx);
wrapper_vmalloc_sync_all();
wrapper_vmalloc_sync_mappings();
return 0;
}
EXPORT_SYMBOL_GPL(lttng_add_cpu_id_to_ctx);
2 changes: 1 addition & 1 deletion lttng-context-hostname.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ int lttng_add_hostname_to_ctx(struct lttng_ctx **ctx)
field->record = hostname_record;
field->get_value = hostname_get_value;
lttng_context_update(*ctx);
wrapper_vmalloc_sync_all();
wrapper_vmalloc_sync_mappings();
return 0;
}
EXPORT_SYMBOL_GPL(lttng_add_hostname_to_ctx);
2 changes: 1 addition & 1 deletion lttng-context-interruptible.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ int lttng_add_interruptible_to_ctx(struct lttng_ctx **ctx)
field->record = interruptible_record;
field->get_value = interruptible_get_value;
lttng_context_update(*ctx);
wrapper_vmalloc_sync_all();
wrapper_vmalloc_sync_mappings();
return 0;
}
EXPORT_SYMBOL_GPL(lttng_add_interruptible_to_ctx);
2 changes: 1 addition & 1 deletion lttng-context-migratable.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int lttng_add_migratable_to_ctx(struct lttng_ctx **ctx)
field->record = migratable_record;
field->get_value = migratable_get_value;
lttng_context_update(*ctx);
wrapper_vmalloc_sync_all();
wrapper_vmalloc_sync_mappings();
return 0;
}
EXPORT_SYMBOL_GPL(lttng_add_migratable_to_ctx);
2 changes: 1 addition & 1 deletion lttng-context-need-reschedule.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int lttng_add_need_reschedule_to_ctx(struct lttng_ctx **ctx)
field->record = need_reschedule_record;
field->get_value = need_reschedule_get_value;
lttng_context_update(*ctx);
wrapper_vmalloc_sync_all();
wrapper_vmalloc_sync_mappings();
return 0;
}
EXPORT_SYMBOL_GPL(lttng_add_need_reschedule_to_ctx);
2 changes: 1 addition & 1 deletion lttng-context-nice.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int lttng_add_nice_to_ctx(struct lttng_ctx **ctx)
field->record = nice_record;
field->get_value = nice_get_value;
lttng_context_update(*ctx);
wrapper_vmalloc_sync_all();
wrapper_vmalloc_sync_mappings();
return 0;
}
EXPORT_SYMBOL_GPL(lttng_add_nice_to_ctx);
2 changes: 1 addition & 1 deletion lttng-context-perf-counters.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ int lttng_add_perf_counter_to_ctx(uint32_t type,
field->u.perf_counter = perf_field;
lttng_context_update(*ctx);

wrapper_vmalloc_sync_all();
wrapper_vmalloc_sync_mappings();
return 0;

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0))
Expand Down
2 changes: 1 addition & 1 deletion lttng-context-pid.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int lttng_add_pid_to_ctx(struct lttng_ctx **ctx)
field->record = pid_record;
field->get_value = pid_get_value;
lttng_context_update(*ctx);
wrapper_vmalloc_sync_all();
wrapper_vmalloc_sync_mappings();
return 0;
}
EXPORT_SYMBOL_GPL(lttng_add_pid_to_ctx);
2 changes: 1 addition & 1 deletion lttng-context-ppid.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ int lttng_add_ppid_to_ctx(struct lttng_ctx **ctx)
field->record = ppid_record;
field->get_value = ppid_get_value;
lttng_context_update(*ctx);
wrapper_vmalloc_sync_all();
wrapper_vmalloc_sync_mappings();
return 0;
}
EXPORT_SYMBOL_GPL(lttng_add_ppid_to_ctx);
2 changes: 1 addition & 1 deletion lttng-context-preemptible.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ int lttng_add_preemptible_to_ctx(struct lttng_ctx **ctx)
field->record = preemptible_record;
field->get_value = preemptible_get_value;
lttng_context_update(*ctx);
wrapper_vmalloc_sync_all();
wrapper_vmalloc_sync_mappings();
return 0;
}
EXPORT_SYMBOL_GPL(lttng_add_preemptible_to_ctx);
2 changes: 1 addition & 1 deletion lttng-context-prio.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ int lttng_add_prio_to_ctx(struct lttng_ctx **ctx)
field->record = prio_record;
field->get_value = prio_get_value;
lttng_context_update(*ctx);
wrapper_vmalloc_sync_all();
wrapper_vmalloc_sync_mappings();
return 0;
}
EXPORT_SYMBOL_GPL(lttng_add_prio_to_ctx);
2 changes: 1 addition & 1 deletion lttng-context-procname.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ int lttng_add_procname_to_ctx(struct lttng_ctx **ctx)
field->record = procname_record;
field->get_value = procname_get_value;
lttng_context_update(*ctx);
wrapper_vmalloc_sync_all();
wrapper_vmalloc_sync_mappings();
return 0;
}
EXPORT_SYMBOL_GPL(lttng_add_procname_to_ctx);
2 changes: 1 addition & 1 deletion lttng-context-tid.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ int lttng_add_tid_to_ctx(struct lttng_ctx **ctx)
field->record = tid_record;
field->get_value = tid_get_value;
lttng_context_update(*ctx);
wrapper_vmalloc_sync_all();
wrapper_vmalloc_sync_mappings();
return 0;
}
EXPORT_SYMBOL_GPL(lttng_add_tid_to_ctx);
2 changes: 1 addition & 1 deletion lttng-context-vpid.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ int lttng_add_vpid_to_ctx(struct lttng_ctx **ctx)
field->record = vpid_record;
field->get_value = vpid_get_value;
lttng_context_update(*ctx);
wrapper_vmalloc_sync_all();
wrapper_vmalloc_sync_mappings();
return 0;
}
EXPORT_SYMBOL_GPL(lttng_add_vpid_to_ctx);
2 changes: 1 addition & 1 deletion lttng-context-vppid.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ int lttng_add_vppid_to_ctx(struct lttng_ctx **ctx)
field->record = vppid_record;
field->get_value = vppid_get_value;
lttng_context_update(*ctx);
wrapper_vmalloc_sync_all();
wrapper_vmalloc_sync_mappings();
return 0;
}
EXPORT_SYMBOL_GPL(lttng_add_vppid_to_ctx);
2 changes: 1 addition & 1 deletion lttng-context-vtid.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx)
field->record = vtid_record;
field->get_value = vtid_get_value;
lttng_context_update(*ctx);
wrapper_vmalloc_sync_all();
wrapper_vmalloc_sync_mappings();
return 0;
}
EXPORT_SYMBOL_GPL(lttng_add_vtid_to_ctx);
2 changes: 1 addition & 1 deletion lttng-context.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <linux/list.h>
#include <linux/mutex.h>
#include <linux/slab.h>
#include <wrapper/vmalloc.h> /* for wrapper_vmalloc_sync_all() */
#include <wrapper/vmalloc.h> /* for wrapper_vmalloc_sync_mappings() */
#include <lttng-events.h>
#include <lttng-tracer.h>

Expand Down
10 changes: 5 additions & 5 deletions lttng-events.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <linux/uuid.h>

#include <wrapper/uuid.h>
#include <wrapper/vmalloc.h> /* for wrapper_vmalloc_sync_all() */
#include <wrapper/vmalloc.h> /* for wrapper_vmalloc_sync_mappings() */
#include <wrapper/random.h>
#include <wrapper/tracepoint.h>
#include <wrapper/list.h>
Expand Down Expand Up @@ -2707,19 +2707,19 @@ int _lttng_session_metadata_statedump(struct lttng_session *session)
* Registers a transport which can be used as output to extract the data out of
* LTTng. The module calling this registration function must ensure that no
* trap-inducing code will be executed by the transport functions. E.g.
* vmalloc_sync_all() must be called between a vmalloc and the moment the memory
* vmalloc_sync_mappings() must be called between a vmalloc and the moment the memory
* is made visible to the transport function. This registration acts as a
* vmalloc_sync_all. Therefore, only if the module allocates virtual memory
* vmalloc_sync_mappings. Therefore, only if the module allocates virtual memory
* after its registration must it synchronize the TLBs.
*/
void lttng_transport_register(struct lttng_transport *transport)
{
/*
* Make sure no page fault can be triggered by the module about to be
* registered. We deal with this here so we don't have to call
* vmalloc_sync_all() in each module's init.
* vmalloc_sync_mappings() in each module's init.
*/
wrapper_vmalloc_sync_all();
wrapper_vmalloc_sync_mappings();

mutex_lock(&sessions_mutex);
list_add_tail(&transport->node, &lttng_transport_list);
Expand Down
4 changes: 2 additions & 2 deletions lttng-ring-buffer-client.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <linux/module.h>
#include <linux/types.h>
#include <lib/bitfield.h>
#include <wrapper/vmalloc.h> /* for wrapper_vmalloc_sync_all() */
#include <wrapper/vmalloc.h> /* for wrapper_vmalloc_sync_mappings() */
#include <wrapper/trace-clock.h>
#include <lttng-events.h>
#include <lttng-tracer.h>
Expand Down Expand Up @@ -766,7 +766,7 @@ static int __init lttng_ring_buffer_client_init(void)
* This vmalloc sync all also takes care of the lib ring buffer
* vmalloc'd module pages when it is built as a module into LTTng.
*/
wrapper_vmalloc_sync_all();
wrapper_vmalloc_sync_mappings();
lttng_transport_register(&lttng_relay_transport);
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions lttng-ring-buffer-metadata-client.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include <linux/module.h>
#include <linux/types.h>
#include <wrapper/vmalloc.h> /* for wrapper_vmalloc_sync_all() */
#include <wrapper/vmalloc.h> /* for wrapper_vmalloc_sync_mappings() */
#include <lttng-events.h>
#include <lttng-tracer.h>

Expand Down Expand Up @@ -428,7 +428,7 @@ static int __init lttng_ring_buffer_client_init(void)
* This vmalloc sync all also takes care of the lib ring buffer
* vmalloc'd module pages when it is built as a module into LTTng.
*/
wrapper_vmalloc_sync_all();
wrapper_vmalloc_sync_mappings();
lttng_transport_register(&lttng_relay_transport);
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion lttng-syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ int lttng_syscalls_register(struct lttng_channel *chan, void *filter)
struct lttng_kernel_event ev;
int ret;

wrapper_vmalloc_sync_all();
wrapper_vmalloc_sync_mappings();

if (!chan->sc_table) {
/* create syscall table mapping syscall to events */
Expand Down
2 changes: 1 addition & 1 deletion probes/lttng-kprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ int lttng_kprobes_register(const char *name,
* Well.. kprobes itself puts the page fault handler on the blacklist,
* but we can never be too careful.
*/
wrapper_vmalloc_sync_all();
wrapper_vmalloc_sync_mappings();

ret = register_kprobe(&event->u.kprobe.kp);
if (ret)
Expand Down
2 changes: 1 addition & 1 deletion probes/lttng-kretprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ int lttng_kretprobes_register(const char *name,
* Well.. kprobes itself puts the page fault handler on the blacklist,
* but we can never be too careful.
*/
wrapper_vmalloc_sync_all();
wrapper_vmalloc_sync_mappings();

ret = register_kretprobe(&lttng_krp->krp);
if (ret)
Expand Down
4 changes: 2 additions & 2 deletions probes/lttng-tracepoint-event-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <probes/lttng.h>
#include <probes/lttng-types.h>
#include <probes/lttng-probe-user.h>
#include <wrapper/vmalloc.h> /* for wrapper_vmalloc_sync_all() */
#include <wrapper/vmalloc.h> /* for wrapper_vmalloc_sync_mappings() */
#include <wrapper/ringbuffer/frontend_types.h>
#include <wrapper/ringbuffer/backend.h>
#include <wrapper/rcu.h>
Expand Down Expand Up @@ -1352,7 +1352,7 @@ static __used struct lttng_probe_desc TP_ID(__probe_desc___, TRACE_SYSTEM) = {
#ifndef TP_MODULE_NOINIT
static int TP_ID(__lttng_events_init__, TRACE_SYSTEM)(void)
{
wrapper_vmalloc_sync_all();
wrapper_vmalloc_sync_mappings();
return lttng_probe_register(&TP_ID(__probe_desc___, TRACE_SYSTEM));
}

Expand Down
2 changes: 1 addition & 1 deletion probes/lttng-uprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ int lttng_uprobes_add_callsite(struct lttng_event *event,
}

/* Ensure the memory we just allocated don't trigger page faults. */
wrapper_vmalloc_sync_all();
wrapper_vmalloc_sync_mappings();

uprobe_handler->event = event;
uprobe_handler->up_consumer.handler = lttng_uprobes_handler_pre;
Expand Down
2 changes: 1 addition & 1 deletion probes/lttng.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ int __init lttng_logger_init(void)
{
int ret = 0;

wrapper_vmalloc_sync_all();
wrapper_vmalloc_sync_mappings();

/* /dev/lttng-logger */
ret = misc_register(&logger_dev);
Expand Down
2 changes: 1 addition & 1 deletion tests/probes/lttng-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ int __init lttng_test_init(void)
int ret = 0;

(void) wrapper_lttng_fixup_sig(THIS_MODULE);
wrapper_vmalloc_sync_all();
wrapper_vmalloc_sync_mappings();
lttng_test_filter_event_dentry =
proc_create_data(LTTNG_TEST_FILTER_EVENT_FILE,
S_IRUGO | S_IWUGO, NULL,
Expand Down

0 comments on commit da0fcb1

Please sign in to comment.