linux/include/linux/mmap_lock.h

#ifndef _LINUX_MMAP_LOCK_H
#define _LINUX_MMAP_LOCK_H

#include <linux/lockdep.h>
#include <linux/mm_types.h>
#include <linux/mmdebug.h>
#include <linux/rwsem.h>
#include <linux/tracepoint-defs.h>
#include <linux/types.h>

#define MMAP_LOCK_INITIALIZER(name)

DECLARE_TRACEPOINT();
DECLARE_TRACEPOINT();
DECLARE_TRACEPOINT();

#ifdef CONFIG_TRACING

void __mmap_lock_do_trace_start_locking(struct mm_struct *mm, bool write);
void __mmap_lock_do_trace_acquire_returned(struct mm_struct *mm, bool write,
					   bool success);
void __mmap_lock_do_trace_released(struct mm_struct *mm, bool write);

static inline void __mmap_lock_trace_start_locking(struct mm_struct *mm,
						   bool write)
{}

static inline void __mmap_lock_trace_acquire_returned(struct mm_struct *mm,
						      bool write, bool success)
{}

static inline void __mmap_lock_trace_released(struct mm_struct *mm, bool write)
{}

#else /* !CONFIG_TRACING */

static inline void __mmap_lock_trace_start_locking(struct mm_struct *mm,
						   bool write)
{
}

static inline void __mmap_lock_trace_acquire_returned(struct mm_struct *mm,
						      bool write, bool success)
{
}

static inline void __mmap_lock_trace_released(struct mm_struct *mm, bool write)
{
}

#endif /* CONFIG_TRACING */

static inline void mmap_assert_locked(const struct mm_struct *mm)
{}

static inline void mmap_assert_write_locked(const struct mm_struct *mm)
{}

#ifdef CONFIG_PER_VMA_LOCK
/*
 * Drop all currently-held per-VMA locks.
 * This is called from the mmap_lock implementation directly before releasing
 * a write-locked mmap_lock (or downgrading it to read-locked).
 * This should normally NOT be called manually from other places.
 * If you want to call this manually anyway, keep in mind that this will release
 * *all* VMA write locks, including ones from further up the stack.
 */
static inline void vma_end_write_all(struct mm_struct *mm)
{}
#else
static inline void vma_end_write_all(struct mm_struct *mm) {}
#endif

static inline void mmap_init_lock(struct mm_struct *mm)
{}

static inline void mmap_write_lock(struct mm_struct *mm)
{}

static inline void mmap_write_lock_nested(struct mm_struct *mm, int subclass)
{}

static inline int mmap_write_lock_killable(struct mm_struct *mm)
{}

static inline void mmap_write_unlock(struct mm_struct *mm)
{}

static inline void mmap_write_downgrade(struct mm_struct *mm)
{}

static inline void mmap_read_lock(struct mm_struct *mm)
{}

static inline int mmap_read_lock_killable(struct mm_struct *mm)
{}

static inline bool mmap_read_trylock(struct mm_struct *mm)
{}

static inline void mmap_read_unlock(struct mm_struct *mm)
{}

static inline void mmap_read_unlock_non_owner(struct mm_struct *mm)
{}

static inline int mmap_lock_is_contended(struct mm_struct *mm)
{}

#endif /* _LINUX_MMAP_LOCK_H */