From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752085AbcF0Qcj (ORCPT ); Mon, 27 Jun 2016 12:32:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54961 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751944AbcF0Qch (ORCPT ); Mon, 27 Jun 2016 12:32:37 -0400 Date: Mon, 27 Jun 2016 11:32:36 -0500 From: Josh Poimboeuf To: Peter Zijlstra Cc: Ingo Molnar , linux-kernel@vger.kernel.org, Mel Gorman , Matt Fleming , Srikar Dronamraju Subject: Re: [PATCH 4/5] sched/debug: remove several CONFIG_SCHEDSTATS guards Message-ID: <20160627163236.so6byunieylj5amx@treble> References: <20160627162111.GF30909@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20160627162111.GF30909@twins.programming.kicks-ass.net> User-Agent: Mutt/1.6.0.1 (2016-04-01) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 27 Jun 2016 16:32:37 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 27, 2016 at 06:21:11PM +0200, Peter Zijlstra wrote: > On Fri, Jun 17, 2016 at 12:43:26PM -0500, Josh Poimboeuf wrote: > > index 017a4f5..0aee5dd 100644 > > --- a/kernel/sched/core.c > > +++ b/kernel/sched/core.c > > @@ -1626,10 +1626,15 @@ static inline int __set_cpus_allowed_ptr(struct task_struct *p, > > static void > > ttwu_stat(struct task_struct *p, int cpu, int wake_flags) > > { > > -#ifdef CONFIG_SCHEDSTATS > > - struct rq *rq = this_rq(); > > + struct rq *rq; > > + > > + if (!schedstat_enabled()) > > + return; > > + > > + rq = this_rq(); > > > > #ifdef CONFIG_SMP > > +{ > > int this_cpu = smp_processor_id(); > > > > if (cpu == this_cpu) { > > @@ -1651,7 +1656,7 @@ ttwu_stat(struct task_struct *p, int cpu, int wake_flags) > > > > if (wake_flags & WF_MIGRATED) > > schedstat_inc(p->se.statistics.nr_wakeups_migrate); > > - > > +} > > #endif /* CONFIG_SMP */ > > > > schedstat_inc(rq->ttwu_count); > > I did: > > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -1636,10 +1636,7 @@ ttwu_stat(struct task_struct *p, int cpu > rq = this_rq(); > > #ifdef CONFIG_SMP > -{ > - int this_cpu = smp_processor_id(); > - > - if (cpu == this_cpu) { > + if (cpu == rq->cpu) { > schedstat_inc(rq->ttwu_local); > schedstat_inc(p->se.statistics.nr_wakeups_local); > } else { > @@ -1647,7 +1644,7 @@ ttwu_stat(struct task_struct *p, int cpu > > schedstat_inc(p->se.statistics.nr_wakeups_remote); > rcu_read_lock(); > - for_each_domain(this_cpu, sd) { > + for_each_domain(rq->cpu, sd) { > if (cpumask_test_cpu(cpu, sched_domain_span(sd))) { > schedstat_inc(sd->ttwu_wake_remote); > break; > @@ -1658,7 +1655,6 @@ ttwu_stat(struct task_struct *p, int cpu > > if (wake_flags & WF_MIGRATED) > schedstat_inc(p->se.statistics.nr_wakeups_migrate); > -} > #endif /* CONFIG_SMP */ > > schedstat_inc(rq->ttwu_count); Much better, thanks. -- Josh