/usr/src/lttng-modules-2.5.1/lib/ringbuffer/vatomic.h is in lttng-modules-dkms 2.5.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | #ifndef _LIB_RING_BUFFER_VATOMIC_H
#define _LIB_RING_BUFFER_VATOMIC_H
/*
* lib/ringbuffer/vatomic.h
*
* Copyright (C) 2010-2012 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 <asm/atomic.h>
#include <asm/local.h>
/*
* Same data type (long) accessed differently depending on configuration.
* v field is for non-atomic access (protected by mutual exclusion).
* In the fast-path, the ring_buffer_config structure is constant, so the
* compiler can statically select the appropriate branch.
* local_t is used for per-cpu and per-thread buffers.
* atomic_long_t is used for globally shared buffers.
*/
union v_atomic {
local_t l;
atomic_long_t a;
long v;
};
static inline
long v_read(const struct lib_ring_buffer_config *config, union v_atomic *v_a)
{
if (config->sync == RING_BUFFER_SYNC_PER_CPU)
return local_read(&v_a->l);
else
return atomic_long_read(&v_a->a);
}
static inline
void v_set(const struct lib_ring_buffer_config *config, union v_atomic *v_a,
long v)
{
if (config->sync == RING_BUFFER_SYNC_PER_CPU)
local_set(&v_a->l, v);
else
atomic_long_set(&v_a->a, v);
}
static inline
void v_add(const struct lib_ring_buffer_config *config, long v, union v_atomic *v_a)
{
if (config->sync == RING_BUFFER_SYNC_PER_CPU)
local_add(v, &v_a->l);
else
atomic_long_add(v, &v_a->a);
}
static inline
void v_inc(const struct lib_ring_buffer_config *config, union v_atomic *v_a)
{
if (config->sync == RING_BUFFER_SYNC_PER_CPU)
local_inc(&v_a->l);
else
atomic_long_inc(&v_a->a);
}
/*
* Non-atomic decrement. Only used by reader, apply to reader-owned subbuffer.
*/
static inline
void _v_dec(const struct lib_ring_buffer_config *config, union v_atomic *v_a)
{
--v_a->v;
}
static inline
long v_cmpxchg(const struct lib_ring_buffer_config *config, union v_atomic *v_a,
long old, long _new)
{
if (config->sync == RING_BUFFER_SYNC_PER_CPU)
return local_cmpxchg(&v_a->l, old, _new);
else
return atomic_long_cmpxchg(&v_a->a, old, _new);
}
#endif /* _LIB_RING_BUFFER_VATOMIC_H */
|