I would like to check in a struct mutex
which is locked in the kernel, who is the owner of that mutex.
struct mutex {
atomic_long_t owner;
spinlock_t wait_lock;
#ifdef CONFIG_MUTEX_SPIN_ON_OWNER
struct optimistic_spin_queue osq; /* Spinner MCS lock */
#endif
struct list_head wait_list;
#ifdef CONFIG_DEBUG_MUTEXES
void *magic;
#endif
#ifdef CONFIG_DEBUG_LOCK_ALLOC
struct lockdep_map dep_map;
#endif
};
I understand from the kernel documentation that:
Field owner actually contains struct task_struct * to the current lock owner and it is therefore NULL if not currently owned.
Is there any safe way to compare that field to current
?