wrapper: remove list wrapper
[lttng-modules.git] / wrapper / rcu.h
CommitLineData
b7cdc182 1/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
9f36eaed 2 *
7a09dcb7
MD
3 * wrapper/rcu.h
4 *
5 * wrapper around linux/rcupdate.h and linux/rculist.h.
6 *
7 * Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7a09dcb7
MD
8 */
9
9f36eaed
MJ
10#ifndef _LTTNG_WRAPPER_RCU_H
11#define _LTTNG_WRAPPER_RCU_H
12
7a09dcb7
MD
13#include <linux/version.h>
14#include <linux/rculist.h>
15#include <linux/rcupdate.h>
7a09dcb7
MD
16
17#ifndef rcu_dereference_raw_notrace
18#define rcu_dereference_raw_notrace(p) rcu_dereference_raw(p)
19#endif
20
21#define lttng_rcu_dereference(p) rcu_dereference_raw_notrace(p)
22
23/**
24 * lttng_list_entry_rcu - get the struct for this entry
25 * @ptr: the &struct list_head pointer.
26 * @type: the type of the struct this is embedded in.
27 * @member: the name of the list_head within the struct.
28 *
29 * This primitive may safely run concurrently with the _rcu list-mutation
30 * primitives such as list_add_rcu() as long as it's guarded by
31 * rcu_read_lock_sched().
32 * Can be used while tracing RCU.
33 */
34#define lttng_list_entry_rcu(ptr, type, member) \
35({ \
36 typeof(*ptr) __rcu *__ptr = (typeof(*ptr) __rcu __force *)ptr; \
37 container_of((typeof(ptr))lttng_rcu_dereference(__ptr), type, member); \
38})
39
40/**
41 * lttng_list_for_each_entry_rcu - iterate over rcu list of given type
42 * @pos: the type * to use as a loop cursor.
43 * @head: the head for your list.
44 * @member: the name of the list_head within the struct.
45 *
46 * This list-traversal primitive may safely run concurrently with
47 * the _rcu list-mutation primitives such as list_add_rcu()
48 * as long as the traversal is guarded by rcu_read_lock_sched().
49 * Can be used while tracing RCU.
50 */
51#define lttng_list_for_each_entry_rcu(pos, head, member) \
52 for (pos = lttng_list_entry_rcu((head)->next, typeof(*pos), member); \
53 &pos->member != (head); \
54 pos = lttng_list_entry_rcu(pos->member.next, typeof(*pos), member))
55
7a09dcb7 56#endif /* _LTTNG_WRAPPER_RCU_H */
This page took 0.033798 seconds and 4 git commands to generate.