Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp920355ybg; Fri, 18 Oct 2019 09:16:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqxDe4KvxVat6lb0UMa+p92a/y8hUhky1TBSBNezMl53R/BaCmuG4OK0EwYEoytUY0fGT9jC X-Received: by 2002:a17:906:480a:: with SMTP id w10mr9474162ejq.212.1571415410286; Fri, 18 Oct 2019 09:16:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571415410; cv=none; d=google.com; s=arc-20160816; b=QhR0hHLhJy0EW4DGoeF6Cfih2sJponhUGr+MAh7hRAk6OmWR7i4F1l0a/Sdto5nF6b fB/BD4S/YkqiphGw45+eqGNrAO0nt19gdXSNSyaqFwifTAH3W5OuwEezjW5ipjSjGK3U aIOY+YaHUukSpvKQFEcY/NLV6WRe+8n9JaHrAHQMsUZgwYDrq9GmJo2RikIUI9TBxgKi 51fD2YD/VN70t0hoajadz0yf3ois6aKNGFPxAaLzqHTnCaAYpB2kHhe5MixpJqZtQ2vn sMDqV3NLIsBdZxs80NJuan9r8ZLP8Tn8O6TDQunX34MU9O8V+gvXSUgyZCz7SD4OKJpG QF1Q== 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; bh=Th37Qhz4w+8rDn8hj1nGSF7iCLduKVxIPDbgodx/X/4=; b=hFqi3gSWfY0rT/KDDywL6IUX67QgnwMkXZWna9tptJZnG7mgpwErGB7GhLQF5OSvUd 13iVy678Fnw8Zr8NvCc8GtJiHs+VspdIMX2WJaxQpxFOmKW2OQLxC+v64R93GJOFaQb+ 5E+rJTxo5LqnCO2i6oO1Q70uM8WOF5+s/YV47/1WrGBp+dtVTaL+OovS2IGkZFHhx++Q 2kRzgc/4/IsLn4rUVDiHtDD5SpaUYR0Su5n93sfH9cZjsv1WZrAY2nzqagdd3UpMIs9e ZpG1VybiFE6+iEPm+rBd8/U5dyBloOveHjTk9e349gZz68b9J6v/Hnmt7RjZW1D+LpvO B31w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=wHx9JLYh; 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 l24si3971311edq.90.2019.10.18.09.16.26; Fri, 18 Oct 2019 09:16: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; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=wHx9JLYh; 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 S2439841AbfJQOLf (ORCPT + 99 others); Thu, 17 Oct 2019 10:11:35 -0400 Received: from merlin.infradead.org ([205.233.59.134]:53812 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727429AbfJQOLf (ORCPT ); Thu, 17 Oct 2019 10:11:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Th37Qhz4w+8rDn8hj1nGSF7iCLduKVxIPDbgodx/X/4=; b=wHx9JLYh7xxzrCE7aqoGH3Fua QJwrcFlGlCUohbrngB+NjEyamPTc7mGtxcwvweVcZtx/XIKutLSD2ogm5yfjvxwOlExfn1Jw57DVr BS0TKGjt2rZ5Rgyas5jzkO/yfFW5tINKeBYMjxXRkVzaw6P8983Uzaxf3YDokJ6nowjkD7N6Xhpgh pfHLicvC/usacRbdA5TZ0xLZmgSTWep4okwXXMs3ltxeu4QKVaH0H83SAR/RIzeQhQnO/kJbKFkmj 56DsB87diY/jsLgpZ2wu2DAM5jknuVIeO2NHFsgBo+OtModaz001PH25OyaDS0p5l4YImq0V4KSST YHSUK7p+Q==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1iL6Ug-0000JA-Qc; Thu, 17 Oct 2019 14:11:11 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 295513032F8; Thu, 17 Oct 2019 16:10:12 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 7FF8D203BFA9E; Thu, 17 Oct 2019 16:11:07 +0200 (CEST) Date: Thu, 17 Oct 2019 16:11:07 +0200 From: Peter Zijlstra To: Quentin Perret Cc: Douglas Raillard , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, mingo@redhat.com, rjw@rjwysocki.net, viresh.kumar@linaro.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, qperret@qperret.net, patrick.bellasi@matbug.net, dh.han@samsung.com Subject: Re: [RFC PATCH v3 0/6] sched/cpufreq: Make schedutil energy aware Message-ID: <20191017141107.GJ2311@hirez.programming.kicks-ass.net> References: <20191011134500.235736-1-douglas.raillard@arm.com> <20191014145315.GZ2311@hirez.programming.kicks-ass.net> <20191017095015.GI2311@hirez.programming.kicks-ass.net> <20191017111116.GA27006@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191017111116.GA27006@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 17, 2019 at 12:11:16PM +0100, Quentin Perret wrote: > On Thursday 17 Oct 2019 at 11:50:15 (+0200), Peter Zijlstra wrote: > > Now, the thing is, we use map_util_freq() in more places, and should we > > not reflect this increase in C for all of them? That is, why is this > > patch changing get_next_freq() and not map_util_freq(). > > > > I don't think that question is answered in the Changelogs. > > > > Exactly because it does change the energy consumption (it must) should > > that not also be reflected in the EAS logic? > > Right that shouldn't hurt and keep things consistent. That probably > won't have a huge impact in practice (the boost should be != 0 only when > the util signals haven't converged IIUC, which is a case where the EAS > calculation is already 'wrong' anyway), but that still feels like the > right thing to do. It only boosts when 'rq->cfs.avg.util' increases while 'rq->cfs.avg.util_est.enqueued' remains unchanged (and util > util_est obv). This condition can be true for select_task_rq_fair(), because that is ran before we do enqueue_task_fair() (for obvious raisins). > > I'm still thinking about the exact means you're using to raise C; that > > is, the 'util - util_est' as cost_margin. It hurts my brain still. > > +1 ... cost_i = capacity_i / power_i ; for the i-th OPP We then do: 'x = util - util_avg' and use that on the first OPP >= min_freq: cost(x) = cost_j + cost_j * x ; freq_j >= min_freq = cost_j * (1 + x) And then we find the highest OPP that has: cost_k <= cost(x) Now, 'P = C*V^2*f', which under 'V ~ f' turns into 'P ~ f^3'. (this assumption is important because we don't have V_i, but know that when f increases, V also increases and the linear relation is the simplest) This then gives us: capacity_i = f_i / f_max power_i ~ f_i ^ 3 cost_i = capacity_i / power_i ~ (f_i / f_max) / f_i^3 ~ 1 / (f_max * f_i^2) (your changelog already called if efficiency, but then went on calling it cost; as per the above, you see that higher frequencies have lower efficiency, as expected) cost(x) then turns into something like: cost(x) = cost_j * (1 + x) ~ (1 + x) / (f_max * f_j^2) We then get the following equation (assuming inf. OPPs): cost_k = cost(x) 1 / (f_max * f_k^2) = (1 + x) / (f_max * f_j^2) From which we can solve f_k: f_k = f_j / sqrt(1 + x) ; x = util - util_est Which, given positive 'x' results in f_k < f_j, IOW. we're selecting a lower frequency. Given that 'cost' really is efficiency, and we've made the equations about selecting a higher efficiency, that makes sense in so far that it would always end up at the knee in the graph (our most efficient OPP). Is this really what we're wanting to do?