From patchwork Wed Jun 5 05:07:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 17535 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f199.google.com (mail-we0-f199.google.com [74.125.82.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3B47225A2B for ; Wed, 5 Jun 2013 05:07:33 +0000 (UTC) Received: by mail-we0-f199.google.com with SMTP id t56sf1065749wes.6 for ; Tue, 04 Jun 2013 22:07:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-beenthere:x-forwarded-to:x-forwarded-for:delivered-to :mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe :content-type; bh=nHUNuspv5gKejypo99Ta4btuIvwyz2xaHsaPWwS8gPQ=; b=Hi7fRSe5QY2lyQyUTRPMH5AseITOxovtAJqdOwIzYsPInWGbjgM0zo+bUNBFQgF45v Ig/Ig5g/YAi2Wdsguf0cSe7Cu3sNkodIAaAzXBr5LUsw9c0FPlywkkz9DAW+EcPnIhTf fCx8ks4Ql+2V2rEvUnBwstHj5VKHSu6Jt1/kF7Vg8RnMzLpcgI5y4JlerJ/rRL1V/iz3 j6SirRLRFnPIOY1w0sQ+DJ6PPNde2HhgXgyOrxSmf3s9F9UW7djKuNUEiYiyizLRd7iS jYZw3gzN6mpboUvQ1pfp+20LHbM8DxnTMEeSG8bGTdwA1pnbgkw+hGV8m++NhZdakFqg 3LJA== X-Received: by 10.180.160.212 with SMTP id xm20mr1795479wib.0.1370408852051; Tue, 04 Jun 2013 22:07:32 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.180.36.80 with SMTP id o16ls1482300wij.43.canary; Tue, 04 Jun 2013 22:07:31 -0700 (PDT) X-Received: by 10.180.149.171 with SMTP id ub11mr4589994wib.40.1370408851929; Tue, 04 Jun 2013 22:07:31 -0700 (PDT) Received: from mail-ve0-x233.google.com (mail-ve0-x233.google.com [2607:f8b0:400c:c01::233]) by mx.google.com with ESMTPS id li6si20425275wjb.47.2013.06.04.22.07.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 04 Jun 2013 22:07:31 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::233 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::233; Received: by mail-ve0-f179.google.com with SMTP id d10so878331vea.38 for ; Tue, 04 Jun 2013 22:07:30 -0700 (PDT) X-Received: by 10.52.36.115 with SMTP id p19mr16825682vdj.8.1370408850738; Tue, 04 Jun 2013 22:07:30 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.10.206 with SMTP id pb14csp1902vcb; Tue, 4 Jun 2013 22:07:29 -0700 (PDT) X-Received: by 10.229.170.131 with SMTP id d3mr7774953qcz.92.1370408849715; Tue, 04 Jun 2013 22:07:29 -0700 (PDT) Received: from mail-qc0-x236.google.com (mail-qc0-x236.google.com [2607:f8b0:400d:c01::236]) by mx.google.com with ESMTPS id w20si5729892qct.167.2013.06.04.22.07.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 04 Jun 2013 22:07:29 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400d:c01::236 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=2607:f8b0:400d:c01::236; Received: by mail-qc0-f182.google.com with SMTP id n1so664661qcw.41 for ; Tue, 04 Jun 2013 22:07:29 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.229.51.202 with SMTP id e10mr1165316qcg.100.1370408849387; Tue, 04 Jun 2013 22:07:29 -0700 (PDT) Received: by 10.49.1.198 with HTTP; Tue, 4 Jun 2013 22:07:29 -0700 (PDT) In-Reply-To: <51AEC1C3.1040804@linux.vnet.ibm.com> References: <51AEC1C3.1040804@linux.vnet.ibm.com> Date: Wed, 5 Jun 2013 10:37:29 +0530 Message-ID: Subject: Re: [PATCH 1/2] sched: Optimize build_sched_domains() for saving first SD node for a cpu From: Viresh Kumar To: Michael Wang Cc: mingo@redhat.com, peterz@infradead.org, linaro-kernel@lists.linaro.org, patches@linaro.org, linux-kernel@vger.kernel.org, robin.randhawa@arm.com, Steve.Bannister@arm.com, Liviu.Dudau@arm.com, charles.garcia-tobin@arm.com, arvind.chauhan@arm.com X-Gm-Message-State: ALoCoQmPmh4uwaQlOL3F0JeNnly9xOmGDMo++KWhpsiEemgiChtoowo/pJQUaw6vsfLZhlPMWY5C X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::233 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , On 5 June 2013 10:12, Michael Wang wrote: > Hi, Viresh > > On 06/04/2013 07:20 PM, Viresh Kumar wrote: > [snip] >> diff --git a/kernel/sched/core.c b/kernel/sched/core.c >> index 58453b8..638f6cb 100644 >> --- a/kernel/sched/core.c >> +++ b/kernel/sched/core.c >> @@ -6533,16 +6533,13 @@ static int build_sched_domains(const struct cpumask *cpu_map, >> sd = NULL; >> for (tl = sched_domain_topology; tl->init; tl++) { >> sd = build_sched_domain(tl, &d, cpu_map, attr, sd, i); >> + if (!*per_cpu_ptr(d.sd, i)) > > What about: > if (tl == sched_domain_topology) > > It cost less than per_cpu_ptr(), isn't it? How can I miss it.. Obviously its better :) See if below one looks better (Attached too in case gmail screws up my mail).. --------x-------------x------------------ From: Viresh Kumar Date: Tue, 4 Jun 2013 15:41:15 +0530 Subject: [PATCH] sched: Optimize build_sched_domains() for saving first SD node for a cpu We are saving first scheduling domain for a cpu in build_sched_domains() by iterating over the nested sd->child list. We don't actually need to do it this way. tl will be equal to sched_domain_topology for the first iteration and so we can set *per_cpu_ptr(d.sd, i) based on that. So, save pointer to first SD while running the iteration loop over tl's. Signed-off-by: Viresh Kumar --- kernel/sched/core.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) /* Build the groups for the domains */ diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 58453b8..08a27be 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6533,16 +6533,13 @@ static int build_sched_domains(const struct cpumask *cpu_map, sd = NULL; for (tl = sched_domain_topology; tl->init; tl++) { sd = build_sched_domain(tl, &d, cpu_map, attr, sd, i); + if (tl == sched_domain_topology) + *per_cpu_ptr(d.sd, i) = sd; if (tl->flags & SDTL_OVERLAP || sched_feat(FORCE_SD_OVERLAP)) sd->flags |= SD_OVERLAP; if (cpumask_equal(cpu_map, sched_domain_span(sd))) break; } - - while (sd->child) - sd = sd->child; - - *per_cpu_ptr(d.sd, i) = sd; }