From: Linus Torvalds <torvalds@linux-foundation.org>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: Yinghai Lu <yinghai@kernel.org>, Avi Kivity <avi@redhat.com>,
Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] cpumask: alloc blank cpumask left over
Date: Fri, 5 Jun 2009 10:34:35 -0700 (PDT) [thread overview]
Message-ID: <alpine.LFD.2.01.0906051026030.6847@localhost.localdomain> (raw)
In-Reply-To: <200906052311.57762.rusty@rustcorp.com.au>
On Fri, 5 Jun 2009, Rusty Russell wrote:
>
> OK, here's what I've got in my tree. Ingo, I think this should go in the
> current -rc to avoid nasty bugs.
Why is the fix not to simply clear it in alloc?
> BTW, the original alloc_cpumask_var did zero; that was dropped after arguments
> over efficiency and fitting with other interfaces, but I clearly had the old
> semantics in my head for a while.
How could this ever be a efficiency issue? If you allocate cpumasks so
often that it's an efficiency problem, it would seem that you have bigger
issues than the memset. You'll have to initialize them some other way
anyway, so it's not like you can ever really avoid the dirty cachelines.
IOW, why isn't the fix just to clean up the horrible mess that is
alloc_cpumask_var_node() once and for all. Why not something like this?
The end result looks a lot simpler.
Or you could just add in that __GFP_ZERO there, and remove the memset. I
don't care. But the current code just looks messy and crazy, and that
FIXME is bogus. The end of the allocation needs to be cleared regardless.
Linus
---
lib/cpumask.c | 13 ++++---------
1 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/lib/cpumask.c b/lib/cpumask.c
index 1f71b97..272b5e5 100644
--- a/lib/cpumask.c
+++ b/lib/cpumask.c
@@ -101,21 +101,16 @@ bool alloc_cpumask_var_node(cpumask_var_t *mask, gfp_t flags, int node)
#endif
*mask = NULL;
}
-#ifdef CONFIG_DEBUG_PER_CPU_MAPS
if (!*mask) {
+#ifdef CONFIG_DEBUG_PER_CPU_MAPS
printk(KERN_ERR "=> alloc_cpumask_var: failed!\n");
dump_stack();
- }
#endif
- /* FIXME: Bandaid to save us from old primitives which go to NR_CPUS. */
- if (*mask) {
- unsigned char *ptr = (unsigned char *)cpumask_bits(*mask);
- unsigned int tail;
- tail = BITS_TO_LONGS(NR_CPUS - nr_cpumask_bits) * sizeof(long);
- memset(ptr + cpumask_size() - tail, 0, tail);
+ return 0;
}
- return *mask != NULL;
+ memset(cpumask_bits(*mask), 0, cpumask_size());
+ return 1;
}
EXPORT_SYMBOL(alloc_cpumask_var_node);
next prev parent reply other threads:[~2009-06-05 17:36 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-04 21:00 [PATCH] kvm: fix kvm reboot crash when MAXSMP is used Yinghai Lu
2009-06-04 21:01 ` [PATCH] cpumask: alloc blank cpumask left over Yinghai Lu
2009-06-05 4:58 ` Rusty Russell
2009-06-05 5:18 ` Avi Kivity
2009-06-05 5:56 ` Yinghai Lu
2009-06-05 13:41 ` Rusty Russell
2009-06-05 17:34 ` Linus Torvalds [this message]
2009-06-05 17:46 ` Yinghai Lu
2009-06-05 17:57 ` Yinghai Lu
2009-06-06 23:40 ` Rusty Russell
2009-06-06 23:43 ` Rusty Russell
2009-06-06 9:22 ` Avi Kivity
2009-06-06 9:36 ` Yinghai Lu
2009-06-06 9:39 ` Avi Kivity
2009-06-06 10:57 ` Yinghai Lu
2009-06-06 21:50 ` [PATCH 1/6] cpumask: introduce zalloc_cpumask_var Yinghai Lu
2009-06-06 21:51 ` Subject: [PATCH 2/6] cpumask: alloc zeroed cpumask for static cpumask_var_ts Yinghai Lu
2009-06-06 21:52 ` [PATCH 3/6] kvm: fix kvm reboot crash when MAXSMP is used Yinghai Lu
2009-06-06 21:53 ` [PATCH 4/6] x86/cpufreq: use cpumask_copy instead of = Yinghai Lu
2009-06-09 6:57 ` Rusty Russell
2009-06-09 8:13 ` Yinghai Lu
2009-06-10 4:20 ` Rusty Russell
2009-06-10 13:39 ` Dave Jones
2009-06-10 17:01 ` Ingo Molnar
2009-06-09 15:46 ` Linus Torvalds
2009-06-09 16:28 ` Dave Jones
2009-06-09 16:41 ` Linus Torvalds
2009-06-10 4:55 ` Rusty Russell
2009-06-10 6:22 ` Rusty Russell
2009-06-10 11:10 ` S06cpuspeed/2637 is trying to acquire lock (&(&dbs_info->work)->work (was: Re: [PATCH 4/6] x86/cpufreq: use cpumask_copy instead of =) Ingo Molnar
2009-06-10 20:58 ` Dave Jones
2009-06-11 10:52 ` Ingo Molnar
2009-06-20 12:48 ` Ingo Molnar
2009-06-21 19:55 ` Thomas Renninger
2009-06-23 18:17 ` [PATCH] cpufreq: remove dbs_mutex Ingo Molnar
2009-06-23 18:40 ` Ingo Molnar
2009-06-23 18:51 ` Pallipadi, Venkatesh
2009-06-23 19:14 ` Ingo Molnar
2009-06-23 19:24 ` Pallipadi, Venkatesh
2009-06-23 19:32 ` Ingo Molnar
2009-06-25 14:01 ` Fix dead lock in cpufreq for CPU hotplug and suspend for 2.6.30.stable Thomas Renninger
2009-06-25 14:06 ` Thomas Renninger
2009-06-25 14:01 ` [PATCH 1/2] CPUFREQ: Remove unneeded dbs_mutexes from ondemand and conservative governors Thomas Renninger
2009-06-25 14:25 ` Mathieu Desnoyers
2009-06-25 15:03 ` Pallipadi, Venkatesh
2009-06-25 22:17 ` Thomas Renninger
2009-06-25 22:26 ` Thomas Renninger
2009-06-30 6:33 ` Pavel Machek
2009-07-03 10:10 ` Thomas Renninger
2009-07-05 19:46 ` Pavel Machek
2009-06-30 22:58 ` [stable] " Greg KH
2009-06-30 23:14 ` Mathieu Desnoyers
2009-06-30 23:39 ` Greg KH
2009-07-01 9:07 ` Thomas Renninger
2009-06-25 14:01 ` [PATCH 2/2] remove rwsem lock from CPUFREQ_GOV_STOP call (second call site) Thomas Renninger
2009-06-10 19:42 ` [PATCH 4/6] x86/cpufreq: use cpumask_copy instead of = Langsdorf, Mark
2009-06-11 2:34 ` Rusty Russell
2009-09-21 16:44 ` Langsdorf, Mark
2009-06-06 21:55 ` [PATCH 5/6] core: use cpumask_copy instead of = for cpus_allowed in fork Yinghai Lu
2009-06-06 21:56 ` [PATCH 6/6] x86/cpufreq: don't use SPEEDSTEP with MAXSMP Yinghai Lu
2009-06-06 21:56 ` [PATCH 1/6] cpumask: introduce zalloc_cpumask_var Andrew Morton
2009-06-06 22:07 ` Yinghai Lu
2009-06-06 21:58 ` Linus Torvalds
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=alpine.LFD.2.01.0906051026030.6847@localhost.localdomain \
--to=torvalds@linux-foundation.org \
--cc=akpm@linux-foundation.org \
--cc=avi@redhat.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rusty@rustcorp.com.au \
--cc=tglx@linutronix.de \
--cc=yinghai@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome