cregit-Linux how code gets into the kernel

Release 4.15 kernel/locking/rwsem.c

Directory: kernel/locking
// SPDX-License-Identifier: GPL-2.0
/* 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);
int __sched down_read_killable(struct rw_semaphore *sem) { might_sleep(); rwsem_acquire_read(&sem->dep_map, 0, 0, _RET_IP_); if (LOCK_CONTENDED_RETURN(sem, __down_read_trylock, __down_read_killable)) { rwsem_release(&sem->dep_map, 1, _RET_IP_); return -EINTR; } rwsem_set_reader_owned(sem); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Kirill Tkhai65100.00%1100.00%
Total65100.00%1100.00%

EXPORT_SYMBOL(down_read_killable); /* * 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%
Davidlohr Bueso A511.90%125.00%
Peter Zijlstra511.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) { lock_downgrade(&sem->dep_map, _RET_IP_); rwsem_set_reader_owned(sem); __downgrade_write(sem); }

Contributors

PersonTokensPropCommitsCommitProp
Ingo Molnar1550.00%125.00%
Junjiro R. Okajima1033.33%125.00%
Davidlohr Bueso A413.33%125.00%
Waiman Long13.33%125.00%
Total30100.00%4100.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%
Peter Zijlstra511.36%133.33%
Waiman Long511.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 Molnar35547.33%316.67%
Al Viro739.73%15.56%
Michal Hocko719.47%15.56%
Kirill Tkhai709.33%15.56%
Jiri Kosina486.40%15.56%
Kent Overstreet435.73%15.56%
Davidlohr Bueso A344.53%211.11%
Peter Zijlstra192.53%15.56%
Waiman Long182.40%15.56%
Junjiro R. Okajima101.33%15.56%
Livio Soares50.67%15.56%
Arun Sharma10.13%15.56%
Pavel Emelyanov10.13%15.56%
Greg Kroah-Hartman10.13%15.56%
Paul Gortmaker10.13%15.56%
Total750100.00%18100.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.