Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1319195imm; Tue, 5 Jun 2018 12:34:20 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJvQSruau+uLRQSt+VAgT4CeZePkdkWpYys46n5bHcNtlLdDSVXORm1J8JI9rQFZkavT53A X-Received: by 2002:a62:4653:: with SMTP id t80-v6mr21705697pfa.58.1528227260739; Tue, 05 Jun 2018 12:34:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528227260; cv=none; d=google.com; s=arc-20160816; b=E5CHPoHZusZ4K4oANFoNa36dDyd//KClEIQOyv0pV0hMrjnyZBLO5BehSYirve0rAI RUU+kCczXkfIwRbTmRr5z0BzePLaxRJaTk9Uc274R8ErK/uxcBI33jOHn/5MN9Q+lrGu a2L1K+zPYMZedwJiR106weP1MA0GflXcZmvJWhgIbGbSJ+rA7iQuhamdOpR0ZbFnFGn0 QbbEu1cbtBGs2BKou8YlDhSY7SOtvoi5s5xEInrwMNTXUJWMy2SpBCBsBNKSdsXrm98o 2DuMywtTQHIVOPigDv4UKmtgwyeXEfp79eoagu/BDLgTCLgN8thxPY9E4CnYSGuMaKLF IyeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=WWkScfg65X11DKdGW6kXDqX2MyYLKMCnvOBpz7dAHB8=; b=fmG5Q8Cpmsza3vzSCu5/SHcdlCekfEhYyw3F0ySQHZyjVrv+9Od2r3vIC7WSB/bWIm VQ1Oxw5cw3TAYuSBLBDt9+mFEMS5mo/YXSMGkeBmpZNhPkhUCueg/RSmq6wn3tFme93U wucJEKYxC8XumlLu1paBGUF+v5mwv02PPcY6U7P4jFcFSjNhFaCbmv3pfoJrqlwpb7VC AvOsP/R5auu3lZlwXgK+DdMkVPkbBXKW1Zsew8kBEK8DaitpuGcabFtZvSECXS2L3gf3 ISecJ4o3QLYAWJ56OV3AcX6a2rOBr2dPYrA+Aj3zN07qVwx71VQ09u4MP7iTsFmiFQz/ kUvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=dvADcdpg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h1-v6si16564386pgs.221.2018.06.05.12.33.58; Tue, 05 Jun 2018 12:34:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=dvADcdpg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751925AbeFETdV (ORCPT + 99 others); Tue, 5 Jun 2018 15:33:21 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:33255 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751816AbeFETdT (ORCPT ); Tue, 5 Jun 2018 15:33:19 -0400 Received: by mail-pf0-f194.google.com with SMTP id b17-v6so1837215pfi.0 for ; Tue, 05 Jun 2018 12:33:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=WWkScfg65X11DKdGW6kXDqX2MyYLKMCnvOBpz7dAHB8=; b=dvADcdpgS+3Zn0LFl2DuVnNLbVuGzuB4C14Yb7MjmlHD6+6YEzvaXItJNNCYqcy0ws +JDP5X6y09Eu41KnX6Fa7yD1Es2Q4n/KYW1Kq7R811nY1apNl8yZTbmXCl4RtxK6xg0I JgFuhh5i3MfY4m69CWUlFoVnnyELb9vIywVCQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=WWkScfg65X11DKdGW6kXDqX2MyYLKMCnvOBpz7dAHB8=; b=UJJANsEnyK9P6Zl1Kpf/5U+URic7EGnc/ZUymFLfJXUyuTHN2hE2YpA3t0AaMi4NWN gVF31kcTXi/6RaTbbM7dCvqsO9x/8hpJ6I17rArpvvhgTkGepIRRl5ew6TApPZa3fYGq BpDUUYijtHMArQkoS5xF0mLyFGVfNAXFad4zAbncD87WU4U8Ev/iBslI4epML+HLwnuX 9KEr4Sl8MVz2C8kN54yMdoaVVa8oGNccyPo11+uP7YarRHaTCECIWSX3QDABIjLMtcrV redeVspnM2dWPUppYZ5tENtBbeQYX1/aJt4MJjH2iWw6c8YbIhJ+R1nqkrsnmFoodEEt yoFQ== X-Gm-Message-State: ALKqPwdcYz5eRFt/m4k6Awfstmn1ql80hhLR7VAzSXmYcyJ/ltF3v69i hBoT6yJFFfc78LcErI59bMLgtQ== X-Received: by 2002:a62:89db:: with SMTP id n88-v6mr26657296pfk.11.1528227198414; Tue, 05 Jun 2018 12:33:18 -0700 (PDT) Received: from localhost ([2620:0:1000:1600:3122:ea9c:d178:eb]) by smtp.gmail.com with ESMTPSA id g4-v6sm46224432pfg.38.2018.06.05.12.33.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jun 2018 12:33:17 -0700 (PDT) Date: Tue, 5 Jun 2018 12:33:17 -0700 From: Joel Fernandes To: Patrick Bellasi Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Ingo Molnar , Peter Zijlstra , "Rafael J . Wysocki" , Viresh Kumar , Vincent Guittot , Dietmar Eggemann , Morten Rasmussen , Juri Lelli , Joel Fernandes , Steve Muckle , Todd Kjos Subject: Re: [PATCH 2/2] sched/fair: util_est: add running_sum tracking Message-ID: <20180605193317.GA239272@joelaf.mtv.corp.google.com> References: <20180604160600.22052-1-patrick.bellasi@arm.com> <20180604160600.22052-3-patrick.bellasi@arm.com> <20180604174618.GA222053@joelaf.mtv.corp.google.com> <20180605152156.GD32302@e110439-lin> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180605152156.GD32302@e110439-lin> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 05, 2018 at 04:21:56PM +0100, Patrick Bellasi wrote: [..] > > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > > > index f74441be3f44..5d54d6a4c31f 100644 > > > --- a/kernel/sched/fair.c > > > +++ b/kernel/sched/fair.c > > > @@ -3161,6 +3161,8 @@ accumulate_sum(u64 delta, int cpu, struct sched_avg *sa, > > > sa->runnable_load_sum = > > > decay_load(sa->runnable_load_sum, periods); > > > sa->util_sum = decay_load((u64)(sa->util_sum), periods); > > > + if (running) > > > + sa->running_sum = decay_load(sa->running_sum, periods); > > > > > > /* > > > * Step 2 > > > @@ -3176,8 +3178,10 @@ accumulate_sum(u64 delta, int cpu, struct sched_avg *sa, > > > sa->load_sum += load * contrib; > > > if (runnable) > > > sa->runnable_load_sum += runnable * contrib; > > > - if (running) > > > + if (running) { > > > sa->util_sum += contrib * scale_cpu; > > > + sa->running_sum += contrib * scale_cpu; > > > + } > > > > > > return periods; > > > } > > > @@ -3963,6 +3967,12 @@ static inline void util_est_enqueue(struct cfs_rq *cfs_rq, > > > WRITE_ONCE(cfs_rq->avg.util_est.enqueued, enqueued); > > > } > > > > PELT changes look nice and makes sense :) > > That's not strictly speaking a PELT change... it's still more in the > idea to work "on top of PELT" to make it more effective in measuring > the tasks expected required CPU bandwidth. I meant "PELT change" as in change to the code that calculates PELT signals.. > > > +static inline void util_est_enqueue_running(struct task_struct *p) > > > +{ > > > + /* Initilize the (non-preempted) utilization */ > > > + p->se.avg.running_sum = p->se.avg.util_sum; > > > +} > > > + > > > /* > > > * Check if a (signed) value is within a specified (unsigned) margin, > > > * based on the observation that: > > > @@ -4018,7 +4028,7 @@ util_est_dequeue(struct cfs_rq *cfs_rq, struct task_struct *p, bool task_sleep) > > > * Skip update of task's estimated utilization when its EWMA is > > > * already ~1% close to its last activation value. > > > */ > > > - ue.enqueued = (task_util(p) | UTIL_AVG_UNCHANGED); > > > + ue.enqueued = p->se.avg.running_sum / LOAD_AVG_MAX; > > > > I guess we are doing extra division here which adds some cost. Does > > performance look Ok with the change? > > This extra division is there and done only at dequeue time instead of > doing it at each update_load_avg. I know. :) > To be more precise, at each ___update_load_avg we should really update > running_avg by: > > u32 divider = LOAD_AVG_MAX - 1024 + sa->period_contrib; > sa->running_avg = sa->running_sum / divider; > > but, this would imply tracking an additional signal in sched_avg and > doing an additional division at ___update_load_avg() time. > > Morten suggested that, if we accept the rounding errors due to > considering > > divider ~= LOAD_AVG_MAX > > thus discarding the (sa->period_contrib - 1024) correction, then we > can completely skip the tracking of running_avg (thus saving space in > sched_avg) and approximate it at dequeue time as per the code line, > just to compute the new util_est sample to accumulate. > > Does that make sense now? The patch always made sense to me.. I was just pointing out the extra division this patch adds. I agree since its done on dequeue-only, then its probably Ok to do.. thanks, - Joel