cgroup: rename cgroup_pidlist->mutex
It's a rw_semaphore not a mutex. Signed-off-by: Li Zefan <lizefan@huawei.com> Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
parent
876ede8b2b
commit
b395890a09
1 changed files with 11 additions and 11 deletions
|
@ -3436,7 +3436,7 @@ struct cgroup_pidlist {
|
||||||
/* pointer to the cgroup we belong to, for list removal purposes */
|
/* pointer to the cgroup we belong to, for list removal purposes */
|
||||||
struct cgroup *owner;
|
struct cgroup *owner;
|
||||||
/* protects the other fields */
|
/* protects the other fields */
|
||||||
struct rw_semaphore mutex;
|
struct rw_semaphore rwsem;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -3509,7 +3509,7 @@ static struct cgroup_pidlist *cgroup_pidlist_find(struct cgroup *cgrp,
|
||||||
struct pid_namespace *ns = task_active_pid_ns(current);
|
struct pid_namespace *ns = task_active_pid_ns(current);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We can't drop the pidlist_mutex before taking the l->mutex in case
|
* We can't drop the pidlist_mutex before taking the l->rwsem in case
|
||||||
* the last ref-holder is trying to remove l from the list at the same
|
* the last ref-holder is trying to remove l from the list at the same
|
||||||
* time. Holding the pidlist_mutex precludes somebody taking whichever
|
* time. Holding the pidlist_mutex precludes somebody taking whichever
|
||||||
* list we find out from under us - compare release_pid_array().
|
* list we find out from under us - compare release_pid_array().
|
||||||
|
@ -3518,7 +3518,7 @@ static struct cgroup_pidlist *cgroup_pidlist_find(struct cgroup *cgrp,
|
||||||
list_for_each_entry(l, &cgrp->pidlists, links) {
|
list_for_each_entry(l, &cgrp->pidlists, links) {
|
||||||
if (l->key.type == type && l->key.ns == ns) {
|
if (l->key.type == type && l->key.ns == ns) {
|
||||||
/* make sure l doesn't vanish out from under us */
|
/* make sure l doesn't vanish out from under us */
|
||||||
down_write(&l->mutex);
|
down_write(&l->rwsem);
|
||||||
mutex_unlock(&cgrp->pidlist_mutex);
|
mutex_unlock(&cgrp->pidlist_mutex);
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
@ -3529,8 +3529,8 @@ static struct cgroup_pidlist *cgroup_pidlist_find(struct cgroup *cgrp,
|
||||||
mutex_unlock(&cgrp->pidlist_mutex);
|
mutex_unlock(&cgrp->pidlist_mutex);
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
init_rwsem(&l->mutex);
|
init_rwsem(&l->rwsem);
|
||||||
down_write(&l->mutex);
|
down_write(&l->rwsem);
|
||||||
l->key.type = type;
|
l->key.type = type;
|
||||||
l->key.ns = get_pid_ns(ns);
|
l->key.ns = get_pid_ns(ns);
|
||||||
l->owner = cgrp;
|
l->owner = cgrp;
|
||||||
|
@ -3591,7 +3591,7 @@ static int pidlist_array_load(struct cgroup *cgrp, enum cgroup_filetype type,
|
||||||
l->list = array;
|
l->list = array;
|
||||||
l->length = length;
|
l->length = length;
|
||||||
l->use_count++;
|
l->use_count++;
|
||||||
up_write(&l->mutex);
|
up_write(&l->rwsem);
|
||||||
*lp = l;
|
*lp = l;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -3669,7 +3669,7 @@ static void *cgroup_pidlist_start(struct seq_file *s, loff_t *pos)
|
||||||
int index = 0, pid = *pos;
|
int index = 0, pid = *pos;
|
||||||
int *iter;
|
int *iter;
|
||||||
|
|
||||||
down_read(&l->mutex);
|
down_read(&l->rwsem);
|
||||||
if (pid) {
|
if (pid) {
|
||||||
int end = l->length;
|
int end = l->length;
|
||||||
|
|
||||||
|
@ -3696,7 +3696,7 @@ static void *cgroup_pidlist_start(struct seq_file *s, loff_t *pos)
|
||||||
static void cgroup_pidlist_stop(struct seq_file *s, void *v)
|
static void cgroup_pidlist_stop(struct seq_file *s, void *v)
|
||||||
{
|
{
|
||||||
struct cgroup_pidlist *l = s->private;
|
struct cgroup_pidlist *l = s->private;
|
||||||
up_read(&l->mutex);
|
up_read(&l->rwsem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *cgroup_pidlist_next(struct seq_file *s, void *v, loff_t *pos)
|
static void *cgroup_pidlist_next(struct seq_file *s, void *v, loff_t *pos)
|
||||||
|
@ -3742,7 +3742,7 @@ static void cgroup_release_pid_array(struct cgroup_pidlist *l)
|
||||||
* pidlist_mutex, we have to take pidlist_mutex first.
|
* pidlist_mutex, we have to take pidlist_mutex first.
|
||||||
*/
|
*/
|
||||||
mutex_lock(&l->owner->pidlist_mutex);
|
mutex_lock(&l->owner->pidlist_mutex);
|
||||||
down_write(&l->mutex);
|
down_write(&l->rwsem);
|
||||||
BUG_ON(!l->use_count);
|
BUG_ON(!l->use_count);
|
||||||
if (!--l->use_count) {
|
if (!--l->use_count) {
|
||||||
/* we're the last user if refcount is 0; remove and free */
|
/* we're the last user if refcount is 0; remove and free */
|
||||||
|
@ -3750,12 +3750,12 @@ static void cgroup_release_pid_array(struct cgroup_pidlist *l)
|
||||||
mutex_unlock(&l->owner->pidlist_mutex);
|
mutex_unlock(&l->owner->pidlist_mutex);
|
||||||
pidlist_free(l->list);
|
pidlist_free(l->list);
|
||||||
put_pid_ns(l->key.ns);
|
put_pid_ns(l->key.ns);
|
||||||
up_write(&l->mutex);
|
up_write(&l->rwsem);
|
||||||
kfree(l);
|
kfree(l);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mutex_unlock(&l->owner->pidlist_mutex);
|
mutex_unlock(&l->owner->pidlist_mutex);
|
||||||
up_write(&l->mutex);
|
up_write(&l->rwsem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cgroup_pidlist_release(struct inode *inode, struct file *file)
|
static int cgroup_pidlist_release(struct inode *inode, struct file *file)
|
||||||
|
|
Loading…
Reference in a new issue