Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 3297
b: refs/heads/master
c: 245af2c
h: refs/heads/master
i:
  3295: ff24905
v: v3
  • Loading branch information
Suresh Siddha authored and Linus Torvalds committed Jun 25, 2005
1 parent 3f623fc commit b072778
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 41c7ce9ad9a859871dffbe7dbc8b1f9571724e3c
refs/heads/master: 245af2c7870bd5940f7bfad19a0a03b32751fbc5
64 changes: 64 additions & 0 deletions trunk/kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -4712,6 +4712,57 @@ static void sched_domain_debug(struct sched_domain *sd, int cpu)
#define sched_domain_debug(sd, cpu) {}
#endif

static int __devinit sd_degenerate(struct sched_domain *sd)
{
if (cpus_weight(sd->span) == 1)
return 1;

/* Following flags need at least 2 groups */
if (sd->flags & (SD_LOAD_BALANCE |
SD_BALANCE_NEWIDLE |
SD_BALANCE_FORK |
SD_BALANCE_EXEC)) {
if (sd->groups != sd->groups->next)
return 0;
}

/* Following flags don't use groups */
if (sd->flags & (SD_WAKE_IDLE |
SD_WAKE_AFFINE |
SD_WAKE_BALANCE))
return 0;

return 1;
}

static int __devinit sd_parent_degenerate(struct sched_domain *sd,
struct sched_domain *parent)
{
unsigned long cflags = sd->flags, pflags = parent->flags;

if (sd_degenerate(parent))
return 1;

if (!cpus_equal(sd->span, parent->span))
return 0;

/* Does parent contain flags not in child? */
/* WAKE_BALANCE is a subset of WAKE_AFFINE */
if (cflags & SD_WAKE_AFFINE)
pflags &= ~SD_WAKE_BALANCE;
/* Flags needing groups don't count if only 1 group in parent */
if (parent->groups == parent->groups->next) {
pflags &= ~(SD_LOAD_BALANCE |
SD_BALANCE_NEWIDLE |
SD_BALANCE_FORK |
SD_BALANCE_EXEC);
}
if (~cflags & pflags)
return 0;

return 1;
}

/*
* Attach the domain 'sd' to 'cpu' as its base domain. Callers must
* hold the hotplug lock.
Expand All @@ -4722,6 +4773,19 @@ void __devinit cpu_attach_domain(struct sched_domain *sd, int cpu)
unsigned long flags;
runqueue_t *rq = cpu_rq(cpu);
int local = 1;
struct sched_domain *tmp;

/* Remove the sched domains which do not contribute to scheduling. */
for (tmp = sd; tmp; tmp = tmp->parent) {
struct sched_domain *parent = tmp->parent;
if (!parent)
break;
if (sd_parent_degenerate(tmp, parent))
tmp->parent = parent->parent;
}

if (sd && sd_degenerate(sd))
sd = sd->parent;

sched_domain_debug(sd, cpu);

Expand Down

0 comments on commit b072778

Please sign in to comment.