summaryrefslogtreecommitdiffstats
path: root/kernel/cgroup.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-11-29 10:42:58 -0500
committerTejun Heo <tj@kernel.org>2013-11-29 10:42:58 -0500
commitac1e69aa78e2e799a8d5475595ba744bdf29b597 (patch)
tree5a33e778c533270e44b6243337d8b49f83b37555 /kernel/cgroup.c
parentc729b11edf7458a939556e1889446184f42f37a7 (diff)
downloadop-kernel-dev-ac1e69aa78e2e799a8d5475595ba744bdf29b597.zip
op-kernel-dev-ac1e69aa78e2e799a8d5475595ba744bdf29b597.tar.gz
cgroup: don't skip seq_open on write only opens on pidlist files
Currently, cgroup_pidlist_open() skips seq_open() and pidlist loading if the file is opened write-only, which is a sensible optimization as pidlist loading can be costly and there often are occasions where tasks or cgroup.procs is opened write-only. However, pidlist init and release are planned to be moved to cgroup_pidlist_start/stop() respectively which would make this optimization unnecessary. This patch removes the optimization and always fully initializes pidlist files regardless of open mode. This will help moving pidlist handling to start/stop by unifying rw paths and removes the need for specifying cftype->release() in addition to .release in cgroup_pidlist_operations as file->f_op is now always overridden. As pidlist files were the only user of cftype->release(), the next patch will remove the method. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Li Zefan <lizefan@huawei.com>
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r--kernel/cgroup.c13
1 files changed, 1 insertions, 12 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 34fd1be..1e09ded 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -3781,12 +3781,7 @@ static void cgroup_release_pid_array(struct cgroup_pidlist *l)
static int cgroup_pidlist_release(struct inode *inode, struct file *file)
{
struct cgroup_pidlist *l;
- if (!(file->f_mode & FMODE_READ))
- return 0;
- /*
- * the seq_file will only be initialized if the file was opened for
- * reading; hence we check if it's not null only in that case.
- */
+
l = ((struct seq_file *)file->private_data)->private;
cgroup_release_pid_array(l);
return seq_release(inode, file);
@@ -3811,10 +3806,6 @@ static int cgroup_pidlist_open(struct file *file, enum cgroup_filetype type)
struct cgroup_pidlist *l;
int retval;
- /* Nothing to do for write-only files */
- if (!(file->f_mode & FMODE_READ))
- return 0;
-
/* have the array populated */
retval = pidlist_array_load(cgrp, type, &l);
if (retval)
@@ -3894,7 +3885,6 @@ static struct cftype cgroup_base_files[] = {
.name = "cgroup.procs",
.open = cgroup_procs_open,
.write_u64 = cgroup_procs_write,
- .release = cgroup_pidlist_release,
.mode = S_IRUGO | S_IWUSR,
},
{
@@ -3919,7 +3909,6 @@ static struct cftype cgroup_base_files[] = {
.flags = CFTYPE_INSANE, /* use "procs" instead */
.open = cgroup_tasks_open,
.write_u64 = cgroup_tasks_write,
- .release = cgroup_pidlist_release,
.mode = S_IRUGO | S_IWUSR,
},
{
OpenPOWER on IntegriCloud