From: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
To: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: LKML <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
cgroups <cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: [PATCH 2/2] cpuset: remove redundant checks in file write functions
Date: Tue, 13 Aug 2013 09:17:53 +0800 [thread overview]
Message-ID: <52098941.4070600@huawei.com> (raw)
In-Reply-To: <5209892D.8070502-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Now cgroup core gets a reference to the css when a cgroup file is
opened(), and the reference is dropped at file release. so it's
guaranteed the cpuset is online during the write function.
Signed-off-by: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
---
kernel/cpuset.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 9d8d637..8c4b3c4 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -1589,8 +1589,6 @@ static int cpuset_write_u64(struct cgroup_subsys_state *css, struct cftype *cft,
int retval = -ENODEV;
mutex_lock(&cpuset_mutex);
- if (!is_cpuset_online(cs))
- goto out_unlock;
switch (type) {
case FILE_CPU_EXCLUSIVE:
@@ -1624,7 +1622,7 @@ static int cpuset_write_u64(struct cgroup_subsys_state *css, struct cftype *cft,
retval = -EINVAL;
break;
}
-out_unlock:
+
mutex_unlock(&cpuset_mutex);
return retval;
}
@@ -1637,8 +1635,6 @@ static int cpuset_write_s64(struct cgroup_subsys_state *css, struct cftype *cft,
int retval = -ENODEV;
mutex_lock(&cpuset_mutex);
- if (!is_cpuset_online(cs))
- goto out_unlock;
switch (type) {
case FILE_SCHED_RELAX_DOMAIN_LEVEL:
@@ -1648,7 +1644,7 @@ static int cpuset_write_s64(struct cgroup_subsys_state *css, struct cftype *cft,
retval = -EINVAL;
break;
}
-out_unlock:
+
mutex_unlock(&cpuset_mutex);
return retval;
}
@@ -1677,8 +1673,6 @@ static int cpuset_write_resmask(struct cgroup_subsys_state *css,
flush_work(&cpuset_hotplug_work);
mutex_lock(&cpuset_mutex);
- if (!is_cpuset_online(cs))
- goto out_unlock;
trialcs = alloc_trial_cpuset(cs);
if (!trialcs) {
--
1.8.0.2
WARNING: multiple messages have this Message-ID (diff)
From: Li Zefan <lizefan@huawei.com>
To: Tejun Heo <tj@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>, cgroups <cgroups@vger.kernel.org>
Subject: [PATCH 2/2] cpuset: remove redundant checks in file write functions
Date: Tue, 13 Aug 2013 09:17:53 +0800 [thread overview]
Message-ID: <52098941.4070600@huawei.com> (raw)
In-Reply-To: <5209892D.8070502@huawei.com>
Now cgroup core gets a reference to the css when a cgroup file is
opened(), and the reference is dropped at file release. so it's
guaranteed the cpuset is online during the write function.
Signed-off-by: Li Zefan <lizefan@huawei.com>
---
kernel/cpuset.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 9d8d637..8c4b3c4 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -1589,8 +1589,6 @@ static int cpuset_write_u64(struct cgroup_subsys_state *css, struct cftype *cft,
int retval = -ENODEV;
mutex_lock(&cpuset_mutex);
- if (!is_cpuset_online(cs))
- goto out_unlock;
switch (type) {
case FILE_CPU_EXCLUSIVE:
@@ -1624,7 +1622,7 @@ static int cpuset_write_u64(struct cgroup_subsys_state *css, struct cftype *cft,
retval = -EINVAL;
break;
}
-out_unlock:
+
mutex_unlock(&cpuset_mutex);
return retval;
}
@@ -1637,8 +1635,6 @@ static int cpuset_write_s64(struct cgroup_subsys_state *css, struct cftype *cft,
int retval = -ENODEV;
mutex_lock(&cpuset_mutex);
- if (!is_cpuset_online(cs))
- goto out_unlock;
switch (type) {
case FILE_SCHED_RELAX_DOMAIN_LEVEL:
@@ -1648,7 +1644,7 @@ static int cpuset_write_s64(struct cgroup_subsys_state *css, struct cftype *cft,
retval = -EINVAL;
break;
}
-out_unlock:
+
mutex_unlock(&cpuset_mutex);
return retval;
}
@@ -1677,8 +1673,6 @@ static int cpuset_write_resmask(struct cgroup_subsys_state *css,
flush_work(&cpuset_hotplug_work);
mutex_lock(&cpuset_mutex);
- if (!is_cpuset_online(cs))
- goto out_unlock;
trialcs = alloc_trial_cpuset(cs);
if (!trialcs) {
--
1.8.0.2
next prev parent reply other threads:[~2013-08-13 1:17 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-13 1:17 [PATCH 1/2] cpuset: remove an unncessary forward declaration Li Zefan
2013-08-13 1:17 ` Li Zefan
[not found] ` <5209892D.8070502-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2013-08-13 1:17 ` Li Zefan [this message]
2013-08-13 1:17 ` [PATCH 2/2] cpuset: remove redundant checks in file write functions Li Zefan
[not found] ` <52098941.4070600-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2013-08-13 2:07 ` Li Zefan
2013-08-13 2:07 ` Li Zefan
2013-08-13 15:05 ` Tejun Heo
2013-08-13 15:05 ` Tejun Heo
[not found] ` <20130813150549.GF26596-9pTldWuhBndy/B6EtB590w@public.gmane.org>
2013-08-14 2:01 ` Li Zefan
2013-08-14 2:01 ` Li Zefan
[not found] ` <520AE4FC.5090702-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2013-08-14 13:30 ` Tejun Heo
2013-08-14 13:30 ` Tejun Heo
[not found] ` <20130814133048.GC28628-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
2013-08-16 6:48 ` Li Zefan
2013-08-16 6:48 ` Li Zefan
2013-08-13 14:53 ` [PATCH 1/2] cpuset: remove an unncessary forward declaration Tejun Heo
2013-08-13 14:53 ` Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52098941.4070600@huawei.com \
--to=lizefan-hv44wf8li93qt0dzr+alfa@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.