* [PATCH 2.6.12-rc6-mm1] add allowed CPUs check into find_idlest_{group|cpu}()
@ 2005-06-08 3:22 M.Baris Demiray
2005-06-08 0:49 ` Nick Piggin
0 siblings, 1 reply; 6+ messages in thread
From: M.Baris Demiray @ 2005-06-08 3:22 UTC (permalink / raw)
To: Nick Piggin; +Cc: Andrew Morton, LKML
[-- Attachment #1: Type: text/plain, Size: 2087 bytes --]
Hello Nick,
a new patch related with recent thread is appended.
I check for CPUs only, ie. not for intersection, in find_idlest_cpu()
since there should be one-to-one comparison when finding CPU. But I
take intersection of group's CPUs and current task's allowed CPUs in
find_allowed_group(). Comments?
o add allowed CPUs check into find_idlest_group() and find_idlest_cpu()
o change the header of find_idlest_cpu() to be able to access
allowed CPUs of current task.
diffstat:
sched.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
--- linux-2.6.12-rc6-mm1/kernel/sched.c.orig 2005-06-08
00:28:59.000000000 +0000
+++ linux-2.6.12-rc6-mm1/kernel/sched.c 2005-06-08 02:28:28.000000000 +0000
@@ -1039,8 +1039,11 @@
int local_group;
int i;
+ /* Loop over if group has no CPUs allowed */
+ if (!cpus_intersects(group->cpumask, p->cpus_allowed))
+ continue;
+
local_group = cpu_isset(this_cpu, group->cpumask);
- /* XXX: put a cpus allowed check */
/* Tally up the load of all CPUs in the group */
avg_load = 0;
@@ -1076,13 +1079,17 @@
/*
* find_idlest_queue - find the idlest runqueue among the cpus in group.
*/
-static int find_idlest_cpu(struct sched_group *group, int this_cpu)
+static int find_idlest_cpu(struct sched_group *group, struct
task_struct *p,
+ int this_cpu)
{
unsigned long load, min_load = ULONG_MAX;
int idlest = -1;
int i;
for_each_cpu_mask(i, group->cpumask) {
+ if (!cpu_isset(i, p->cpus_allowed))
+ continue;
+
load = source_load(i, 0);
if (load < min_load || (load == min_load && i == this_cpu)) {
@@ -1124,7 +1131,7 @@
if (!group)
goto nextlevel;
- new_cpu = find_idlest_cpu(group, cpu);
+ new_cpu = find_idlest_cpu(group, t, cpu);
if (new_cpu == -1 || new_cpu == cpu)
goto nextlevel;
--
"You have to understand, most of these people are not ready to be
unplugged. And many of them are no inert, so hopelessly dependent
on the system, that they will fight to protect it."
Morpheus
[-- Attachment #2: baris.vcf --]
[-- Type: text/x-vcard, Size: 342 bytes --]
begin:vcard
fn:M.Baris Demiray
n:Demiray;M.Baris
org:Labris Teknoloji
adr:;;Teknokent Silikon Bina No:24 ODTU;Ankara;;06531;Turkey
email;internet:baris@labristeknoloji.com
title:Yazilim Gelistirme Uzmani
tel;work:+903122101490
tel;fax:+903122101492
x-mozilla-html:FALSE
url:http://www.labristeknoloji.com
version:2.1
end:vcard
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 2.6.12-rc6-mm1] add allowed CPUs check into find_idlest_{group|cpu}()
2005-06-08 3:22 [PATCH 2.6.12-rc6-mm1] add allowed CPUs check into find_idlest_{group|cpu}() M.Baris Demiray
@ 2005-06-08 0:49 ` Nick Piggin
2005-06-08 21:07 ` M.Baris Demiray
0 siblings, 1 reply; 6+ messages in thread
From: Nick Piggin @ 2005-06-08 0:49 UTC (permalink / raw)
To: M.Baris Demiray; +Cc: Andrew Morton, lkml
On Wed, 2005-06-08 at 03:22 +0000, M.Baris Demiray wrote:
> Hello Nick,
> a new patch related with recent thread is appended.
>
Hi,
> I check for CPUs only, ie. not for intersection, in find_idlest_cpu()
> since there should be one-to-one comparison when finding CPU. But I
> take intersection of group's CPUs and current task's allowed CPUs in
> find_allowed_group(). Comments?
>
Getting better. Thanks.
By taking the intersection in find_idlest_cpu, I don't mean checking
whether or not they intersect as in find_idlest_group. I mean doing
this:
cpumask_t tmp;
/* Find the intersection */
cpus_and(tmp, group->cpumask, p->cpus_allowed);
for_each_cpu_mask(i, tmp) {
Right? That is effectively the same as what you've got in your patch,
but it means we don't need to do the cpumask comparison every time
around the loop (aside from being an extra branch, the actual operation
itself gets a little costly with huge cpu masks).
Nick
--
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 2.6.12-rc6-mm1] add allowed CPUs check into find_idlest_{group|cpu}()
2005-06-08 0:49 ` Nick Piggin
@ 2005-06-08 21:07 ` M.Baris Demiray
2005-06-09 0:24 ` Nick Piggin
0 siblings, 1 reply; 6+ messages in thread
From: M.Baris Demiray @ 2005-06-08 21:07 UTC (permalink / raw)
To: Nick Piggin; +Cc: Andrew Morton, LKML
[-- Attachment #1: Type: text/plain, Size: 2369 bytes --]
Nick Piggin wrote:
> [...]
> Hi,
Hi Nick,
> [...]
>
> By taking the intersection in find_idlest_cpu, I don't mean checking
> whether or not they intersect as in find_idlest_group. I mean doing
> this:
>
>
> cpumask_t tmp;
>
> /* Find the intersection */
> cpus_and(tmp, group->cpumask, p->cpus_allowed);
>
> for_each_cpu_mask(i, tmp) {
>
> Right? That is effectively the same as what you've got in your patch,
> but it means we don't need to do the cpumask comparison every time
> around the loop (aside from being an extra branch, the actual operation
> itself gets a little costly with huge cpu masks).
You're right, I got it. Updated version is appended.
--- linux-2.6.12-rc6-mm1/kernel/sched.c.orig 2005-06-08
00:28:59.000000000 +0000
+++ linux-2.6.12-rc6-mm1/kernel/sched.c 2005-06-08 20:45:25.000000000 +0000
@@ -1039,8 +1039,11 @@
int local_group;
int i;
+ /* Loop over if group has no CPUs allowed */
+ if (!cpus_intersects(group->cpumask, p->cpus_allowed))
+ continue;
+
local_group = cpu_isset(this_cpu, group->cpumask);
- /* XXX: put a cpus allowed check */
/* Tally up the load of all CPUs in the group */
avg_load = 0;
@@ -1076,13 +1079,17 @@
/*
* find_idlest_queue - find the idlest runqueue among the cpus in group.
*/
-static int find_idlest_cpu(struct sched_group *group, int this_cpu)
+static int find_idlest_cpu(struct sched_group *group, struct
task_struct *p,
+ int this_cpu)
{
unsigned long load, min_load = ULONG_MAX;
int idlest = -1;
int i;
+ cpumask_t allowed_cpus;
- for_each_cpu_mask(i, group->cpumask) {
+ /* Traverse only the allowed CPUs */
+ cpus_and(allowed_cpus, group->cpumask, p->cpus_allowed);
+ for_each_cpu_mask(i, allowed_cpus) {
load = source_load(i, 0);
if (load < min_load || (load == min_load && i == this_cpu)) {
@@ -1124,7 +1131,7 @@
if (!group)
goto nextlevel;
- new_cpu = find_idlest_cpu(group, cpu);
+ new_cpu = find_idlest_cpu(group, t, cpu);
if (new_cpu == -1 || new_cpu == cpu)
goto nextlevel;
PS: Thanks for your help and patience :-)
> Nick
>
--
"You have to understand, most of these people are not ready to be
unplugged. And many of them are no inert, so hopelessly dependent
on the system, that they will fight to protect it."
Morpheus
[-- Attachment #2: baris.vcf --]
[-- Type: text/x-vcard, Size: 342 bytes --]
begin:vcard
fn:M.Baris Demiray
n:Demiray;M.Baris
org:Labris Teknoloji
adr:;;Teknokent Silikon Bina No:24 ODTU;Ankara;;06531;Turkey
email;internet:baris@labristeknoloji.com
title:Yazilim Gelistirme Uzmani
tel;work:+903122101490
tel;fax:+903122101492
x-mozilla-html:FALSE
url:http://www.labristeknoloji.com
version:2.1
end:vcard
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 2.6.12-rc6-mm1] add allowed CPUs check into find_idlest_{group|cpu}()
2005-06-08 21:07 ` M.Baris Demiray
@ 2005-06-09 0:24 ` Nick Piggin
2005-06-09 10:08 ` M.Baris Demiray
0 siblings, 1 reply; 6+ messages in thread
From: Nick Piggin @ 2005-06-09 0:24 UTC (permalink / raw)
To: M.Baris Demiray; +Cc: Andrew Morton, LKML
M.Baris Demiray wrote:
>
>
> You're right, I got it. Updated version is appended.
>
Looks good, thanks. I'll test it here and queue it up to
send to Andrew. Will you send me a Signed-off-by: line to
go with that?
--
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 2.6.12-rc6-mm1] add allowed CPUs check into find_idlest_{group|cpu}()
2005-06-09 0:24 ` Nick Piggin
@ 2005-06-09 10:08 ` M.Baris Demiray
2005-06-09 12:01 ` Nick Piggin
0 siblings, 1 reply; 6+ messages in thread
From: M.Baris Demiray @ 2005-06-09 10:08 UTC (permalink / raw)
To: Nick Piggin; +Cc: LKML
[-- Attachment #1: Type: text/plain, Size: 2095 bytes --]
Nick Piggin wrote:
> [...]
> Looks good, thanks. I'll test it here and queue it up to
> send to Andrew. Will you send me a Signed-off-by: line to
> go with that?
Ops, thanks. Latest one is appended again (also not wrapped this time) and..
o Add relevant checks into find_idlest_group() and find_idlest_cpu()
to make them return only the groups that have allowed CPUs and allowed
CPUs respectively.
Signed-off-by: M.Baris Demiray <baris@labristeknoloji.com>
--- linux-2.6.12-rc6-mm1/kernel/sched.c.orig 2005-06-08 00:28:59.000000000 +0000
+++ linux-2.6.12-rc6-mm1/kernel/sched.c 2005-06-08 20:45:25.000000000 +0000
@@ -1039,8 +1039,11 @@
int local_group;
int i;
+ /* Loop over if group has no CPUs allowed */
+ if (!cpus_intersects(group->cpumask, p->cpus_allowed))
+ continue;
+
local_group = cpu_isset(this_cpu, group->cpumask);
- /* XXX: put a cpus allowed check */
/* Tally up the load of all CPUs in the group */
avg_load = 0;
@@ -1076,13 +1079,17 @@
/*
* find_idlest_queue - find the idlest runqueue among the cpus in group.
*/
-static int find_idlest_cpu(struct sched_group *group, int this_cpu)
+static int find_idlest_cpu(struct sched_group *group, struct task_struct *p,
+ int this_cpu)
{
unsigned long load, min_load = ULONG_MAX;
int idlest = -1;
int i;
+ cpumask_t allowed_cpus;
- for_each_cpu_mask(i, group->cpumask) {
+ /* Traverse only the allowed CPUs */
+ cpus_and(allowed_cpus, group->cpumask, p->cpus_allowed);
+ for_each_cpu_mask(i, allowed_cpus) {
load = source_load(i, 0);
if (load < min_load || (load == min_load && i == this_cpu)) {
@@ -1124,7 +1131,7 @@
if (!group)
goto nextlevel;
- new_cpu = find_idlest_cpu(group, cpu);
+ new_cpu = find_idlest_cpu(group, t, cpu);
if (new_cpu == -1 || new_cpu == cpu)
goto nextlevel;
--
"You have to understand, most of these people are not ready to be
unplugged. And many of them are no inert, so hopelessly dependent
on the system, that they will fight to protect it."
Morpheus
[-- Attachment #2: baris.vcf --]
[-- Type: text/x-vcard, Size: 342 bytes --]
begin:vcard
fn:M.Baris Demiray
n:Demiray;M.Baris
org:Labris Teknoloji
adr:;;Teknokent Silikon Bina No:24 ODTU;Ankara;;06531;Turkey
email;internet:baris@labristeknoloji.com
title:Yazilim Gelistirme Uzmani
tel;work:+903122101490
tel;fax:+903122101492
x-mozilla-html:FALSE
url:http://www.labristeknoloji.com
version:2.1
end:vcard
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 2.6.12-rc6-mm1] add allowed CPUs check into find_idlest_{group|cpu}()
2005-06-09 10:08 ` M.Baris Demiray
@ 2005-06-09 12:01 ` Nick Piggin
0 siblings, 0 replies; 6+ messages in thread
From: Nick Piggin @ 2005-06-09 12:01 UTC (permalink / raw)
To: M.Baris Demiray; +Cc: LKML
M.Baris Demiray wrote:
>
> Nick Piggin wrote:
> > [...]
>
>> Looks good, thanks. I'll test it here and queue it up to
>> send to Andrew. Will you send me a Signed-off-by: line to
>> go with that?
>
>
> Ops, thanks. Latest one is appended again (also not wrapped this time)
> and..
>
Looks good. I'll queue this up and send it to Andrew when I
get a chance. Thanks!
--
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-06-09 12:02 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-08 3:22 [PATCH 2.6.12-rc6-mm1] add allowed CPUs check into find_idlest_{group|cpu}() M.Baris Demiray
2005-06-08 0:49 ` Nick Piggin
2005-06-08 21:07 ` M.Baris Demiray
2005-06-09 0:24 ` Nick Piggin
2005-06-09 10:08 ` M.Baris Demiray
2005-06-09 12:01 ` Nick Piggin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox