mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Williams <pwil3058@bigpond.net.au>
To: Andrew Morton <akpm@osdl.org>
Cc: "Siddha, Suresh B" <suresh.b.siddha@intel.com>,
	"Chen, Kenneth W" <kenneth.w.chen@intel.com>,
	Con Kolivas <kernel@kolivas.org>, Ingo Molnar <mingo@elte.hu>,
	Nick Piggin <nickpiggin@yahoo.com.au>,
	Mike Galbraith <efault@gmx.de>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH] sched: protect calculation of max_pull from integer wrap
Date: Mon, 27 Mar 2006 12:21:42 +1100	[thread overview]
Message-ID: <44273E26.5090203@bigpond.net.au> (raw)

[-- Attachment #1: Type: text/plain, Size: 1059 bytes --]

Problem:

As the comment above the calculation of max_pull in the function states, 
there is a need to ensure that negative results of the subtractions do 
not wrap around to large numbers.  This has not been implemented for the 
(max_load - busiest_load_per_task) expression and the possible 
consequences are for undesirable movement of tasks from one group to 
another group. E.g. consider a numa system with two nodes, each
node containing four processors.  If there are two processes in node-0 
and with node-1 being completely idle,  one of those processes will be 
moved to node-1 whereas the desired behavior is to retain those two 
processes in node-0.

Fix:

Make sure that max_load is greater than busiest_load_per_task before 
making the calculation.  If it isn't max_pull will be zero and we skip 
directly to out_balanced.

Signed-off-by: Peter Williams <pwil3058@bigpond.com.au>

-- 
Peter Williams                                   pwil3058@bigpond.net.au

"Learning, n. The kind of ignorance distinguishing the studious."
  -- Ambrose Bierce

[-- Attachment #2: smpnice-protect-max_pull-calculation --]
[-- Type: text/plain, Size: 633 bytes --]

Index: MM-2.6.X/kernel/sched.c
===================================================================
--- MM-2.6.X.orig/kernel/sched.c	2006-03-27 11:07:52.000000000 +1100
+++ MM-2.6.X/kernel/sched.c	2006-03-27 12:08:47.000000000 +1100
@@ -2179,6 +2179,8 @@ find_busiest_group(struct sched_domain *
 	 * by pulling tasks to us.  Be careful of negative numbers as they'll
 	 * appear as very large values with unsigned longs.
 	 */
+	if (max_load <= busiest_load_per_task)
+		goto out_balanced;
 
 	/* Don't want to pull so many tasks that a group would go idle */
 	max_pull = min(max_load - avg_load, max_load - busiest_load_per_task);

                 reply	other threads:[~2006-03-27  1:21 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=44273E26.5090203@bigpond.net.au \
    --to=pwil3058@bigpond.net.au \
    --cc=akpm@osdl.org \
    --cc=efault@gmx.de \
    --cc=kenneth.w.chen@intel.com \
    --cc=kernel@kolivas.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=nickpiggin@yahoo.com.au \
    --cc=suresh.b.siddha@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®