]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
Merge branch 'sched/cpuset' into sched/urgent
authorIngo Molnar <mingo@elte.hu>
Sat, 6 Sep 2008 19:03:16 +0000 (21:03 +0200)
committerIngo Molnar <mingo@elte.hu>
Sat, 6 Sep 2008 19:03:16 +0000 (21:03 +0200)
1  2 
kernel/sched.c

diff --combined kernel/sched.c
index 1a5f73c1fcdcd12983c6a2eed9ef66e630dca837,d72ee9a0eacd41078b460b1692520d5d1e9d1b97..cc1f81b50b82dddb19658dc4d10dd419087a59fc
@@@ -808,9 -808,9 +808,9 @@@ const_debug unsigned int sysctl_sched_n
  
  /*
   * ratelimit for updating the group shares.
 - * default: 0.5ms
 + * default: 0.25ms
   */
 -const_debug unsigned int sysctl_sched_shares_ratelimit = 500000;
 +unsigned int sysctl_sched_shares_ratelimit = 250000;
  
  /*
   * period over which we measure -rt task cpu usage in us.
@@@ -4178,65 -4178,6 +4178,65 @@@ void account_steal_time(struct task_str
                cpustat->steal = cputime64_add(cpustat->steal, tmp);
  }
  
 +/*
 + * Use precise platform statistics if available:
 + */
 +#ifdef CONFIG_VIRT_CPU_ACCOUNTING
 +cputime_t task_utime(struct task_struct *p)
 +{
 +      return p->utime;
 +}
 +
 +cputime_t task_stime(struct task_struct *p)
 +{
 +      return p->stime;
 +}
 +#else
 +cputime_t task_utime(struct task_struct *p)
 +{
 +      clock_t utime = cputime_to_clock_t(p->utime),
 +              total = utime + cputime_to_clock_t(p->stime);
 +      u64 temp;
 +
 +      /*
 +       * Use CFS's precise accounting:
 +       */
 +      temp = (u64)nsec_to_clock_t(p->se.sum_exec_runtime);
 +
 +      if (total) {
 +              temp *= utime;
 +              do_div(temp, total);
 +      }
 +      utime = (clock_t)temp;
 +
 +      p->prev_utime = max(p->prev_utime, clock_t_to_cputime(utime));
 +      return p->prev_utime;
 +}
 +
 +cputime_t task_stime(struct task_struct *p)
 +{
 +      clock_t stime;
 +
 +      /*
 +       * Use CFS's precise accounting. (we subtract utime from
 +       * the total, to make sure the total observed by userspace
 +       * grows monotonically - apps rely on that):
 +       */
 +      stime = nsec_to_clock_t(p->se.sum_exec_runtime) -
 +                      cputime_to_clock_t(task_utime(p));
 +
 +      if (stime >= 0)
 +              p->prev_stime = max(p->prev_stime, clock_t_to_cputime(stime));
 +
 +      return p->prev_stime;
 +}
 +#endif
 +
 +inline cputime_t task_gtime(struct task_struct *p)
 +{
 +      return p->gtime;
 +}
 +
  /*
   * This function gets called by the timer code, with HZ frequency.
   * We call it with interrupts disabled.
@@@ -4728,52 -4669,6 +4728,52 @@@ int __sched wait_for_completion_killabl
  }
  EXPORT_SYMBOL(wait_for_completion_killable);
  
 +/**
 + *    try_wait_for_completion - try to decrement a completion without blocking
 + *    @x:     completion structure
 + *
 + *    Returns: 0 if a decrement cannot be done without blocking
 + *             1 if a decrement succeeded.
 + *
 + *    If a completion is being used as a counting completion,
 + *    attempt to decrement the counter without blocking. This
 + *    enables us to avoid waiting if the resource the completion
 + *    is protecting is not available.
 + */
 +bool try_wait_for_completion(struct completion *x)
 +{
 +      int ret = 1;
 +
 +      spin_lock_irq(&x->wait.lock);
 +      if (!x->done)
 +              ret = 0;
 +      else
 +              x->done--;
 +      spin_unlock_irq(&x->wait.lock);
 +      return ret;
 +}
 +EXPORT_SYMBOL(try_wait_for_completion);
 +
 +/**
 + *    completion_done - Test to see if a completion has any waiters
 + *    @x:     completion structure
 + *
 + *    Returns: 0 if there are waiters (wait_for_completion() in progress)
 + *             1 if there are no waiters.
 + *
 + */
 +bool completion_done(struct completion *x)
 +{
 +      int ret = 1;
 +
 +      spin_lock_irq(&x->wait.lock);
 +      if (!x->done)
 +              ret = 0;
 +      spin_unlock_irq(&x->wait.lock);
 +      return ret;
 +}
 +EXPORT_SYMBOL(completion_done);
 +
  static long __sched
  sleep_on_common(wait_queue_head_t *q, int state, long timeout)
  {
@@@ -5845,8 -5740,6 +5845,8 @@@ static inline void sched_init_granulari
                sysctl_sched_latency = limit;
  
        sysctl_sched_wakeup_granularity *= factor;
 +
 +      sysctl_sched_shares_ratelimit *= factor;
  }
  
  #ifdef CONFIG_SMP
@@@ -7696,24 -7589,27 +7696,27 @@@ static int dattrs_equal(struct sched_do
   * and partition_sched_domains() will fallback to the single partition
   * 'fallback_doms', it also forces the domains to be rebuilt.
   *
+  * If doms_new==NULL it will be replaced with cpu_online_map.
+  * ndoms_new==0 is a special case for destroying existing domains.
+  * It will not create the default domain.
+  *
   * Call with hotplug lock held
   */
  void partition_sched_domains(int ndoms_new, cpumask_t *doms_new,
                             struct sched_domain_attr *dattr_new)
  {
-       int i, j;
+       int i, j, n;
  
        mutex_lock(&sched_domains_mutex);
  
        /* always unregister in case we don't destroy any domains */
        unregister_sched_domain_sysctl();
  
-       if (doms_new == NULL)
-               ndoms_new = 0;
+       n = doms_new ? ndoms_new : 0;
  
        /* Destroy deleted domains */
        for (i = 0; i < ndoms_cur; i++) {
-               for (j = 0; j < ndoms_new; j++) {
+               for (j = 0; j < n; j++) {
                        if (cpus_equal(doms_cur[i], doms_new[j])
                            && dattrs_equal(dattr_cur, i, dattr_new, j))
                                goto match1;
@@@ -7726,7 -7622,6 +7729,6 @@@ match1
  
        if (doms_new == NULL) {
                ndoms_cur = 0;
-               ndoms_new = 1;
                doms_new = &fallback_doms;
                cpus_andnot(doms_new[0], cpu_online_map, cpu_isolated_map);
                dattr_new = NULL;
@@@ -7763,8 -7658,13 +7765,13 @@@ match2
  int arch_reinit_sched_domains(void)
  {
        get_online_cpus();
+       /* Destroy domains first to force the rebuild */
+       partition_sched_domains(0, NULL, NULL);
        rebuild_sched_domains();
        put_online_cpus();
        return 0;
  }
  
@@@ -7848,7 -7748,7 +7855,7 @@@ static int update_sched_domains(struct 
        case CPU_ONLINE_FROZEN:
        case CPU_DEAD:
        case CPU_DEAD_FROZEN:
-               partition_sched_domains(0, NULL, NULL);
+               partition_sched_domains(1, NULL, NULL);
                return NOTIFY_OK;
  
        default:
@@@ -8569,8 -8469,8 +8576,8 @@@ struct task_group *sched_create_group(s
        WARN_ON(!parent); /* root should already exist */
  
        tg->parent = parent;
 -      list_add_rcu(&tg->siblings, &parent->children);
        INIT_LIST_HEAD(&tg->children);
 +      list_add_rcu(&tg->siblings, &parent->children);
        spin_unlock_irqrestore(&task_group_lock, flags);
  
        return tg;