linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "Dietmar Eggemann" <dietmar.eggemann@arm.com>,
	"Michel Dänzer" <michel@daenzer.net>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>
Subject: Re: Random panic in load_balance() with 3.16-rc
Date: Wed, 23 Jul 2014 20:23:09 +0200	[thread overview]
Message-ID: <20140723182309.GB3935@laptop> (raw)
In-Reply-To: <CA+55aFzSU5u8MiGqRZ6BVojQPnxbd1hxmFY_BA=UuCAygxR8WQ@mail.gmail.com>

On Wed, Jul 23, 2014 at 09:54:23AM -0700, Linus Torvalds wrote:
> Alternatively, keep it a "cpumask_var_t", but then you need to use
> __get_cpu_pointer() to get the address of it, and use
> "alloc_cpumask_var()" to allocate area for the OFFSTACK case.
> 
> TOTALLY UNTESTED AND PROBABLY PURE CRAP PATCH ATTACHED.
> 
> WARNING! WARNING! WARNING! This is just looking at the code, not
> really knowing it, and saying "that looks really really wrong". Maybe
> I'm full of shit.

If we're doing that, then we also need to unconditionally allocate
memory for that pointer.

The below is something that seems to be consistent and uses struct
cpumask * as you suggest.

Still wondering how the heck any of that worked and didn't generate more
crashing.

---
 kernel/sched/core.c | 17 +++++++----------
 kernel/sched/fair.c |  4 ++--
 2 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 7bc599dc4aa4..976d520587a8 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6867,7 +6867,7 @@ struct task_group root_task_group;
 LIST_HEAD(task_groups);
 #endif
 
-DECLARE_PER_CPU(cpumask_var_t, load_balance_mask);
+DECLARE_PER_CPU(struct cpumask *, load_balance_mask);
 
 void __init sched_init(void)
 {
@@ -6880,9 +6880,6 @@ void __init sched_init(void)
 #ifdef CONFIG_RT_GROUP_SCHED
 	alloc_size += 2 * nr_cpu_ids * sizeof(void **);
 #endif
-#ifdef CONFIG_CPUMASK_OFFSTACK
-	alloc_size += num_possible_cpus() * cpumask_size();
-#endif
 	if (alloc_size) {
 		ptr = (unsigned long)kzalloc(alloc_size, GFP_NOWAIT);
 
@@ -6902,12 +6899,12 @@ void __init sched_init(void)
 		ptr += nr_cpu_ids * sizeof(void **);
 
 #endif /* CONFIG_RT_GROUP_SCHED */
-#ifdef CONFIG_CPUMASK_OFFSTACK
-		for_each_possible_cpu(i) {
-			per_cpu(load_balance_mask, i) = (void *)ptr;
-			ptr += cpumask_size();
-		}
-#endif /* CONFIG_CPUMASK_OFFSTACK */
+	}
+
+	for_each_possible_cpu(i) {
+		per_cpu(load_balance_mask, i) = kzalloc_node(cpumask_size(),
+							     GFP_NOWAIT,
+							     cpu_to_node(i));
 	}
 
 	init_rt_bandwidth(&def_rt_bandwidth,
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 45943b2fa82b..e4d939dc1084 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6469,7 +6469,7 @@ static struct rq *find_busiest_queue(struct lb_env *env,
 #define MAX_PINNED_INTERVAL	512
 
 /* Working cpumask for load_balance and load_balance_newidle. */
-DEFINE_PER_CPU(cpumask_var_t, load_balance_mask);
+DEFINE_PER_CPU(struct cpumask *, load_balance_mask);
 
 static int need_active_balance(struct lb_env *env)
 {
@@ -6538,7 +6538,7 @@ static int load_balance(int this_cpu, struct rq *this_rq,
 	struct sched_group *group;
 	struct rq *busiest;
 	unsigned long flags;
-	struct cpumask *cpus = __get_cpu_var(load_balance_mask);
+	struct cpumask *cpus = this_cpu_read(load_balance_mask);
 
 	struct lb_env env = {
 		.sd		= sd,

  parent reply	other threads:[~2014-07-23 18:23 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <53C77BB8.6030804@daenzer.net>
2014-07-17  7:58 ` Random panic in load_balance() with 3.16-rc Peter Zijlstra
2014-07-18  9:29   ` Michel Dänzer
2014-07-22  6:13     ` Michel Dänzer
2014-07-23  3:53       ` Michel Dänzer
2014-07-23  4:21         ` Linus Torvalds
2014-07-23  6:49           ` Peter Zijlstra
2014-07-23  8:05             ` Michel Dänzer
2014-07-23  8:28               ` Peter Zijlstra
2014-07-23  9:25                 ` Peter Zijlstra
2014-07-23  9:31                   ` Michel Dänzer
2014-07-23  9:45                     ` Dietmar Eggemann
2014-07-23 11:11                       ` Peter Zijlstra
2014-07-23 11:30                         ` Peter Zijlstra
2014-07-23 14:24                           ` Peter Zijlstra
2014-07-23 14:38                             ` Michel Dänzer
2014-07-23 15:51                             ` Linus Torvalds
     [not found]                               ` <20140723155526.GW3935@laptop>
2014-07-23 16:54                                 ` Linus Torvalds
2014-07-23 17:03                                   ` Peter Zijlstra
2014-07-23 17:12                                     ` Linus Torvalds
2014-07-23 17:26                                       ` Linus Torvalds
2014-07-23 18:25                                         ` Peter Zijlstra
2014-07-23 18:35                                           ` Linus Torvalds
2014-07-23 18:41                                             ` Peter Zijlstra
2014-07-23 18:55                                               ` Linus Torvalds
2014-07-23 19:02                                                 ` Peter Zijlstra
2014-07-23 19:20                                                   ` Linus Torvalds
2014-07-24  1:43                                                     ` Michel Dänzer
2014-07-24 18:47                                                       ` Linus Torvalds
2014-07-24 18:59                                                         ` Peter Zijlstra
2014-07-25  1:25                                                         ` Michel Dänzer
2014-07-25  2:33                                                           ` Linus Torvalds
2014-07-25  2:50                                                             ` Nick Krause
2014-07-25  2:36                                                           ` Nick Krause
2014-07-25  3:55                                                           ` Alexei Starovoitov
2014-07-25  4:00                                                             ` Nick Krause
2014-07-25 14:02                                                             ` Steven Rostedt
2014-07-25 18:29                                                               ` Linus Torvalds
2014-07-25 19:10                                                                 ` Steven Rostedt
2014-07-25 20:01                                                                 ` Linus Torvalds
2014-07-25 20:13                                                                   ` Steven Rostedt
2014-07-25 21:25                                                                   ` Jakub Jelinek
2014-07-26 18:28                                                                 ` Linus Torvalds
2014-07-26 18:39                                                                   ` Linus Torvalds
2014-07-26 19:35                                                                     ` Markus Trippelsdorf
2014-07-26 19:55                                                                       ` Theodore Ts'o
2014-07-26 20:20                                                                         ` Markus Trippelsdorf
2014-07-26 22:08                                                                           ` Jakub Jelinek
2014-07-26 19:56                                                                       ` Linus Torvalds
2014-07-26 20:03                                                                         ` Linus Torvalds
2014-07-26 20:19                                                                         ` Markus Trippelsdorf
2014-07-26 20:39                                                                           ` Linus Torvalds
2014-07-28 12:26                                                                             ` Frank Ch. Eigler
2014-07-28 13:10                                                                               ` Theodore Ts'o
2014-07-28 14:11                                                                                 ` Frank Ch. Eigler
2014-07-28 16:45                                                                               ` Linus Torvalds
2014-07-28 17:27                                                                                 ` Alexei Starovoitov
2014-07-28 18:09                                                                                   ` Markus Trippelsdorf
2014-07-28 18:28                                                                                     ` Linus Torvalds
2014-07-28 18:41                                                                                       ` Markus Trippelsdorf
2014-07-29  8:58                                                                                     ` Jakub Jelinek
2014-07-28 19:50                                                                                   ` Theodore Ts'o
2014-07-28  3:47                                                                         ` Michel Dänzer
2014-07-28 16:48                                                                           ` Linus Torvalds
2014-07-29  2:29                                                                             ` Michel Dänzer
2014-08-05  3:19                                                                 ` Steven Rostedt
2014-07-26 18:02                                                           ` Steven Chamberlain
2014-07-29  9:20                                                             ` Michel Dänzer
2014-07-25  6:48                                                         ` Jakub Jelinek
2014-07-25  8:15                                                           ` Linus Torvalds
2014-07-25  9:03                                                             ` Michel Dänzer
2014-07-25  9:21                                                               ` Markus Trippelsdorf
2014-07-25  9:42                                                                 ` Markus Trippelsdorf
2014-07-23 18:07                                       ` Linus Torvalds
2014-07-23 18:31                                         ` Peter Zijlstra
2014-07-23 18:24                                       ` Peter Zijlstra
2014-07-23 17:04                                   ` Peter Zijlstra
2014-07-23 17:15                                     ` Linus Torvalds
2014-07-23 18:25                                       ` Peter Zijlstra
2014-07-23 18:23                                   ` Peter Zijlstra [this message]
2014-07-23 10:52                     ` Peter Zijlstra
2014-07-24  7:18                     ` Michel Dänzer
2014-07-24  7:51                       ` Peter Zijlstra
2014-07-24  9:55                         ` Peter Zijlstra

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=20140723182309.GB3935@laptop \
    --to=peterz@infradead.org \
    --cc=dietmar.eggemann@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michel@daenzer.net \
    --cc=mingo@redhat.com \
    --cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).