lkml.org 
[lkml]   [2011]   [Mar]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[RFC][PATCH 07/14] sched: Simplify finding the lowest sched_domain
    Instead of relying on knowing the build order and various CONFIG_
    flags simply remember the bottom most sched_domain when we created the
    domain hierarchy.

    Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
    LKML-Reference: <new-submission>
    ---
    include/asm-generic/percpu.h | 4 ++++
    kernel/sched.c | 23 +++++++++++++----------
    2 files changed, 17 insertions(+), 10 deletions(-)

    Index: linux-2.6/kernel/sched.c
    ===================================================================
    --- linux-2.6.orig/kernel/sched.c
    +++ linux-2.6/kernel/sched.c
    @@ -6841,11 +6841,13 @@ struct s_data {
    cpumask_var_t nodemask;
    cpumask_var_t send_covered;
    cpumask_var_t tmpmask;
    + struct sched_domain ** __percpu sd;
    struct root_domain *rd;
    };

    enum s_alloc {
    sa_rootdomain,
    + sa_sd,
    sa_tmpmask,
    sa_send_covered,
    sa_nodemask,
    @@ -7080,6 +7082,8 @@ static void __free_domain_allocs(struct
    switch (what) {
    case sa_rootdomain:
    free_rootdomain(d->rd); /* fall through */
    + case sa_sd:
    + free_percpu(d->sd); /* fall through */
    case sa_tmpmask:
    free_cpumask_var(d->tmpmask); /* fall through */
    case sa_send_covered:
    @@ -7100,10 +7104,15 @@ static enum s_alloc __visit_domain_alloc
    return sa_nodemask;
    if (!alloc_cpumask_var(&d->tmpmask, GFP_KERNEL))
    return sa_send_covered;
    + d->sd = alloc_percpu(struct sched_domain *);
    + if (!d->sd) {
    + printk(KERN_WARNING "Cannot alloc per-cpu pointers\n");
    + return sa_tmpmask;
    + }
    d->rd = alloc_rootdomain();
    if (!d->rd) {
    printk(KERN_WARNING "Cannot alloc root domain\n");
    - return sa_tmpmask;
    + return sa_sd;
    }
    return sa_rootdomain;
    }
    @@ -7292,6 +7301,8 @@ static int __build_sched_domains(const s
    sd = __build_mc_sched_domain(&d, cpu_map, attr, sd, i);
    sd = __build_smt_sched_domain(&d, cpu_map, attr, sd, i);

    + *per_cpu_ptr(d.sd, i) = sd;
    +
    for (tmp = sd; tmp; tmp = tmp->parent) {
    tmp->span_weight = cpumask_weight(sched_domain_span(tmp));
    build_sched_groups(&d, tmp, cpu_map, i);
    @@ -7339,15 +7350,7 @@ static int __build_sched_domains(const s

    /* Attach the domains */
    for_each_cpu(i, cpu_map) {
    -#ifdef CONFIG_SCHED_SMT
    - sd = &per_cpu(cpu_domains, i).sd;
    -#elif defined(CONFIG_SCHED_MC)
    - sd = &per_cpu(core_domains, i).sd;
    -#elif defined(CONFIG_SCHED_BOOK)
    - sd = &per_cpu(book_domains, i).sd;
    -#else
    - sd = &per_cpu(phys_domains, i).sd;
    -#endif
    + sd = *per_cpu_ptr(d.sd, i);
    cpu_attach_domain(sd, d.rd, i);
    }




    \
     
     \ /
      Last update: 2011-03-14 16:31    [W:0.021 / U:62.704 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site