Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751243AbdH2EqD (ORCPT ); Tue, 29 Aug 2017 00:46:03 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:55854 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750758AbdH2EqB (ORCPT ); Tue, 29 Aug 2017 00:46:01 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E361D6072E Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=pkondeti@codeaurora.org MIME-Version: 1.0 In-Reply-To: <20170825102008.4626-3-patrick.bellasi@arm.com> References: <20170825102008.4626-1-patrick.bellasi@arm.com> <20170825102008.4626-3-patrick.bellasi@arm.com> From: Pavan Kondeti Date: Tue, 29 Aug 2017 10:15:58 +0530 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC 2/3] sched/fair: use util_est in LB To: Patrick Bellasi Cc: LKML , linux-pm@vger.kernel.org, Ingo Molnar , Peter Zijlstra , "Rafael J . Wysocki" , Paul Turner , Vincent Guittot , John Stultz , Morten Rasmussen , Dietmar Eggemann , Juri Lelli , Tim Murray , Todd Kjos , Andres Oportus , Joel Fernandes , Viresh Kumar Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2531 Lines: 68 On Fri, Aug 25, 2017 at 3:50 PM, Patrick Bellasi wrote: > When the scheduler looks at the CPU utlization, the current PELT value > for a CPU is returned straight away. In certain scenarios this can have > undesired side effects on task placement. > > +/** > + * cpu_util_est: estimated utilization for the specified CPU > + * @cpu: the CPU to get the estimated utilization for > + * > + * The estimated utilization of a CPU is defined to be the maximum between its > + * PELT's utilization and the sum of the estimated utilization of the tasks > + * currently RUNNABLE on that CPU. > + * > + * This allows to properly represent the expected utilization of a CPU which > + * has just got a big task running since a long sleep period. At the same time > + * however it preserves the benefits of the "blocked load" in describing the > + * potential for other tasks waking up on the same CPU. > + * > + * Return: the estimated utlization for the specified CPU > + */ > +static inline unsigned long cpu_util_est(int cpu) > +{ > + struct sched_avg *sa = &cpu_rq(cpu)->cfs.avg; > + unsigned long util = cpu_util(cpu); > + > + if (!sched_feat(UTIL_EST)) > + return util; > + > + return max(util, util_est(sa, UTIL_EST_LAST)); > +} > + > static inline int task_util(struct task_struct *p) > { > return p->se.avg.util_avg; > @@ -6007,11 +6033,19 @@ static int cpu_util_wake(int cpu, struct task_struct *p) > > /* Task has no contribution or is new */ > if (cpu != task_cpu(p) || !p->se.avg.last_update_time) > - return cpu_util(cpu); > + return cpu_util_est(cpu); > > capacity = capacity_orig_of(cpu); > util = max_t(long, cpu_rq(cpu)->cfs.avg.util_avg - task_util(p), 0); > > + /* > + * Estimated utilization tracks only tasks already enqueued, but still > + * sometimes can return a bigger value than PELT, for example when the > + * blocked load is negligible wrt the estimated utilization of the > + * already enqueued tasks. > + */ > + util = max_t(long, util, cpu_util_est(cpu)); > + We are supposed to discount the task's util from its CPU. But the cpu_util_est() can potentially return cpu_util() which includes the task's utilization. Thanks, Pavan -- Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project