Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4926939ybl; Wed, 22 Jan 2020 07:12:12 -0800 (PST) X-Google-Smtp-Source: APXvYqz3rmYWIkucFKPXuK8I0qLwlFdTxtJ9oUNd6Cph/dSdsoO4zi8Y8D8WHbD6uvyu3/e7BqOU X-Received: by 2002:a05:6808:53:: with SMTP id v19mr7422484oic.18.1579705931848; Wed, 22 Jan 2020 07:12:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579705931; cv=none; d=google.com; s=arc-20160816; b=JqNfNET/2saeUPq/efs02evv6AoaMjY8O6lOLR8fAVuNUebv1NIYjqcQBDzTM1mMQo n1LdqiKj2RH42lTzVndHoIXd7klYPKMvNmyV5n6DeJgqnsBhYuxTe8KoIHg5XzCfGhnh 8exLL4snDyfVymnyp2LeS4zT0oxI3H7cZx0aJugxZ4G91mYjK6eCrShgh5SWbjUIRsxO hRa5Ez53I4ZygxOhBs42sDK3osQa3xSnU1s6gJjaiFUhOgflG3ROXSw+/RgPAUfozx/j qOUPC6+vYxc5ilOco5zashl0MvzYHxX8cRo4l4FCRYPhS9gRo1+urt4hgqZ7CwOnVcLX 2+lg== 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; bh=pzzytQdUzZAPbRoEH6kkTxgqSw+TFgUz3Ty1jNKih/U=; b=HXy10Xnrc6Dzqcb63jjJGIyvgJM/BqTvWv2grAdVmfYHao/AYNkG3EwwmbZSSTRjLF XCHPK57z0Man/4iIXbuyG/7m0kEK4uSgcgCH3iPILzW7Yq+9Jt7enqSZfxcIp4eVRt5G m+TaiAuGemGeKikfN5bqzHuBl/vRXT9t3jY8BLz0j+wZb96aPgG2EcyaBuD+bfj1+Bsg 8vUsXAfBaiotLDDBF1KHEqm9pPzwcwpaBv/4unAYRMGXUido0u888OiLK0u8u/IbL3D4 VTjRrlbqBj9kNZWdGQuTXwA7FBs1yFcuzsTN4IwgmAE7N/jIaandUrtUeErsD4SXj/nX bGSw== ARC-Authentication-Results: i=1; mx.google.com; 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 i11si23392568otc.105.2020.01.22.07.11.59; Wed, 22 Jan 2020 07:12:11 -0800 (PST) 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; 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 S1728831AbgAVPKh (ORCPT + 99 others); Wed, 22 Jan 2020 10:10:37 -0500 Received: from mx2.suse.de ([195.135.220.15]:39552 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726181AbgAVPKf (ORCPT ); Wed, 22 Jan 2020 10:10:35 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 8C130AD03; Wed, 22 Jan 2020 15:10:32 +0000 (UTC) From: Giovanni Gherdovich To: Srinivas Pandruvada , Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Borislav Petkov , Len Brown , "Rafael J . Wysocki" Cc: x86@kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Mel Gorman , Matt Fleming , Viresh Kumar , Juri Lelli , Paul Turner , Vincent Guittot , Quentin Perret , Dietmar Eggemann , Doug Smythies , Ionela Voinescu , Giovanni Gherdovich Subject: [PATCH v5 5/6] x86,sched: Add support for frequency invariance on ATOM Date: Wed, 22 Jan 2020 16:16:16 +0100 Message-Id: <20200122151617.531-6-ggherdovich@suse.cz> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200122151617.531-1-ggherdovich@suse.cz> References: <20200122151617.531-1-ggherdovich@suse.cz> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The scheduler needs the ratio freq_curr/freq_max for frequency-invariant accounting. On all ATOM CPUs prior to Goldmont, set freq_max to the 1-core turbo ratio. We intended to perform tests validating that this patch doesn't regress in terms of energy efficiency, given that this is the primary concern on Atom processors. Alas, we found out that turbostat doesn't support reading RAPL interfaces on our test machine (Airmont), and we don't have external equipment to measure power consumption; all we have is the performance results of the benchmarks we ran. Test machine: Platform : Dell Wyse 3040 Thin Client[1] CPU Model : Intel Atom x5-Z8350 (aka Cherry Trail, aka Airmont) Fam/Mod/Ste : 6:76:4 Topology : 1 socket, 4 cores / 4 threads Memory : 2G Storage : onboard flash, XFS filesystem [1] https://www.dell.com/en-us/work/shop/wyse-endpoints-and-software/wyse-3040-thin-client/spd/wyse-3040-thin-client Base frequency and available turbo levels (MHz): Min Operating Freq 266 |*** Low Freq Mode 800 |******** Base Freq 2400 |************************ 4 Cores 2800 |**************************** 3 Cores 2800 |**************************** 2 Cores 3200 |******************************** 1 Core 3200 |******************************** Tested kernels: Baseline : v5.4-rc1, intel_pstate passive, schedutil Comparison #1 : v5.4-rc1, intel_pstate active , powersave Comparison #2 : v5.4-rc1, this patch, intel_pstate passive, schedutil tbench, hackbench and kernbench performed the same under all three kernels; dbench ran faster with intel_pstate/powersave and the git unit tests were a lot faster with intel_pstate/powersave and invariant schedutil wrt the baseline. Not that any of this is terrbily interesting anyway, one doesn't buy an Atom system to go fast. Power consumption regressions aren't expected but we lack the equipment to make that measurement. Turbostat seems to think that reading RAPL on this machine isn't a good idea and we're trusting that decision. comparison ratio of performance with baseline; 1.00 means neutral, lower is better: I_PSTATE FREQ-INV ---------------------------------------- dbench 0.90 ~ kernbench 0.98 0.97 gitsource 0.63 0.43 Signed-off-by: Giovanni Gherdovich --- arch/x86/kernel/smpboot.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 3e32d620f1fb..5f04bf8419f9 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -1821,6 +1821,24 @@ static bool turbo_disabled(void) return (misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE); } +static bool slv_set_max_freq_ratio(u64 *base_freq, u64 *turbo_freq) +{ + int err; + + err = rdmsrl_safe(MSR_ATOM_CORE_RATIOS, base_freq); + if (err) + return false; + + err = rdmsrl_safe(MSR_ATOM_CORE_TURBO_RATIOS, turbo_freq); + if (err) + return false; + + *base_freq = (*base_freq >> 16) & 0x3F; /* max P state */ + *turbo_freq = *turbo_freq & 0x3F; /* 1C turbo */ + + return true; +} + #include #include @@ -1938,17 +1956,14 @@ static bool core_set_max_freq_ratio(u64 *base_freq, u64 *turbo_freq) static bool intel_set_max_freq_ratio(void) { - /* - * TODO: add support for: - * - * - Atom Silvermont - */ - u64 base_freq = 1, turbo_freq = 1; if (turbo_disabled()) goto out; + if (slv_set_max_freq_ratio(&base_freq, &turbo_freq)) + goto out; + if (x86_match_cpu(has_glm_turbo_ratio_limits) && skx_set_max_freq_ratio(&base_freq, &turbo_freq, 1)) goto out; -- 2.16.4