From patchwork Fri Sep 22 23:04:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 114111 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp63639qgf; Fri, 22 Sep 2017 16:05:23 -0700 (PDT) X-Received: by 10.98.32.139 with SMTP id m11mr580653pfj.172.1506121523769; Fri, 22 Sep 2017 16:05:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506121523; cv=none; d=google.com; s=arc-20160816; b=uhybNdB2YIUUasXkmfKxukIMhK8vObyUGotJtpnohH3mrLq2mfzc5oHoihbmvH53H2 HD36VPSJAspbUjWTFEDD+T7zditGetE74kkIpCoHsioJCh7O4DnPSbfsym3fuOgaPlv5 9kKLzITbIXtc/dD0IByLBmnhkcI5hwp4c8NeMUZ/Gabz3HuHZN1n8ZehSMqvPPy0q/5Y /2GB7/58vDIpSHlLZiwRy05i+MVgqQXGDh0TY/L5FledeLNDc9j9prhthtlayn2lsUws 4uVz4XZ1iMJ6xwhhE8X1wPILwzIXLoISkg8gttTY3QMuvmZ/tYM4gEF9DIiltTq6atRy hvIg== 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=iRYDM/4+nf5Ce0SYSQj1qQlsYmZk8YkcHwGnqUtcVRc=; b=V2uQ84U4aUWvJHLTUVk+/Lqz7QX3/rMBEaQvNDwX6YncxE1jvqcOvDcVS179O8Rd9T 320Y/cG7tRuVFBy03t5sJle2TWa7Yyj1/hIYE8NkRDF9PlMbfOOEgEw3Uh2Dp+0hJFhs skz973+I4OTkEOHiwxkk6FbUVhS3EiBBc+11gDC6ogOkIIyrNjohKsXhKQoA1u8PJe68 IWsbo2ErRIqvgi3p1Y1P2gTcjw4eE9HtkfBD8n2UukuxtrfDiM+JYYwGM+b0X/6XgipY dBHdG+qWMh0SousH0AbwWCoOpin4yFj+ZqnXOfUYFeNKDrs2ChTYsPvhq7vCw/oLfi3e vP+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fatR+sLb; 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 n71si459133pfk.593.2017.09.22.16.05.23; Fri, 22 Sep 2017 16:05:23 -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=fatR+sLb; 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 S1752338AbdIVXFU (ORCPT + 26 others); Fri, 22 Sep 2017 19:05:20 -0400 Received: from mail-pg0-f52.google.com ([74.125.83.52]:47106 "EHLO mail-pg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751763AbdIVXFR (ORCPT ); Fri, 22 Sep 2017 19:05:17 -0400 Received: by mail-pg0-f52.google.com with SMTP id d8so1313942pgt.4 for ; Fri, 22 Sep 2017 16:05:17 -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=iRYDM/4+nf5Ce0SYSQj1qQlsYmZk8YkcHwGnqUtcVRc=; b=fatR+sLbbEaQlF1bDn67YpVrmFHZAopWNXJMZHwet11JSqEgPjb/MtTg9JX4tbA3U3 zWTGoJBAQ/jh2ePUtxTcQNdwzx2+qRqoSB0raLLqgBzuyKsneEu+2ToCdQJk3SsWb4DR nF6lzlI3mJ+qGTcdBcXkCzSVHlPl2xXpcwG2c= 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=iRYDM/4+nf5Ce0SYSQj1qQlsYmZk8YkcHwGnqUtcVRc=; b=kowTYPxf9nO7UxeZVDUnjRk+/uBS9XR8yskIWQypGtst5rBi1Hdr1kWarl+cc41Q6+ dezSdhj7528Dj0+04cyN+raWcGPo1DBZGSufqDs/w8rS35qYStjCR7xoNU0smxQ7972f RpDOFNNAbOUyM2NI4PW6Wb834QoXKBXK5d3bRJdM7atoRXzff9uKkEs0+nkE44ipAPkB lL0Kq9uMq2sOuza2usiEMFp+m3a7whAxv8pQpY0jhsVHK1s0lHTYlJqaEkBsJWiavpJO qPo5LnCo6R0UjjVzBXf+rPWrnw/Tban1FQcBnQnzGE2QZS0HGdpkLTlfvhtsiJ7XZZ8M aI3Q== X-Gm-Message-State: AHPjjUj02WPARnSRP5lbebfThp952wuVgiTPZiIS/RnJcKS/eqp9EjZ/ gZo0FAbPPBWqkbejjwjJxl/dbg== X-Google-Smtp-Source: AOwi7QDhRX5PvnQ4EB1BKrjmK0R1bDdiaEMfVIzFYxRqKDSm0XgrHlWO1iEN9m61gWGTM5LAG4xyCw== X-Received: by 10.84.210.67 with SMTP id z61mr532405plh.125.1506121516840; Fri, 22 Sep 2017 16:05:16 -0700 (PDT) Received: from localhost.localdomain (c-69-181-16-182.hsd1.ca.comcast.net. [69.181.16.182]) by smtp.gmail.com with ESMTPSA id h9sm1049584pfh.98.2017.09.22.16.05.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 Sep 2017 16:05:15 -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 Subject: [PATCH 2/2] cpufreq: schedutil: consolidate capacity margin calculation Date: Sat, 23 Sep 2017 07:04:44 +0800 Message-Id: <1506121484-8260-2-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506121484-8260-1-git-send-email-leo.yan@linaro.org> References: <1506121484-8260-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 calculate the capacity margin, and schedutil governor also needs to compensate the same margin for frequency tipping point. Below are formulas used in CFS class and schedutil governor separately: 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 capacity margin calculation so let schedutil to use same formula with CFS class. As result this can avoid the mismatch issue between schedutil and CFS class after change 'capacity_margin' to other values. Cc: Dietmar Eggemann Cc: Morten Rasmussen Cc: Chris Redpath Cc: Joel Fernandes Cc: Vincent Guittot Signed-off-by: Leo Yan --- kernel/sched/cpufreq_schedutil.c | 5 +++-- kernel/sched/sched.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 9209d83..067abbe 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -155,7 +155,8 @@ 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 / 1024 = 1.25, so it's for 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 +169,7 @@ 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 / 1024) * 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;