wrapper: remove timer wrapper
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 13 Apr 2020 18:31:50 +0000 (14:31 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 13 Apr 2020 18:32:34 +0000 (14:32 -0400)
lib/ringbuffer/ring_buffer_frontend.c
wrapper/timer.h [deleted file]

index 8c9e5ef768857393e2c93c796ca4194ecb3f169a..2ca778a06ddca1dc5cadf0f0cbec00fa24713855 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/percpu.h>
 #include <linux/kref.h>
 #include <linux/percpu-defs.h>
+#include <linux/timer.h>
 #include <asm/cacheflush.h>
 
 #include <wrapper/ringbuffer/config.h>
@@ -50,7 +51,6 @@
 #include <wrapper/ringbuffer/iterator.h>
 #include <wrapper/ringbuffer/nohz.h>
 #include <wrapper/atomic.h>
-#include <wrapper/timer.h>
 
 /*
  * Internal structure representing offsets to use at a sub-buffer switch.
@@ -313,11 +313,10 @@ free_chanbuf:
        return ret;
 }
 
-static void switch_buffer_timer(LTTNG_TIMER_FUNC_ARG_TYPE t)
+static void switch_buffer_timer(struct timer_list *t)
 {
-       struct lib_ring_buffer *buf = lttng_from_timer(buf, t, switch_timer);
+       struct lib_ring_buffer *buf = from_timer(buf, t, switch_timer);
        struct channel *chan = buf->backend.chan;
-       const struct lib_ring_buffer_config *config = &chan->backend.config;
 
        /*
         * Only flush buffers periodically if readers are active.
@@ -325,12 +324,8 @@ static void switch_buffer_timer(LTTNG_TIMER_FUNC_ARG_TYPE t)
        if (atomic_long_read(&buf->active_readers))
                lib_ring_buffer_switch_slow(buf, SWITCH_ACTIVE);
 
-       if (config->alloc == RING_BUFFER_ALLOC_PER_CPU)
-               lttng_mod_timer_pinned(&buf->switch_timer,
-                                jiffies + chan->switch_timer_interval);
-       else
-               mod_timer(&buf->switch_timer,
-                         jiffies + chan->switch_timer_interval);
+       mod_timer(&buf->switch_timer,
+                 jiffies + chan->switch_timer_interval);
 }
 
 /*
@@ -346,9 +341,9 @@ static void lib_ring_buffer_start_switch_timer(struct lib_ring_buffer *buf)
                return;
 
        if (config->alloc == RING_BUFFER_ALLOC_PER_CPU)
-               flags = LTTNG_TIMER_PINNED;
+               flags = TIMER_PINNED;
 
-       lttng_timer_setup(&buf->switch_timer, switch_buffer_timer, flags, buf);
+       timer_setup(&buf->switch_timer, switch_buffer_timer, flags);
        buf->switch_timer.expires = jiffies + chan->switch_timer_interval;
 
        if (config->alloc == RING_BUFFER_ALLOC_PER_CPU)
@@ -376,9 +371,9 @@ static void lib_ring_buffer_stop_switch_timer(struct lib_ring_buffer *buf)
 /*
  * Polling timer to check the channels for data.
  */
-static void read_buffer_timer(LTTNG_TIMER_FUNC_ARG_TYPE t)
+static void read_buffer_timer(struct timer_list *t)
 {
-       struct lib_ring_buffer *buf = lttng_from_timer(buf, t, read_timer);
+       struct lib_ring_buffer *buf = from_timer(buf, t, read_timer);
        struct channel *chan = buf->backend.chan;
        const struct lib_ring_buffer_config *config = &chan->backend.config;
 
@@ -390,12 +385,8 @@ static void read_buffer_timer(LTTNG_TIMER_FUNC_ARG_TYPE t)
                wake_up_interruptible(&chan->read_wait);
        }
 
-       if (config->alloc == RING_BUFFER_ALLOC_PER_CPU)
-               lttng_mod_timer_pinned(&buf->read_timer,
-                                jiffies + chan->read_timer_interval);
-       else
-               mod_timer(&buf->read_timer,
-                         jiffies + chan->read_timer_interval);
+       mod_timer(&buf->read_timer,
+                 jiffies + chan->read_timer_interval);
 }
 
 /*
@@ -413,9 +404,9 @@ static void lib_ring_buffer_start_read_timer(struct lib_ring_buffer *buf)
                return;
 
        if (config->alloc == RING_BUFFER_ALLOC_PER_CPU)
-               flags = LTTNG_TIMER_PINNED;
+               flags = TIMER_PINNED;
 
-       lttng_timer_setup(&buf->read_timer, read_buffer_timer, flags, buf);
+       timer_setup(&buf->read_timer, read_buffer_timer, flags);
        buf->read_timer.expires = jiffies + chan->read_timer_interval;
 
        if (config->alloc == RING_BUFFER_ALLOC_PER_CPU)
diff --git a/wrapper/timer.h b/wrapper/timer.h
deleted file mode 100644 (file)
index 02f60dc..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
- *
- * wrapper/timer.h
- *
- * wrapper around linux/timer.h.
- *
- * Copyright (C) 2016 Michael Jeanson <mjeanson@efficios.com>
- */
-
-#ifndef _LTTNG_WRAPPER_TIMER_H
-#define _LTTNG_WRAPPER_TIMER_H
-
-#include <linux/version.h>
-#include <linux/timer.h>
-#include <lttng-kernel-version.h>
-
-/*
- * In the olden days, pinned timers were initialized normaly with init_timer()
- * and then modified with mod_timer_pinned().
- *
- * Then came kernel 4.8.0 and they had to be initilized as pinned with
- * init_timer_pinned() and then modified as regular timers with mod_timer().
- *
- * Then came kernel 4.15.0 with a new timer API where init_timer() is no more.
- * It's replaced by timer_setup() where pinned is now part of timer flags.
- */
-
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,15,0))
-
-#define LTTNG_TIMER_PINNED             TIMER_PINNED
-#define LTTNG_TIMER_FUNC_ARG_TYPE      struct timer_list *
-
-#define lttng_mod_timer_pinned(timer, expires) \
-       mod_timer(timer, expires)
-
-#define lttng_from_timer(var, callback_timer, timer_fieldname) \
-       from_timer(var, callback_timer, timer_fieldname)
-
-#define lttng_timer_setup(timer, callback, flags, unused) \
-       timer_setup(timer, callback, flags)
-
-
-#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,15,0) */
-
-
-# if (LTTNG_RT_VERSION_CODE >= LTTNG_RT_KERNEL_VERSION(4,6,4,8) \
-       || LINUX_VERSION_CODE >= KERNEL_VERSION(4,8,0))
-
-#define lttng_init_timer_pinned(timer) \
-       init_timer_pinned(timer)
-
-#define lttng_mod_timer_pinned(timer, expires) \
-       mod_timer(timer, expires)
-
-# else /* LTTNG_RT_VERSION_CODE >= LTTNG_RT_KERNEL_VERSION(4,6,4,8) */
-
-#define lttng_init_timer_pinned(timer) \
-       init_timer(timer)
-
-#define lttng_mod_timer_pinned(timer, expires) \
-       mod_timer_pinned(timer, expires)
-
-# endif /* LTTNG_RT_VERSION_CODE >= LTTNG_RT_KERNEL_VERSION(4,6,4,8) */
-
-
-#define LTTNG_TIMER_PINNED             TIMER_PINNED
-#define LTTNG_TIMER_FUNC_ARG_TYPE      unsigned long
-
-/* timer_fieldname is unused prior to 4.15. */
-#define lttng_from_timer(var, timer_data, timer_fieldname) \
-       ((typeof(var))timer_data)
-
-static inline void lttng_timer_setup(struct timer_list *timer,
-               void (*function)(LTTNG_TIMER_FUNC_ARG_TYPE),
-               unsigned int flags, void *data)
-{
-       if (flags & LTTNG_TIMER_PINNED)
-               lttng_init_timer_pinned(timer);
-       else
-               init_timer(timer);
-
-       timer->function = function;
-       timer->data = (unsigned long)data;
-}
-
-#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,15,0) */
-
-#endif /* _LTTNG_WRAPPER_TIMER_H */
This page took 0.029169 seconds and 4 git commands to generate.