*/
#include "../../wrapper/ringbuffer/frontend.h"
+#include "../../wrapper/percpu-defs.h"
#include <linux/errno.h>
#include <linux/prefetch.h>
void lib_ring_buffer_put_cpu(const struct lib_ring_buffer_config *config)
{
barrier();
- __get_cpu_var(lib_ring_buffer_nesting)--;
+ (*lttng_this_cpu_ptr(&lib_ring_buffer_nesting))--;
rcu_read_unlock_sched_notrace();
}
#include "../../wrapper/ringbuffer/iterator.h"
#include "../../wrapper/ringbuffer/nohz.h"
#include "../../wrapper/atomic.h"
+#include "../../wrapper/percpu-defs.h"
/*
* Internal structure representing offsets to use at a sub-buffer switch.
raw_spin_unlock(&buf->raw_tick_nohz_spinlock);
break;
case TICK_NOHZ_STOP:
- spin_lock(&__get_cpu_var(ring_buffer_nohz_lock));
+ spin_lock(lttng_this_cpu_ptr(&ring_buffer_nohz_lock));
lib_ring_buffer_stop_switch_timer(buf);
lib_ring_buffer_stop_read_timer(buf);
- spin_unlock(&__get_cpu_var(ring_buffer_nohz_lock));
+ spin_unlock(lttng_this_cpu_ptr(&ring_buffer_nohz_lock));
break;
case TICK_NOHZ_RESTART:
- spin_lock(&__get_cpu_var(ring_buffer_nohz_lock));
+ spin_lock(lttng_this_cpu_ptr(&ring_buffer_nohz_lock));
lib_ring_buffer_start_read_timer(buf);
lib_ring_buffer_start_switch_timer(buf);
- spin_unlock(&__get_cpu_var(ring_buffer_nohz_lock));
+ spin_unlock(lttng_this_cpu_ptr(&ring_buffer_nohz_lock));
break;
}
--- /dev/null
+#ifndef _LTTNG_WRAPPER_PERCPU_DEFS_H
+#define _LTTNG_WRAPPER_PERCPU_DEFS_H
+
+/*
+ * wrapper/percpu-defs.h
+ *
+ * wrapper around linux/percpu-defs.h.
+ *
+ * Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/version.h>
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
+
+#include <linux/percpu-defs.h>
+
+#define lttng_this_cpu_ptr(ptr) this_cpu_ptr(ptr)
+
+#else /* #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0) */
+
+#include <linux/percpu.h>
+
+#define lttng_this_cpu_ptr(ptr) (&__get_cpu_var(*(ptr)))
+
+#endif /* #else #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0) */
+
+#endif /* _LTTNG_WRAPPER_PERCPU_DEFS_H */
#include <linux/version.h>
#include <asm/local.h>
#include "../lttng-kernel-version.h"
+#include "percpu-defs.h"
#include "random.h"
#if LTTNG_KERNEL_RANGE(3,10,0, 3,10,14) || LTTNG_KERNEL_RANGE(3,11,0, 3,11,3)
local_t *last_tsc;
/* Use fast nmi-safe monotonic clock provided by the Linux kernel. */
- last_tsc = &__get_cpu_var(lttng_last_tsc);
+ last_tsc = lttng_this_cpu_ptr(<tng_last_tsc);
last = local_read(last_tsc);
/*
* Read "last" before "now". It is not strictly required, but it ensures