From: Max Krasnyansky <maxk@qualcomm.com>
To: mingo@elte.hu
Cc: pj@sgi.com, a.p.zijlstra@chello.nl, linux-kernel@vger.kernel.org,
menage@google.com, rostedt@goodmis.org,
Max Krasnyansky <maxk@qualcomm.com>
Subject: [PATCH] sched: Fix memory leak in the cpu hotplug handing logic
Date: Mon, 2 Jun 2008 14:08:21 -0700 [thread overview]
Message-ID: <1212440902-31215-1-git-send-email-maxk@qualcomm.com> (raw)
This is an updated/split up version of the patch I sent earlier.
Basically the issue is that we are leaking doms_cur on cpu hotplug events.
doms_cur is allocated in the arch_init_sched_domains() which is called for
every hotplug event. So we just keep reallocating doms_cur without freeing it.
This patch introduces free_sched_domains() function that cleans things up.
Note that doms_cur can also come from cpusets via partition_sched_domains().
That path is already handled correctly.
This just a bug fix and should go into 2.6.26 and probably -stable as well.
Signed-off-by: Max Krasnyansky <maxk@qualcomm.com>
---
kernel/sched.c | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/kernel/sched.c b/kernel/sched.c
index 8dcdec6..465f3c8 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -6855,6 +6855,19 @@ void __attribute__((weak)) arch_update_cpu_topology(void)
}
/*
+ * Free current domain masks.
+ * Called after all cpus are attached to NULL domain.
+ */
+static void free_sched_domains(void)
+{
+ ndoms_cur = 0;
+ if (doms_cur != &fallback_doms) {
+ kfree(doms_cur);
+ doms_cur = &fallback_doms;
+ }
+}
+
+/*
* Set up scheduler domains and groups. Callers must hold the hotplug lock.
* For now this just excludes isolated cpus, but could be used to
* exclude other special cases in the future.
@@ -6974,6 +6987,7 @@ int arch_reinit_sched_domains(void)
get_online_cpus();
detach_destroy_domains(&cpu_online_map);
+ free_sched_domains();
err = arch_init_sched_domains(&cpu_online_map);
put_online_cpus();
@@ -7058,6 +7072,7 @@ static int update_sched_domains(struct notifier_block *nfb,
case CPU_DOWN_PREPARE:
case CPU_DOWN_PREPARE_FROZEN:
detach_destroy_domains(&cpu_online_map);
+ free_sched_domains();
return NOTIFY_OK;
case CPU_UP_CANCELED:
--
1.5.4.5
reply other threads:[~2008-06-02 21:08 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1212440902-31215-1-git-send-email-maxk@qualcomm.com \
--to=maxk@qualcomm.com \
--cc=a.p.zijlstra@chello.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=menage@google.com \
--cc=mingo@elte.hu \
--cc=pj@sgi.com \
--cc=rostedt@goodmis.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