Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933008AbdC2VEp (ORCPT ); Wed, 29 Mar 2017 17:04:45 -0400 Received: from foss.arm.com ([217.140.101.70]:39300 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932509AbdC2VDt (ORCPT ); Wed, 29 Mar 2017 17:03:49 -0400 Subject: Re: [RFC PATCH 2/5] sched/events: Introduce cfs_rq load tracking trace event To: Peter Zijlstra , Steven Rostedt References: <20170328063541.12912-1-dietmar.eggemann@arm.com> <20170328063541.12912-3-dietmar.eggemann@arm.com> <20170328104600.18d36cb0@gandalf.local.home> <20170328164459.tkiqbtb7yaplygng@hirez.programming.kicks-ass.net> Cc: Ingo Molnar , LKML , Matt Fleming , Vincent Guittot , Morten Rasmussen , Juri Lelli , Patrick Bellasi From: Dietmar Eggemann Message-ID: <60375c17-3a2e-bbd3-f7a4-6e206f13c8a5@arm.com> Date: Wed, 29 Mar 2017 23:03:45 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170328164459.tkiqbtb7yaplygng@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2781 Lines: 84 On 03/28/2017 06:44 PM, Peter Zijlstra wrote: > On Tue, Mar 28, 2017 at 10:46:00AM -0400, Steven Rostedt wrote: >> On Tue, 28 Mar 2017 07:35:38 +0100 >> Dietmar Eggemann wrote: [...] > I too suggested that; but then I looked again at that code and we can > actually do this. cfs_rq can be constant propagated and the if > determined at build time. > > Its not immediately obvious from the current code; but if we do > something like the below, it should be clearer. > > --- > Subject: sched/fair: Explicitly generate __update_load_avg() instances > From: Peter Zijlstra > Date: Tue Mar 28 11:08:20 CEST 2017 > > The __update_load_avg() function is an __always_inline because its > used with constant propagation to generate different variants of the > code without having to duplicate it (which would be prone to bugs). Ah, so the if(cfs_rq)/else condition should stay in ___update_load_avg() and I shouldn't move the trace events into the 3 variants? I tried to verify that the if is determined at build time but it's kind of hard with trace_events. > Explicitly instantiate the 3 variants. > > Note that most of this is called from rather hot paths, so reducing > branches is good. > > Signed-off-by: Peter Zijlstra (Intel) > --- > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -2849,7 +2849,7 @@ static u32 __compute_runnable_contrib(u6 > * = u_0 + u_1*y + u_2*y^2 + ... [re-labeling u_i --> u_{i+1}] > */ > static __always_inline int > -__update_load_avg(u64 now, int cpu, struct sched_avg *sa, > +___update_load_avg(u64 now, int cpu, struct sched_avg *sa, > unsigned long weight, int running, struct cfs_rq *cfs_rq) > { > u64 delta, scaled_delta, periods; > @@ -2953,6 +2953,26 @@ __update_load_avg(u64 now, int cpu, stru > return decayed; > } > > +static int > +__update_load_avg_blocked_se(u64 now, int cpu, struct sched_avg *sa) > +{ > + return ___update_load_avg(now, cpu, sa, 0, 0, NULL); > +} > + > +static int > +__update_load_avg_se(u64 now, int cpu, struct sched_avg *sa, > + unsigned long weight, int running) > +{ > + return ___update_load_avg(now, cpu, sa, weight, running, NULL); > +} > + > +static int > +__update_load_avg(u64 now, int cpu, struct sched_avg *sa, > + unsigned long weight, int running, struct cfs_rq *cfs_rq) > +{ > + return ___update_load_avg(now, cpu, sa, weight, running, cfs_rq); > +} Why not reduce the parameter list of these 3 incarnations to 'now, cpu, object'? static int __update_load_avg_blocked_se(u64 now, int cpu, struct sched_entity *se) static int __update_load_avg_se(u64 now, int cpu, struct sched_entity *se) static int __update_load_avg_cfs_rq(u64 now, int cpu, struct cfs_rq *cfs_rq) [...]