From: Li Zefan <lizf@cn.fujitsu.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Paul Menage" <menage@google.com>,
"David Rientjes" <rientjes@google.com>,
"缪 勰" <miaox@cn.fujitsu.com>, LKML <linux-kernel@vger.kernel.org>,
linux-mm@kvack.org
Subject: Re: [PATCH] cpuset: Add a missing unlock in cpuset_write_resmask()
Date: Tue, 01 Mar 2011 09:05:22 +0800 [thread overview]
Message-ID: <4D6C4652.6030804@cn.fujitsu.com> (raw)
In-Reply-To: <20110228155524.6d7563e0.akpm@linux-foundation.org>
>> @@ -1561,8 +1561,10 @@ static int cpuset_write_resmask(struct cgroup *cgrp, struct cftype *cft,
>> return -ENODEV;
>>
>> trialcs = alloc_trial_cpuset(cs);
>> - if (!trialcs)
>> + if (!trialcs) {
>> + cgroup_unlock();
>> return -ENOMEM;
>> + }
>>
>> switch (cft->private) {
>> case FILE_CPULIST:
>
> It would be better to avoid multiple returns - it leads to more
> maintainable code and often shorter code:
>
I have no strong opinion on this.
> --- a/kernel/cpuset.c~cpuset-add-a-missing-unlock-in-cpuset_write_resmask-fix
> +++ a/kernel/cpuset.c
> @@ -1562,8 +1562,8 @@ static int cpuset_write_resmask(struct c
>
> trialcs = alloc_trial_cpuset(cs);
> if (!trialcs) {
> - cgroup_unlock();
> - return -ENOMEM;
> + retval = -ENOMEM;
> + goto out;
> }
>
> switch (cft->private) {
> @@ -1579,6 +1579,7 @@ static int cpuset_write_resmask(struct c
> }
>
> free_trial_cpuset(trialcs);
> +out:
> cgroup_unlock();
> return retval;
> }
> _
>
> also, alloc_trial_cpuset() is a fairly slow-looking function.
> cpuset_write_resmask() could run alloc_trial_cpuset() before running
> cgroup_lock_live_group(), thereby reducing lock hold times.
>
Nope. alloc_trial_cpuset() will read 'cs', so it must be protected by
the lock.
WARNING: multiple messages have this Message-ID (diff)
From: Li Zefan <lizf@cn.fujitsu.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Paul Menage" <menage@google.com>,
"David Rientjes" <rientjes@google.com>,
"缪 勰" <miaox@cn.fujitsu.com>, LKML <linux-kernel@vger.kernel.org>,
linux-mm@kvack.org
Subject: Re: [PATCH] cpuset: Add a missing unlock in cpuset_write_resmask()
Date: Tue, 01 Mar 2011 09:05:22 +0800 [thread overview]
Message-ID: <4D6C4652.6030804@cn.fujitsu.com> (raw)
In-Reply-To: <20110228155524.6d7563e0.akpm@linux-foundation.org>
>> @@ -1561,8 +1561,10 @@ static int cpuset_write_resmask(struct cgroup *cgrp, struct cftype *cft,
>> return -ENODEV;
>>
>> trialcs = alloc_trial_cpuset(cs);
>> - if (!trialcs)
>> + if (!trialcs) {
>> + cgroup_unlock();
>> return -ENOMEM;
>> + }
>>
>> switch (cft->private) {
>> case FILE_CPULIST:
>
> It would be better to avoid multiple returns - it leads to more
> maintainable code and often shorter code:
>
I have no strong opinion on this.
> --- a/kernel/cpuset.c~cpuset-add-a-missing-unlock-in-cpuset_write_resmask-fix
> +++ a/kernel/cpuset.c
> @@ -1562,8 +1562,8 @@ static int cpuset_write_resmask(struct c
>
> trialcs = alloc_trial_cpuset(cs);
> if (!trialcs) {
> - cgroup_unlock();
> - return -ENOMEM;
> + retval = -ENOMEM;
> + goto out;
> }
>
> switch (cft->private) {
> @@ -1579,6 +1579,7 @@ static int cpuset_write_resmask(struct c
> }
>
> free_trial_cpuset(trialcs);
> +out:
> cgroup_unlock();
> return retval;
> }
> _
>
> also, alloc_trial_cpuset() is a fairly slow-looking function.
> cpuset_write_resmask() could run alloc_trial_cpuset() before running
> cgroup_lock_live_group(), thereby reducing lock hold times.
>
Nope. alloc_trial_cpuset() will read 'cs', so it must be protected by
the lock.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2011-03-01 1:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-24 6:58 [PATCH] cpuset: Add a missing unlock in cpuset_write_resmask() Li Zefan
2011-02-24 6:58 ` Li Zefan
2011-02-24 7:05 ` David Rientjes
2011-02-24 7:05 ` David Rientjes
2011-02-28 23:55 ` Andrew Morton
2011-02-28 23:55 ` Andrew Morton
2011-03-01 1:05 ` Li Zefan [this message]
2011-03-01 1:05 ` Li Zefan
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=4D6C4652.6030804@cn.fujitsu.com \
--to=lizf@cn.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=menage@google.com \
--cc=miaox@cn.fujitsu.com \
--cc=rientjes@google.com \
/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.