Commit a4b13f2f authored by Linus Torvalds's avatar Linus Torvalds

Lock-annotate some kernel functions as an example of how it works.

In particular, a function that is called with a lock held, and
releases it only to re-acquire it needs to be annotated as such,
since otherwise sparse will complain about an unexpected unlock,
even though "globally" the lock is constant over the call.
parent 434a9cc6
......@@ -54,6 +54,8 @@ void free_fd_array(struct file **array, int num)
*/
int expand_fd_array(struct files_struct *files, int nr)
__releases(files->file_lock)
__acquires(files->file_lock)
{
struct file **new_fds;
int error, nfds;
......@@ -157,6 +159,8 @@ void free_fdset(fd_set *array, int num)
* held for write.
*/
int expand_fdset(struct files_struct *files, int nr)
__releases(file->file_lock)
__acquires(file->file_lock)
{
fd_set *new_openset = NULL, *new_execset = NULL;
int error, nfds = 0;
......
......@@ -441,6 +441,7 @@ static void __init smp_init(void)
*/
static void noinline rest_init(void)
__releases(kernel_lock)
{
kernel_thread(init, NULL, CLONE_FS | CLONE_SIGHAND);
numa_default_policy();
......
......@@ -57,6 +57,7 @@ static void *r_next(struct seq_file *m, void *v, loff_t *pos)
}
static void *r_start(struct seq_file *m, loff_t *pos)
__acquires(resource_lock)
{
struct resource *p = m->private;
loff_t l = 0;
......@@ -67,6 +68,7 @@ static void *r_start(struct seq_file *m, loff_t *pos)
}
static void r_stop(struct seq_file *m, void *v)
__releases(resource_lock)
{
read_unlock(&resource_lock);
}
......
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