* [PATCH] cgroup: add opts release function to simplify the code
@ 2016-03-11 7:07 Xiubo Li
[not found] ` <1457680035-26772-1-git-send-email-lixiubo-0p4V/sDNsUmm0O/7XYngnFaTQe2KTcn/@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Xiubo Li @ 2016-03-11 7:07 UTC (permalink / raw)
To: tj-DgEjT+Ai2ygdnm+yROfE0A, lizefan-hv44wF8Li93QT0dZR+AlfA
Cc: cgroups-u79uwXL29TY76Z2rM5mHXA, Xiubo Li
The old code is a bit confusing for the readers by thinking why
these two members of opts should be released?
The resources allocated by whom has the possiblity to release it,
But this will make the opts parse function more complex. So add
opts release function to simplify the code, and at the same time
to make the code more easy to read and be understood.
Signed-off-by: Xiubo Li <lixiubo-0p4V/sDNsUmm0O/7XYngnFaTQe2KTcn/@public.gmane.org>
---
kernel/cgroup.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 155c884..5db5dad 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1761,6 +1761,12 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts)
return 0;
}
+static inline void release_cgroupfs_options(struct cgroup_sb_opts *opts)
+{
+ kfree(opts->release_agent);
+ kfree(opts->name);
+}
+
static int cgroup_remount(struct kernfs_root *kf_root, int *flags, char *data)
{
int ret = 0;
@@ -1814,9 +1820,8 @@ static int cgroup_remount(struct kernfs_root *kf_root, int *flags, char *data)
spin_unlock(&release_agent_path_lock);
}
out_unlock:
- kfree(opts.release_agent);
- kfree(opts.name);
mutex_unlock(&cgroup_mutex);
+ release_cgroupfs_options(&opts);
return ret;
}
@@ -2070,7 +2075,7 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
mutex_unlock(&cgroup_mutex);
msleep(10);
ret = restart_syscall();
- goto out_free;
+ goto out_release;
}
cgroup_put(&ss->root->cgrp);
}
@@ -2127,7 +2132,7 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
deactivate_super(pinned_sb);
msleep(10);
ret = restart_syscall();
- goto out_free;
+ goto out_release;
}
ret = 0;
@@ -2168,9 +2173,8 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
out_unlock:
mutex_unlock(&cgroup_mutex);
-out_free:
- kfree(opts.release_agent);
- kfree(opts.name);
+out_release:
+ release_cgroupfs_options(&opts);
if (ret) {
put_cgroup_ns(ns);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] cgroup: add opts release function to simplify the code
[not found] ` <1457680035-26772-1-git-send-email-lixiubo-0p4V/sDNsUmm0O/7XYngnFaTQe2KTcn/@public.gmane.org>
@ 2016-03-11 17:26 ` Tejun Heo
[not found] ` <20160311172617.GE24046-piEFEHQLUPpN0TnZuCh8vA@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Tejun Heo @ 2016-03-11 17:26 UTC (permalink / raw)
To: Xiubo Li; +Cc: lizefan-hv44wF8Li93QT0dZR+AlfA, cgroups-u79uwXL29TY76Z2rM5mHXA
On Fri, Mar 11, 2016 at 03:07:15PM +0800, Xiubo Li wrote:
> The old code is a bit confusing for the readers by thinking why
> these two members of opts should be released?
>
> The resources allocated by whom has the possiblity to release it,
> But this will make the opts parse function more complex. So add
> opts release function to simplify the code, and at the same time
> to make the code more easy to read and be understood.
I'm not really sure this improves anything.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] cgroup: add opts release function to simplify the code
[not found] ` <20160311172617.GE24046-piEFEHQLUPpN0TnZuCh8vA@public.gmane.org>
@ 2016-03-14 1:30 ` Xiubo Li
0 siblings, 0 replies; 3+ messages in thread
From: Xiubo Li @ 2016-03-14 1:30 UTC (permalink / raw)
To: Tejun Heo; +Cc: lizefan-hv44wF8Li93QT0dZR+AlfA, cgroups-u79uwXL29TY76Z2rM5mHXA
On 12/03/2016 01:26, Tejun Heo wrote:
> On Fri, Mar 11, 2016 at 03:07:15PM +0800, Xiubo Li wrote:
>> The old code is a bit confusing for the readers by thinking why
>> these two members of opts should be released?
>>
>> The resources allocated by whom has the possiblity to release it,
>> But this will make the opts parse function more complex. So add
>> opts release function to simplify the code, and at the same time
>> to make the code more easy to read and be understood.
>
> I'm not really sure this improves anything.
>
Okay
Thanks,
> Thanks.
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-03-14 1:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-11 7:07 [PATCH] cgroup: add opts release function to simplify the code Xiubo Li
[not found] ` <1457680035-26772-1-git-send-email-lixiubo-0p4V/sDNsUmm0O/7XYngnFaTQe2KTcn/@public.gmane.org>
2016-03-11 17:26 ` Tejun Heo
[not found] ` <20160311172617.GE24046-piEFEHQLUPpN0TnZuCh8vA@public.gmane.org>
2016-03-14 1:30 ` Xiubo Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).