From: Andrew Morton <akpm@linux-foundation.org>
To: Li Zefan <lizf@cn.fujitsu.com>
Cc: Ingo Molnar <mingo@elte.hu>,
Rusty Russell <rusty@rustcorp.com.au>,
Mike Travis <travis@sgi.com>, Paul Menage <menage@google.com>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 4/6] cpuset: don't allocate trial cpuset on stack
Date: Sun, 4 Jan 2009 23:46:59 -0800 [thread overview]
Message-ID: <20090104234659.19e62245.akpm@linux-foundation.org> (raw)
In-Reply-To: <495B2F19.7040806@cn.fujitsu.com>
On Wed, 31 Dec 2008 16:36:41 +0800 Li Zefan <lizf@cn.fujitsu.com> wrote:
> Impact: cleanups, reduce stack usage
>
> This patch prepares for the next patch. When we convert cpuset.cpus_allowed
> to cpumask_var_t, (trialcs = *cs) no longer works.
>
> Another result of this patch is reducing stack usage of trialcs. sizeof(*cs)
> can be as large as 148 bytes on x86_64, so it's really not good to have it
> on stack.
>
err, what?
> --- a/kernel/cpuset.c
> +++ b/kernel/cpuset.c
> @@ -415,6 +415,24 @@ static int is_cpuset_subset(const struct cpuset *p, const struct cpuset *q)
> is_mem_exclusive(p) <= is_mem_exclusive(q);
> }
>
> +/**
> + * alloc_trial_cpuset - allocate a trial cpuset
> + * @cs: the cpuset that the trial cpuset duplicates
> + */
> +static struct cpuset *alloc_trial_cpuset(const struct cpuset *cs)
> +{
> + return kmemdup(cs, sizeof(*cs), GFP_KERNEL);
> +}
We copy a cpuset by value?
> -static int update_cpumask(struct cpuset *cs, const char *buf)
> +static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs,
> + const char *buf)
> {
> struct ptr_heap heap;
> - struct cpuset trialcs;
> int retval;
> int is_load_balanced;
>
> @@ -891,8 +909,6 @@ static int update_cpumask(struct cpuset *cs, const char *buf)
> if (cs == &top_cpuset)
> return -EACCES;
>
> - trialcs = *cs;
Yes, we already do.
That thing contains spinlocks and list_heads (at least), which cannot
be copied in this way.
Seems that we're doing this gross thing because it just so happens that
we only use the cpus_allowed and mems_allowed fields, and because
several of the called functions require a cpuset*, but only needed a
cpumask_t.
How perfectly beastly.
next prev parent reply other threads:[~2009-01-05 7:47 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-31 8:34 [PATCH 0/6] cpuset: convert to new cpumask API Li Zefan
2008-12-31 8:35 ` [PATCH 1/6] cpuset: remove on stack cpumask_t in cpuset_sprintf_cpulist() Li Zefan
2008-12-31 8:35 ` [PATCH 2/6] cpuset: remove on stack cpumask_t in cpuset_can_attach() Li Zefan
2008-12-31 8:36 ` [PATCH 3/6] cpuset: convert cpuset_attach() to use cpumask_var_t Li Zefan
2008-12-31 8:36 ` [PATCH 4/6] cpuset: don't allocate trial cpuset on stack Li Zefan
2008-12-31 8:37 ` [PATCH 5/6] cpuset: convert cpuset->cpus_allowed to cpumask_var_t Li Zefan
2008-12-31 8:37 ` [PATCH 6/6] cpuset: remove remaining pointers to cpumask_t Li Zefan
2009-01-05 7:46 ` Andrew Morton [this message]
2009-01-05 9:13 ` [PATCH 4/6] cpuset: don't allocate trial cpuset on stack Li Zefan
2009-01-05 7:38 ` [PATCH 3/6] cpuset: convert cpuset_attach() to use cpumask_var_t Andrew Morton
2009-01-05 8:47 ` Li Zefan
2009-01-05 9:01 ` Andrew Morton
2009-01-05 9:04 ` Li Zefan
2009-01-05 9:14 ` Andrew Morton
2009-01-05 9:21 ` Li Zefan
2009-01-07 2:04 ` Rusty Russell
2009-01-07 16:39 ` Paul Menage
2008-12-31 11:56 ` [PATCH 0/6] cpuset: convert to new cpumask API Mike Travis
2008-12-31 13:26 ` Rusty Russell
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=20090104234659.19e62245.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizf@cn.fujitsu.com \
--cc=menage@google.com \
--cc=mingo@elte.hu \
--cc=rusty@rustcorp.com.au \
--cc=travis@sgi.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.