From patchwork Wed Oct 4 08:04:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 114754 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2822336qgn; Wed, 4 Oct 2017 01:04:59 -0700 (PDT) X-Received: by 10.101.69.74 with SMTP id x10mr17823266pgr.294.1507104299625; Wed, 04 Oct 2017 01:04:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507104299; cv=none; d=google.com; s=arc-20160816; b=P8udUSxz5i5AQkjbWk3OgdGE4f51MiJJjAwOFodJaQzBCvKP47P+U6U4wjm/ZnOtoP VRHIpqmIJwQSD63tJ8JBJOYeavDAAhAlwtDvOCtnJuK6+sbT0J29jI1AouSeE2Dj3sAU Fol1jqmSVwTJR1A+ESpHEG9DauhEmwX5zTc3tKSlet6t/zLH52uyk+NeTYLS1WRNxhkS 4gTaOweyd6hfKsefmAT+dBSb/WPSSoLE0tsmjfG9tr0jRCoBeX1s4rymSrqhNs0vUzk5 I5aCfYLx26ncNQmkcJNcZzgyiz09Lgypv0ekOx6ESFEV+rW+9c/0WtUdCtzq6fm8fpGU 7v6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=rJ1ArqNcMApyvCITKI9N4wWAj8PomZSMnopYgGiIfis=; b=Xe+qhIp7KmB26RzfH8knZr7+tpVDNTE92q8Uh3i+h4cA/x/wqk0NUa7SY9seOpzpJy 0dJtp8cU3PDif2G8BZRRO8hEUGNaP6Aba+lZ3yYpq5OEGpCiXVixGC3Zl1X3pafuKbs1 FuhoIqSlN13a99NfBW1XM5GH2gKvE+McclI6GxsVghZ5Hhx0clOWlNXqY+rKB53KKFUi mfXqRsM8ZhDXvhirmHFJriTU2sU1ins44BK3ycwfdjVYBStOBrrdqVElddWbNV1tKoKQ YEEoaVRgxyG2e3FE1Qf0boDNOsrN6msIfh2qWuILa5BO1CBcrb8nveDNd+zMfdzlmpKY THMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MtndpR64; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i4si11244396pfj.577.2017.10.04.01.04.59; Wed, 04 Oct 2017 01:04:59 -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=@linaro.org header.s=google header.b=MtndpR64; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751736AbdJDIE5 (ORCPT + 26 others); Wed, 4 Oct 2017 04:04:57 -0400 Received: from mail-pf0-f177.google.com ([209.85.192.177]:51546 "EHLO mail-pf0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751500AbdJDIEw (ORCPT ); Wed, 4 Oct 2017 04:04:52 -0400 Received: by mail-pf0-f177.google.com with SMTP id n14so3991239pfh.8 for ; Wed, 04 Oct 2017 01:04:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rJ1ArqNcMApyvCITKI9N4wWAj8PomZSMnopYgGiIfis=; b=MtndpR64g/h1snMpwH67FRDAFdIGR9k3cPQwe46APwPFA5134URvh+JUXKdk+LDQA1 Q9RztvyIxHx1GhlrTcNbZvRxXRUPdLhi6sBkqfvzlQAWmPb9HhYErytLaAdh2lcigbGu VsBvKGzrAIRyuWeX/CRWUj5D2kV+oPLLQmfSA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rJ1ArqNcMApyvCITKI9N4wWAj8PomZSMnopYgGiIfis=; b=eZ28oeCkUZULREek3bGwtxJ0hNIHFNeUC+QpAsEcrf/5Rn1A8ANQne/JSVbgqkaQl2 ftFdVih0/OMiCmVd5fV6jedbt1070Sp0i5qTd9gS6hHE/yTTSJXmNaihEFV2Scf23j0I YuufwSv0OU/IEbiS86v+ZQwxfu7pLwuXEvjAlmuRWu9oh8gJPXS0xx4ZojgtRangZd3p sHIJTHen+bRMiukw43QhLDbrN2RSfIsyjybdyM90QyhNratDfxnoJwsohfH0myPYC1kF 9Kd9QBfa1faPNLyKF1F/FjhUwHlH8UQfTN8vlYIOnyGZl7zlDayOgIZwv0bRMFqzyl70 Ls3A== X-Gm-Message-State: AHPjjUjZi5IFiCRe1LpAoG0ffvGzxryAxItBgI5eNyKCYuMBIGppaz2L wDLhIXdP6r2hN09DDj+Skz/p5A== X-Google-Smtp-Source: AOwi7QALIC6+emnBCVBMeknFGzK9vXFJlDjvHZNngw4BNe+TZQhhIAPYHJ1skPuSqhREDtFIjnSwcQ== X-Received: by 10.84.130.108 with SMTP id 99mr19437549plc.343.1507104291586; Wed, 04 Oct 2017 01:04:51 -0700 (PDT) Received: from localhost.localdomain (li1068-205.members.linode.com. [106.184.3.205]) by smtp.gmail.com with ESMTPSA id r12sm21830904pgp.81.2017.10.04.01.04.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 Oct 2017 01:04:50 -0700 (PDT) From: Leo Yan To: Ingo Molnar , Peter Zijlstra , linux-kernel@vger.kernel.org Cc: Leo Yan , Dietmar Eggemann , Morten Rasmussen , Chris Redpath , Joel Fernandes , Vincent Guittot , Patrick Bellasi , "Rafael J . Wysocki" Subject: [PATCH v3 2/2] cpufreq: schedutil: consolidate capacity margin calculation Date: Wed, 4 Oct 2017 16:04:34 +0800 Message-Id: <1507104274-24385-2-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507104274-24385-1-git-send-email-leo.yan@linaro.org> References: <1507104274-24385-1-git-send-email-leo.yan@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Scheduler CFS class has variable 'capacity_margin' to represent the capacity margin, currently in the kernel 'capacity_margin' is 1280; on the other hand schedutil governor also needs to compensate the margin for frequency tipping point. Below are formulas which are used in CFS class and schedutil governor separately, from the formulas we can get to know essentially both of them uses the same margin: CFS: U` = U * capacity_margin / 1024 = U * 1.25 Schedutil: U` = U + U >> 2 = U + U * 0.25 = U * 1.25 This patch consolidates the usage of the capacity margin value and lets schedutil use the same formula as the CFS class. Thus we can avoid the mismatch between schedutil and CFS class if 'capacity_margin' is changed to other values in the future. Cc: Dietmar Eggemann Cc: Morten Rasmussen Cc: Chris Redpath Cc: Joel Fernandes Cc: Vincent Guittot Cc: Patrick Bellasi Cc: Rafael J. Wysocki Signed-off-by: Leo Yan --- kernel/sched/cpufreq_schedutil.c | 7 +++++-- kernel/sched/sched.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 9209d83..79abbaa 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -155,7 +155,9 @@ static void sugov_update_commit(struct sugov_policy *sg_policy, u64 time, * * next_freq = C * curr_freq * util_raw / max * - * Take C = 1.25 for the frequency tipping point at (util / max) = 0.8. + * Take C = capacity_margin >> SCHED_CAPACITY_SHIFT; if capacity_margin is + * 1280 and SCHED_CAPACITY_SHIFT is 10, this results in C = 1.25 and the + * frequency tipping point at (util / max) = 0.8. * * The lowest driver-supported frequency which is equal or greater than the raw * next_freq (as calculated above) is returned, subject to policy min/max and @@ -168,7 +170,8 @@ static unsigned int get_next_freq(struct sugov_policy *sg_policy, unsigned int freq = arch_scale_freq_invariant() ? policy->cpuinfo.max_freq : policy->cur; - freq = (freq + (freq >> 2)) * util / max; + freq = freq * capacity_margin >> SCHED_CAPACITY_SHIFT; + freq = freq * util / max; if (freq == sg_policy->cached_raw_freq && sg_policy->next_freq != UINT_MAX) return sg_policy->next_freq; diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 14db76c..cf75bdc 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -52,6 +52,7 @@ struct cpuidle_state; #define TASK_ON_RQ_MIGRATING 2 extern __read_mostly int scheduler_running; +extern unsigned int capacity_margin __read_mostly; extern unsigned long calc_load_update; extern atomic_long_t calc_load_tasks;