Received: by 10.213.65.68 with SMTP id h4csp3803088imn; Tue, 10 Apr 2018 05:04:50 -0700 (PDT) X-Google-Smtp-Source: AIpwx49d02l/493U5eU/T2inw7UAuQp0Q6SIbdyETYMD9FWGYZSWsYHavTQpN0l55Lu6Im+iFQzz X-Received: by 2002:a17:902:1006:: with SMTP id b6-v6mr142240pla.252.1523361890905; Tue, 10 Apr 2018 05:04:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523361890; cv=none; d=google.com; s=arc-20160816; b=MiPtxA/CBapezcjnOKW1d/4UGnRAcYzMgAA4v1fdgHWDAoFaJnWlQbVwjC3+Wvz4xq J+0tyJBaLB57R8SuKADCT8G/0ylT24UDj/jrz8J8SM6TNlxbudkCpra/ut/xMUTqiP+J pR8TXd0oHKtapHBpczz7OfT44RuVuX3b+nGjvtJzU3TR2vgqtbW5CmLc4cEnuvqK/HIJ /PFIxV00Ptrbpx1KkTYNIn5VxQ+tn1eLXZyD4CgRLEykofV2GlUyZafcW1Ko/yNqKFh1 OwV7vpO7JeIhzZYDQNvp/fPuP43ogDE/o/5Z83HYbH8Wmn2R11Sz6NyLb1WE7sOjDqNl wllg== 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:arc-authentication-results; bh=s3+VCuAOmpKQJue72/IfAgXpX4hfJC/jyIyKySKcKUQ=; b=mD/PY8fJfr6MNNVroAMIxdSEwy4JdjAvQ+hZgxEtX8CEWftIpW4ovHSLnshfczcSEU 6U9JnSHCihvloW/XvbVmmBjWaLYMRVvWXpN2M+9kjEhbrfYS8Rj97rLAaJCURKf1a3sq 5q4D4bYORAGM8OVSUEFbIuziLoGdC/cq1rp+D8ARNI1RTiwW2eRq3MCSW1+wLBHj1MOw 17xITFf8ClPe8hor8WkwIlSstB3hVRYwkUfMxm1aoy9vY65OY0M6+eP71HaGHIyNOyMn ceuD8HaaLcyBVLKp5qqShSsTHu4xqi/NjHkb2nbYn5P0RTqp6Jthy+6wh51tIWWFMJlg xVcg== ARC-Authentication-Results: i=1; mx.google.com; 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 q2si1986478pfh.196.2018.04.10.05.04.13; Tue, 10 Apr 2018 05:04:50 -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; 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 S1752870AbeDJL6D (ORCPT + 99 others); Tue, 10 Apr 2018 07:58:03 -0400 Received: from foss.arm.com ([217.140.101.70]:37086 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752645AbeDJL6B (ORCPT ); Tue, 10 Apr 2018 07:58:01 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8303F80D; Tue, 10 Apr 2018 04:58:01 -0700 (PDT) Received: from e110439-lin (e110439-lin.cambridge.arm.com [10.1.210.68]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4DF993F24A; Tue, 10 Apr 2018 04:57:59 -0700 (PDT) Date: Tue, 10 Apr 2018 12:57:56 +0100 From: Patrick Bellasi To: Viresh Kumar Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Ingo Molnar , Peter Zijlstra , "Rafael J . Wysocki" , Vincent Guittot , Dietmar Eggemann , Morten Rasmussen , Juri Lelli , Todd Kjos , Joel Fernandes , Steve Muckle Subject: Re: [PATCH] cpufreq/schedutil: Cleanup and document iowait boost Message-ID: <20180410115756.GI14248@e110439-lin> References: <20180328090721.26068-1-patrick.bellasi@arm.com> <20180405095858.GP3572@vireshk-i7> <20180410104349.GE14248@e110439-lin> <20180410105606.GH7671@vireshk-i7> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180410105606.GH7671@vireshk-i7> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10-Apr 16:26, Viresh Kumar wrote: > On 10-04-18, 11:43, Patrick Bellasi wrote: > > On 05-Apr 15:28, Viresh Kumar wrote: > > What about this new version for the two functions, > > just compile tested: > > > > ---8<--- > > > > static void sugov_set_iowait_boost(struct sugov_cpu *sg_cpu, u64 time, > > unsigned int flags) > > { > > bool iowait = flags & SCHED_CPUFREQ_IOWAIT; > > > > /* Reset boost if the CPU appears to have been idle enough */ > > if (sg_cpu->iowait_boost) { > > s64 delta_ns = time - sg_cpu->last_update; > > > > if (delta_ns > TICK_NSEC) { > > sg_cpu->iowait_boost = iowait > > ? sg_cpu->sg_policy->policy->min : 0; > > Yeah, I see you are trying to optimize it a bit here but this makes > things more confusing I would say :) > > I would just set iowait_boost to 0 and drop the return; from below and > let the code fall through and reach the end of this routine. Yes, that's possible... althought it's in the same scope of the optimization you suggested for the next function, bail out ASAP to avoid other branches. > > sg_cpu->iowait_boost_pending = iowait; > > return; > > } > > } > > > > /* Boost only tasks waking up after IO */ > > if (!iowait) > > return; > > > > /* Ensure IO boost doubles only one time at each frequency increase */ > > if (sg_cpu->iowait_boost_pending) > > return; > > sg_cpu->iowait_boost_pending = true; > > > > /* Double the IO boost at each frequency increase */ > > if (sg_cpu->iowait_boost) { > > sg_cpu->iowait_boost <<= 1; > > if (sg_cpu->iowait_boost > sg_cpu->iowait_boost_max) > > sg_cpu->iowait_boost = sg_cpu->iowait_boost_max; > > return; > > } > > > > /* At first wakeup after IO, start with minimum boost */ > > sg_cpu->iowait_boost = sg_cpu->sg_policy->policy->min; > > } > > > > static void sugov_iowait_boost(struct sugov_cpu *sg_cpu, > > unsigned long *util, unsigned long *max) > > { > > unsigned int boost_util, boost_max; > > > > /* No IOWait boost active */ > > if (!sg_cpu->iowait_boost) > > return; > > > > /* An IO waiting task has just woken up, use the boost value */ > > if (sg_cpu->iowait_boost_pending) { > > sg_cpu->iowait_boost_pending = false; > > } else { > > /* Reduce the boost value otherwise */ > > sg_cpu->iowait_boost >>= 1; > > if (sg_cpu->iowait_boost < sg_cpu->sg_policy->policy->min) { > > sg_cpu->iowait_boost = 0; > > return; > > } > > } > > > > boost_util = sg_cpu->iowait_boost; > > boost_max = sg_cpu->iowait_boost_max; > > > > /* > > * A CPU is boosted only if its current utilization is smaller then > > * the current IO boost level. > > */ > > if (*util * boost_max < *max * boost_util) { > > *util = boost_util; > > *max = boost_max; > > } > > } > > So this is quite different than what you proposed, it is only fixing > the existing problem which I pointed out to. Looks fine, not much > changed really from the current state of code. Yes, maybe... I think we still get the benefit to consolidate all the iowait boost code into just these two function, while instead currently the reset is in sugov_next_freq_shared(). Moreoverer, IMO it's easy to read and with a documentation more aligned... but, lemme post a v2 and then we will see if it still makes sense or I should just drop it. -- #include Patrick Bellasi