Commit c83ff1d2 authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Linus Torvalds

[PATCH] Lock initializer unifying (Core)

To make spinlock/rwlock initialization consistent all over the kernel,
this patch converts explicit lock-initializers into spin_lock_init() and
rwlock_init() calls.

Currently, spinlocks and rwlocks are initialized in two different ways:

  lock = SPIN_LOCK_UNLOCKED
  spin_lock_init(&lock)

  rwlock = RW_LOCK_UNLOCKED
  rwlock_init(&rwlock)

this patch converts all explicit lock initializations to
spin_lock_init() or rwlock_init(). (Besides consistency this also helps
automatic lock validators and debugging code.)

The conversion was done with a script, it was verified manually and it
was reviewed, compiled and tested as far as possible on x86, ARM, PPC.

There is no runtime overhead or actual code change resulting out of this
patch, because spin_lock_init() and rwlock_init() are macros and are
thus equivalent to the explicit initialization method.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Acked-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 41b873ff
...@@ -193,7 +193,7 @@ int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size) ...@@ -193,7 +193,7 @@ int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size)
if(ids->seq > ids->seq_max) if(ids->seq > ids->seq_max)
ids->seq = 0; ids->seq = 0;
new->lock = SPIN_LOCK_UNLOCKED; spin_lock_init(&new->lock);
new->deleted = 0; new->deleted = 0;
rcu_read_lock(); rcu_read_lock();
spin_lock(&new->lock); spin_lock(&new->lock);
......
...@@ -293,8 +293,8 @@ static struct mm_struct * mm_init(struct mm_struct * mm) ...@@ -293,8 +293,8 @@ static struct mm_struct * mm_init(struct mm_struct * mm)
INIT_LIST_HEAD(&mm->mmlist); INIT_LIST_HEAD(&mm->mmlist);
mm->core_waiters = 0; mm->core_waiters = 0;
mm->nr_ptes = 0; mm->nr_ptes = 0;
mm->page_table_lock = SPIN_LOCK_UNLOCKED; spin_lock_init(&mm->page_table_lock);
mm->ioctx_list_lock = RW_LOCK_UNLOCKED; rwlock_init(&mm->ioctx_list_lock);
mm->ioctx_list = NULL; mm->ioctx_list = NULL;
mm->default_kioctx = (struct kioctx)INIT_KIOCTX(mm->default_kioctx, *mm); mm->default_kioctx = (struct kioctx)INIT_KIOCTX(mm->default_kioctx, *mm);
mm->free_area_cache = TASK_UNMAPPED_BASE; mm->free_area_cache = TASK_UNMAPPED_BASE;
...@@ -494,7 +494,7 @@ static inline struct fs_struct *__copy_fs_struct(struct fs_struct *old) ...@@ -494,7 +494,7 @@ static inline struct fs_struct *__copy_fs_struct(struct fs_struct *old)
/* We don't need to lock fs - think why ;-) */ /* We don't need to lock fs - think why ;-) */
if (fs) { if (fs) {
atomic_set(&fs->count, 1); atomic_set(&fs->count, 1);
fs->lock = RW_LOCK_UNLOCKED; rwlock_init(&fs->lock);
fs->umask = old->umask; fs->umask = old->umask;
read_lock(&old->lock); read_lock(&old->lock);
fs->rootmnt = mntget(old->rootmnt); fs->rootmnt = mntget(old->rootmnt);
...@@ -576,7 +576,7 @@ static int copy_files(unsigned long clone_flags, struct task_struct * tsk) ...@@ -576,7 +576,7 @@ static int copy_files(unsigned long clone_flags, struct task_struct * tsk)
atomic_set(&newf->count, 1); atomic_set(&newf->count, 1);
newf->file_lock = SPIN_LOCK_UNLOCKED; spin_lock_init(&newf->file_lock);
newf->next_fd = 0; newf->next_fd = 0;
newf->max_fds = NR_OPEN_DEFAULT; newf->max_fds = NR_OPEN_DEFAULT;
newf->max_fdset = __FD_SETSIZE; newf->max_fdset = __FD_SETSIZE;
......
...@@ -732,7 +732,7 @@ static int __init init(void) ...@@ -732,7 +732,7 @@ static int __init init(void)
for (i = 0; i < ARRAY_SIZE(futex_queues); i++) { for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
INIT_LIST_HEAD(&futex_queues[i].chain); INIT_LIST_HEAD(&futex_queues[i].chain);
futex_queues[i].lock = SPIN_LOCK_UNLOCKED; spin_lock_init(&futex_queues[i].lock);
} }
return 0; return 0;
} }
......
...@@ -1374,7 +1374,7 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags) ...@@ -1374,7 +1374,7 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
p->highest_bit = 0; p->highest_bit = 0;
p->cluster_nr = 0; p->cluster_nr = 0;
p->inuse_pages = 0; p->inuse_pages = 0;
p->sdev_lock = SPIN_LOCK_UNLOCKED; spin_lock_init(&p->sdev_lock);
p->next = -1; p->next = -1;
if (swap_flags & SWAP_FLAG_PREFER) { if (swap_flags & SWAP_FLAG_PREFER) {
p->prio = p->prio =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment