cregit-Linux how code gets into the kernel

Release 4.11 kernel/locking/rwsem.c

Directory: kernel/locking
/* kernel/rwsem.c: R/W semaphores, public implementation
 *
 * Written by David Howells (dhowells@redhat.com).
 * Derived from asm-i386/semaphore.h
 */

#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/sched/debug.h>
#include <linux/export.h>
#include <linux/rwsem.h>
#include <linux/atomic.h>

#include "rwsem.h"

/*
 * lock for reading
 */

void __sched down_read(struct rw_semaphore *sem) { might_sleep(); rwsem_acquire_read(&sem->dep_map, 0, 0, _RET_IP_); LOCK_CONTENDED(sem, __down_read_trylock, __down_read); rwsem_set_reader_owned(sem); }

Contributors

PersonTokensPropCommitsCommitProp
Ingo Molnar3173.81%125.00%
Peter Zijlstra511.90%125.00%
Waiman Long511.90%125.00%
Livio Soares12.38%125.00%
Total42100.00%4100.00%

EXPORT_SYMBOL(down_read); /* * trylock for reading -- returns 1 if successful, 0 if contention */
int down_read_trylock(struct rw_semaphore *sem) { int ret = __down_read_trylock(sem); if (ret == 1) { rwsem_acquire_read(&sem->dep_map, 0, 1, _RET_IP_); rwsem_set_reader_owned(sem); } return ret; }

Contributors

PersonTokensPropCommitsCommitProp
Ingo Molnar4185.42%150.00%
Waiman Long714.58%150.00%
Total48100.00%2100.00%

EXPORT_SYMBOL(down_read_trylock); /* * lock for writing */
void __sched down_write(struct rw_semaphore *sem) { might_sleep(); rwsem_acquire(&sem->dep_map, 0, 0, _RET_IP_); LOCK_CONTENDED(sem, __down_write_trylock, __down_write); rwsem_set_owner(sem); }

Contributors

PersonTokensPropCommitsCommitProp
Ingo Molnar3173.81%125.00%
Peter Zijlstra511.90%125.00%
Davidlohr Bueso A511.90%125.00%
Livio Soares12.38%125.00%
Total42100.00%4100.00%

EXPORT_SYMBOL(down_write); /* * lock for writing */
int __sched down_write_killable(struct rw_semaphore *sem) { might_sleep(); rwsem_acquire(&sem->dep_map, 0, 0, _RET_IP_); if (LOCK_CONTENDED_RETURN(sem, __down_write_trylock, __down_write_killable)) { rwsem_release(&sem->dep_map, 1, _RET_IP_); return -EINTR; } rwsem_set_owner(sem); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Michal Hocko65100.00%1100.00%
Total65100.00%1100.00%

EXPORT_SYMBOL(down_write_killable); /* * trylock for writing -- returns 1 if successful, 0 if contention */
int down_write_trylock(struct rw_semaphore *sem) { int ret = __down_write_trylock(sem); if (ret == 1) { rwsem_acquire(&sem->dep_map, 0, 1, _RET_IP_); rwsem_set_owner(sem); } return ret; }

Contributors

PersonTokensPropCommitsCommitProp
Ingo Molnar4083.33%133.33%
Davidlohr Bueso A714.58%133.33%
Pavel Emelyanov12.08%133.33%
Total48100.00%3100.00%

EXPORT_SYMBOL(down_write_trylock); /* * release a read lock */
void up_read(struct rw_semaphore *sem) { rwsem_release(&sem->dep_map, 1, _RET_IP_); __up_read(sem); }

Contributors

PersonTokensPropCommitsCommitProp
Ingo Molnar27100.00%1100.00%
Total27100.00%1100.00%

EXPORT_SYMBOL(up_read); /* * release a write lock */
void up_write(struct rw_semaphore *sem) { rwsem_release(&sem->dep_map, 1, _RET_IP_); rwsem_clear_owner(sem); __up_write(sem); }

Contributors

PersonTokensPropCommitsCommitProp
Ingo Molnar2784.38%150.00%
Davidlohr Bueso A515.62%150.00%
Total32100.00%2100.00%

EXPORT_SYMBOL(up_write); /* * downgrade write lock to read lock */
void downgrade_write(struct rw_semaphore *sem) { /* * lockdep: a downgraded write will live on as a write * dependency. */ rwsem_set_reader_owned(sem); __downgrade_write(sem); }

Contributors

PersonTokensPropCommitsCommitProp
Ingo Molnar1676.19%133.33%
Davidlohr Bueso A419.05%133.33%
Waiman Long14.76%133.33%
Total21100.00%3100.00%

EXPORT_SYMBOL(downgrade_write); #ifdef CONFIG_DEBUG_LOCK_ALLOC
void down_read_nested(struct rw_semaphore *sem, int subclass) { might_sleep(); rwsem_acquire_read(&sem->dep_map, subclass, 0, _RET_IP_); LOCK_CONTENDED(sem, __down_read_trylock, __down_read); rwsem_set_reader_owned(sem); }

Contributors

PersonTokensPropCommitsCommitProp
Ingo Molnar3477.27%133.33%
Waiman Long511.36%133.33%
Peter Zijlstra511.36%133.33%
Total44100.00%3100.00%

EXPORT_SYMBOL(down_read_nested);
void _down_write_nest_lock(struct rw_semaphore *sem, struct lockdep_map *nest) { might_sleep(); rwsem_acquire_nest(&sem->dep_map, 0, 0, nest, _RET_IP_); LOCK_CONTENDED(sem, __down_write_trylock, __down_write); rwsem_set_owner(sem); }

Contributors

PersonTokensPropCommitsCommitProp
Jiri Kosina4389.58%150.00%
Davidlohr Bueso A510.42%150.00%
Total48100.00%2100.00%

EXPORT_SYMBOL(_down_write_nest_lock);
void down_read_non_owner(struct rw_semaphore *sem) { might_sleep(); __down_read(sem); }

Contributors

PersonTokensPropCommitsCommitProp
Kent Overstreet18100.00%1100.00%
Total18100.00%1100.00%

EXPORT_SYMBOL(down_read_non_owner);
void down_write_nested(struct rw_semaphore *sem, int subclass) { might_sleep(); rwsem_acquire(&sem->dep_map, subclass, 0, _RET_IP_); LOCK_CONTENDED(sem, __down_write_trylock, __down_write); rwsem_set_owner(sem); }

Contributors

PersonTokensPropCommitsCommitProp
Ingo Molnar3579.55%133.33%
Davidlohr Bueso A511.36%133.33%
Peter Zijlstra49.09%133.33%
Total44100.00%3100.00%

EXPORT_SYMBOL(down_write_nested);
int __sched down_write_killable_nested(struct rw_semaphore *sem, int subclass) { might_sleep(); rwsem_acquire(&sem->dep_map, subclass, 0, _RET_IP_); if (LOCK_CONTENDED_RETURN(sem, __down_write_trylock, __down_write_killable)) { rwsem_release(&sem->dep_map, 1, _RET_IP_); return -EINTR; } rwsem_set_owner(sem); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Al Viro68100.00%1100.00%
Total68100.00%1100.00%

EXPORT_SYMBOL(down_write_killable_nested);
void up_read_non_owner(struct rw_semaphore *sem) { __up_read(sem); }

Contributors

PersonTokensPropCommitsCommitProp
Kent Overstreet15100.00%1100.00%
Total15100.00%1100.00%

EXPORT_SYMBOL(up_read_non_owner); #endif

Overall Contributors

PersonTokensPropCommitsCommitProp
Ingo Molnar35653.13%320.00%
Al Viro7310.90%16.67%
Michal Hocko7110.60%16.67%
Jiri Kosina487.16%16.67%
Kent Overstreet436.42%16.67%
Davidlohr Bueso A345.07%213.33%
Peter Zijlstra192.84%16.67%
Waiman Long182.69%16.67%
Livio Soares50.75%16.67%
Pavel Emelyanov10.15%16.67%
Paul Gortmaker10.15%16.67%
Arun Sharma10.15%16.67%
Total670100.00%15100.00%
Directory: kernel/locking
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.