From patchwork Mon Oct 2 00:30:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 114538 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp104290qgn; Sun, 1 Oct 2017 17:30:40 -0700 (PDT) X-Received: by 10.98.144.142 with SMTP id q14mr12989505pfk.303.1506904240567; Sun, 01 Oct 2017 17:30:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506904240; cv=none; d=google.com; s=arc-20160816; b=F7LOF44ZxgqmD/L1dxFWtjSBzJGQTf2KdqWPOpBIh5ImSiRWgD0iLgv8XlU2iGkqA5 e3oav5MvwW9gOgRg5yff+M4DcalSgH9JWNuLI3+yDAL2QorzaBJjmCnr+sgQlOKe7YO8 0+Z1ViNRpKczoQWxhxwL0SFCh7Ga2d3PgM5mcI/RX9Ny4jJ45BGy4JUMPVD/wcabW4j8 W4hm18L8apZDzv/AsUiJIS+HZhIrqmjBt8rRnmGvo1chQMFuubyxYeHTDANe9pR+H1za keKYFkmM4Zz7WrbHGU7ysnE4fpJ4Iji+oT6Cl2dmuOIi1dO9kUepoQCtBqxa49Y6fu+z Dd1Q== 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=EscfFnBiBX4Go+y2mDGX7Sf4MSgpenDs1EmVogoARRY=; b=PFJoH4lBprm1u1Qf7UxfVlVjbEwcHa2ET9yY6vxlRCK0YzPUdguJeCRysZdASdsQvN K5LDxvDSC8oer3WEhpHx7IyTnGQwoIHNPTmiIsE8i+KyUCK8k6HfFo/Scr3jeHknp7f8 2hvQwQTJ9p6CaIxm9U14fgPvf8KoaN3G4jNSzseLsTQimCe7jvOwZzJMVqcQPmeArr/6 zjEeKGbhJuSJXIDWna+XehVt9EzdUJ1MIQf80aG8dyscFXcqEDCAFIGSnAzQ0A2NU9hr HxHXvOuRVhJ+qKTASglc2N2VXa5vMoUM2VGJ3PT39dGsX8l5An29oe4kCySPmC4XgUVX QR7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hLvtVRXb; 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 y20si99354pll.433.2017.10.01.17.30.40; Sun, 01 Oct 2017 17:30:40 -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=hLvtVRXb; 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 S1751672AbdJBAag (ORCPT + 26 others); Sun, 1 Oct 2017 20:30:36 -0400 Received: from mail-pg0-f54.google.com ([74.125.83.54]:46006 "EHLO mail-pg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751027AbdJBAae (ORCPT ); Sun, 1 Oct 2017 20:30:34 -0400 Received: by mail-pg0-f54.google.com with SMTP id 188so2184001pgb.2 for ; Sun, 01 Oct 2017 17:30:34 -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=EscfFnBiBX4Go+y2mDGX7Sf4MSgpenDs1EmVogoARRY=; b=hLvtVRXbaP0aVjMEEdqeljv/MVqHczirM3JID6cAdHdLTpOP6etOCdgAkppQKcMXKr uxsa9YGDL+Mw00MDXfgeFEHr/GmD5DJUPivuw7xzwDZKfaFmh0PRiyB/tE2suV/N4ast rf97ScLSrTM5wHq8NaPs3RUAB4e/hi0311H2w= 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=EscfFnBiBX4Go+y2mDGX7Sf4MSgpenDs1EmVogoARRY=; b=hd9B3q41Fscwbsa/E8XTF/k1uqaNYE1IofwqhanqjzaOxJ8xajZeCAhthTAGCOQLKE ARrNZgy2qMIsnMmFDp5gHVFxk2vPN5tWHrRvcppwBFn6mzNIufAQQc86MV4Bo3ytoMX7 Mf/HAIVqaT1/dl/ZRqXOkCmsqm8QFkRtGVr/t66tT1PTNgfvKj3DEbdBvLXG+YacgZbP mwqkthnGpO3jvul1sauyy8/z0f8chM9/+bEEUTNncc9g+NYMhq9GhtiqCeoeF9itcBXH PKLzz6W7Psl5boraefDk15QblK3VTZViQhuBrle+tBmcCTTOT68G1QI7o5QAss6+Q764 puCw== X-Gm-Message-State: AHPjjUh6rweiJzmAxr7pT4ihvZ/5cRfvGe1LhEI63qz4bpLYiOyODoYW ByjTSHQreC1nbAZnYebYj8lBTA== X-Google-Smtp-Source: AOwi7QC8tLdE5W9v06jfiULUAyDiGirU93GIUuQYn0XJ482BXHaAMVZdMDbwMwU6tip7fNz0HrZZig== X-Received: by 10.84.173.4 with SMTP id o4mr12867681plb.150.1506904233917; Sun, 01 Oct 2017 17:30:33 -0700 (PDT) Received: from localhost.localdomain (li1068-205.members.linode.com. [106.184.3.205]) by smtp.gmail.com with ESMTPSA id z74sm15306729pfi.156.2017.10.01.17.30.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 01 Oct 2017 17:30:32 -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 v2 2/2] cpufreq: schedutil: consolidate capacity margin calculation Date: Mon, 2 Oct 2017 08:30:12 +0800 Message-Id: <1506904212-15354-2-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506904212-15354-1-git-send-email-leo.yan@linaro.org> References: <1506904212-15354-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 Cc: Patrick Bellasi Cc: Rafael J. Wysocki Signed-off-by: Leo Yan --- kernel/sched/cpufreq_schedutil.c | 6 ++++-- kernel/sched/sched.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 9209d83..13cc243 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,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;