X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=include%2Fwrapper%2Fcpu.h;fp=include%2Fwrapper%2Fcpu.h;h=cbee1962726afe149067d8e40d7dff2b5db66a67;hb=ffcc873470121ef1ebb110df3d9038a38d9cb7cb;hp=0000000000000000000000000000000000000000;hpb=7259e6a5dfc2a27cd7e8171d9b337610bbf44984;p=lttng-modules.git diff --git a/include/wrapper/cpu.h b/include/wrapper/cpu.h new file mode 100644 index 00000000..cbee1962 --- /dev/null +++ b/include/wrapper/cpu.h @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) + * + * wrapper/cpu.h + * + * Copyright (C) 2021 Michael Jeanson + */ + +#ifndef _LTTNG_WRAPPER_CPU_H +#define _LTTNG_WRAPPER_CPU_H + +#include +#include + +#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,13,0)) + +static inline +void lttng_cpus_read_lock(void) +{ + cpus_read_lock(); +} + +static inline +void lttng_cpus_read_unlock(void) +{ + cpus_read_unlock(); +} + +#else /* LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,13,0) */ + +static inline +void lttng_cpus_read_lock(void) +{ + get_online_cpus(); +} + +static inline +void lttng_cpus_read_unlock(void) +{ + put_online_cpus(); +} + +#endif /* LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,13,0) */ + +#endif /* _LTTNG_WRAPPER_CPU_H */