Commit | Line | Data |
---|---|---|
8be4c8a3 MJ |
1 | /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) |
2 | * | |
3 | * wrapper/cpu.h | |
4 | * | |
5 | * Copyright (C) 2021 Michael Jeanson <mjeanson@efficios.com> | |
6 | */ | |
7 | ||
8 | #ifndef _LTTNG_WRAPPER_CPU_H | |
9 | #define _LTTNG_WRAPPER_CPU_H | |
10 | ||
11 | #include <linux/cpu.h> | |
12 | #include <lttng/kernel-version.h> | |
13 | ||
14 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,13,0)) | |
15 | ||
16 | static inline | |
17 | void lttng_cpus_read_lock(void) | |
18 | { | |
19 | cpus_read_lock(); | |
20 | } | |
21 | ||
22 | static inline | |
23 | void lttng_cpus_read_unlock(void) | |
24 | { | |
25 | cpus_read_unlock(); | |
26 | } | |
27 | ||
28 | #else /* LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,13,0) */ | |
29 | ||
30 | static inline | |
31 | void lttng_cpus_read_lock(void) | |
32 | { | |
33 | get_online_cpus(); | |
34 | } | |
35 | ||
36 | static inline | |
37 | void lttng_cpus_read_unlock(void) | |
38 | { | |
39 | put_online_cpus(); | |
40 | } | |
41 | ||
42 | #endif /* LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,13,0) */ | |
43 | ||
44 | #endif /* _LTTNG_WRAPPER_CPU_H */ |