From patchwork Mon Oct 2 00:30:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 114537 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp104203qgn; Sun, 1 Oct 2017 17:30:35 -0700 (PDT) X-Received: by 10.84.244.198 with SMTP id f6mr3196791plt.32.1506904235115; Sun, 01 Oct 2017 17:30:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506904235; cv=none; d=google.com; s=arc-20160816; b=ej/eRZ4Fy/1qhzm6j1J8ZFSklIwaklR4ISevgHxwOy5LzZymScDjQ/It21BszkoIOs Q+Utc4oWGF1o9tEp68lzVZNu3mj9rQOfhYCp/DJu5XkXWUoJrfAwHxF9Uub4RhIOFjEy 0hTdULfYHXURw+VDYTQxKZg8QIoItfR1xGafc0CZIxu3RiyWFeUnIWx5crDuncpId82y zNouwAzrSZzAs47Uo5Cry0w3CCpcMbdzDwwp0IkHH5RYFWyH9K6C0V/JAbaypFRVwa// y+j9Alm21viJp033YkbNHnhStEeApmeFfYLlN97RYp4wH+beeyxW0bFs0KxSGAWDSPFC 26NA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=3pwBSl7T1ecPKWxQGqkdkwXWIDg4+huomt4diow/KdA=; b=GpR63KmhmnPJpVr8qBf43M4DtHfCIR1vUkii5p/Gwm5b4gOaAwJIBpbpszS9rndcZm mj7FZgMdH4URc8d9/81nj5X2T99UBeUJJQTgY43FmcWkhXYCj+VHzMhod6O/cSaT6csy V9GkqYO/ITkhVmZWs9aYtnsbV2n83aXcEfX5W9R6uvUJVeqlecXejD5a0eD69+qpNHJA i46BQS0mr7JzN76Q/Q6QcGtRPKCP6v5v694ShIYHNBqmwhaqqX+9rAZI0kolVR3UF28Z hREe6A/EXOCSj6PbUakXgda8j07GmqgQuzVvTEHopdhtKx0tsXOZfnDWxJkb6+27AXAJ YI+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=X3q4PL/j; 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 60si7053404ple.818.2017.10.01.17.30.34; Sun, 01 Oct 2017 17:30:35 -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=X3q4PL/j; 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 S1751430AbdJBAaa (ORCPT + 26 others); Sun, 1 Oct 2017 20:30:30 -0400 Received: from mail-pg0-f50.google.com ([74.125.83.50]:56455 "EHLO mail-pg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751027AbdJBAa3 (ORCPT ); Sun, 1 Oct 2017 20:30:29 -0400 Received: by mail-pg0-f50.google.com with SMTP id n1so1479034pgt.13 for ; Sun, 01 Oct 2017 17:30:29 -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; bh=3pwBSl7T1ecPKWxQGqkdkwXWIDg4+huomt4diow/KdA=; b=X3q4PL/jTBW+GiyqCa6z/qOHrbftE7xjwIfp+wr+CoQo14f0HI0kcNIO86MD37ULX4 vpqzKhxG453HJth3DPi9/PgTEPy4DayHVYGGmHJDPGPz6xNq6WI71Ol4npTqcpHZwRBf fLdqsatJgcdKXcz8e+wuVXXBDmLDwaES6mNmg= 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; bh=3pwBSl7T1ecPKWxQGqkdkwXWIDg4+huomt4diow/KdA=; b=Ha82EPrbJ+MrHSS1o8RN065Xi6jLHTkWwRx8kbPeEmDCsLKruzr9df60NKIuLcs9U1 nATKAxZAvi0jPhuw71G30fFA/LcHHR1FInfGN3MHKLiVSJj+hgHGyYoe1pZJRVbFq74W 89busWetVFPLjeWmR0zzvWZ5qVhNH7bAxX7scOtf7eUS2zRd/XTVfeR0eFyTxUhrVmwm VxLkYmgwB2fo6q2VA0WxO8/81QVssRTqKb4ilu/cm+H1A45+qC5R/PoIAHDTkJ12IC4A x4Xh3Y8q/HhhSylwWgZVIeMxab8G8XAvW1U2XUUGUnhZRMdOY/x4YLbjyUPLVmGDKn6w KBbA== X-Gm-Message-State: AMCzsaWjmqdyE+CzZUnXr4KW46EeJ2NPJq+ztG11ajixgMJFUXHfA1Uk dVrW8z3WYrA6vOw82BkuR0XSBA== X-Google-Smtp-Source: AOwi7QC4DAB4NDTIFC4k6rS2miOttFGrOHeuZKQcrsgNGT2k5eCg5M9IruXbg+W59+hTBCe7C12awA== X-Received: by 10.99.95.145 with SMTP id t139mr4071882pgb.344.1506904229151; Sun, 01 Oct 2017 17:30:29 -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.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 01 Oct 2017 17:30:27 -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 Subject: [PATCH v2 1/2] sched/fair: make capacity_margin __read_mostly Date: Mon, 2 Oct 2017 08:30:11 +0800 Message-Id: <1506904212-15354-1-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Variable 'capacity_margin' is used with read operation for most cases to calculate the capacity margin, put it into __read_mostly section. Cc: Dietmar Eggemann Cc: Morten Rasmussen Cc: Chris Redpath Cc: Joel Fernandes Cc: Vincent Guittot Cc: Patrick Bellasi Signed-off-by: Leo Yan --- kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 70ba32e..ad03bf4 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -129,7 +129,7 @@ unsigned int sysctl_sched_cfs_bandwidth_slice = 5000UL; * * (default: ~20%) */ -unsigned int capacity_margin = 1280; +unsigned int capacity_margin __read_mostly = 1280; static inline void update_load_add(struct load_weight *lw, unsigned long inc) { 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;