Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6494573ybx; Mon, 11 Nov 2019 10:02:32 -0800 (PST) X-Google-Smtp-Source: APXvYqxSKq2h40j9eR8lp9+FM8W+6AU9FAXN0L6IvsgYEbzZvKl6eA8L3POVvj5M+iptcwDHuus3 X-Received: by 2002:a17:906:c7d5:: with SMTP id dc21mr24507174ejb.267.1573495352285; Mon, 11 Nov 2019 10:02:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573495352; cv=none; d=google.com; s=arc-20160816; b=bciOe++s57N4Ie7UzirnuNT/G3e1F4o/Fwvhep7t2lHclytbCVnqMizvMNxA5fRfVd Ygac8qFxBLRBSrfmCsYBeEwPVR2H8m9QUxd4pr277eI/5g4S+/5fO7RBOJtOC2H7o/Xg GtsBsSivLS2S6FJmgLRgUTT2uDtUwHqLFVoOFqCF4F5yxnrSLuFpNhjtF1TQeDzs/yMu JoSPn2ipQ3v4s4K4Ppvn1TjdX2+5P2hFNoTDOgbneqWO4miiRiQ7RUd18+ezOmbNHB4L AUSAW0QDpidki8Wh/w0yC+XvfWQoPLzFsNOQ3cpI8REnTu/A1OY1JODzNIZFFQSiH9sC MgJQ== 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=hgJkOzFRSpx9WJgaRo3G9xinXZd4d5GNW9jahtJ0bzM=; b=zQwgCW6PQiJezYgpHfcV3DQA/nBG9swoI03L2Nd5yV+P71efKsSMBnT7aXgrEiHZj5 vv8wtDJAU1jsOzVc9doDjSIskA3pFloMNOMV2IeqefAWRWYxXbrmMVNUhGiX93czvy+U pT2EsNRXRF2bfXpmoE3857i46aczNlhNyjAaBmg7QXzdnVRfmJSh4g5MwdwbrpSRCVq0 TBmnE5wVnE7X49Ojh4bnzN6KqsAbENhk2PFboi52iJvAFltx7hRH7sgAgVJMaJd4AsZw u1Jj2jZQfukS9gTqZtaFleEYjhKZClerRqpT5O+1po3bO7psCThYWMMIC6MdIrwvNja8 0m9g== 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 92si12593087edh.321.2019.11.11.10.02.07; Mon, 11 Nov 2019 10:02:32 -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 S1727040AbfKKSA2 (ORCPT + 99 others); Mon, 11 Nov 2019 13:00:28 -0500 Received: from mx2.suse.de ([195.135.220.15]:33848 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726741AbfKKSA0 (ORCPT ); Mon, 11 Nov 2019 13:00:26 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 733D5AF79; Mon, 11 Nov 2019 18:00:24 +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 , Giovanni Gherdovich Subject: [PATCH 4/6] x86,sched: Add support for frequency invariance on ATOM_GOLDMONT* Date: Mon, 11 Nov 2019 19:05:47 +0100 Message-Id: <20191111180549.12166-5-ggherdovich@suse.cz> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20191111180549.12166-1-ggherdovich@suse.cz> References: <20191111180549.12166-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 GOLDMONT (aka Apollo Lake), GOLDMONT_D (aka Denverton) and GOLDMONT_PLUS CPUs (aka Gemini Lake) set freq_max to the highest frequency reported by the CPU. The encoding of turbo ratios for GOLDMONT* is identical to the one for SKYLAKE_X, but we treat the Atom case apart because we want to set freq_max to a higher value, thus the ratio freq_curr/freq_max to be lower, leading to more conservative frequency selections (favoring power efficiency). Signed-off-by: Giovanni Gherdovich --- arch/x86/kernel/smpboot.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 0e79dcc03ae4..4d192abf337d 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -1795,6 +1795,10 @@ void native_play_dead(void) * which would ignore the entire turbo range (a conspicuous part, making * freq_curr/freq_max always maxed out). * + * An exception to the heuristic above is the Atom uarch, where we choose the + * highest turbo level for freq_max since Atom's are generally oriented towards + * power efficiency. + * * Setting freq_max to anything less than the 1C turbo ratio makes the ratio * freq_curr / freq_max to eventually grow >1, in which case we clip it to 1. */ @@ -1841,6 +1845,27 @@ static const struct x86_cpu_id has_glm_turbo_ratio_limits[] = { {} }; +static bool glm_set_cpu_max_freq(u64 *ratio, u64 *turbo_ratio) +{ + int err; + + if (!x86_match_cpu(has_glm_turbo_ratio_limits)) + return false; + + err = rdmsrl_safe(MSR_PLATFORM_INFO, ratio); + if (err) + return false; + + err = rdmsrl_safe(MSR_TURBO_RATIO_LIMIT, turbo_ratio); + if (err) + return false; + + *ratio = (*ratio >> 8) & 0xFF; /* max P state ratio */ + *turbo_ratio = *turbo_ratio & 0xFF; /* highest turbo ratio */ + + return true; +} + static int get_knl_turbo_ratio(u64 *turbo_ratio) { u64 msr; @@ -1962,7 +1987,6 @@ static void intel_set_cpu_max_freq(void) /* * TODO: add support for: * - * - Atom Goldmont * - Atom Silvermont * * which all now get by default arch_max_freq = SCHED_CAPACITY_SCALE @@ -1970,10 +1994,12 @@ static void intel_set_cpu_max_freq(void) u64 ratio = 1, turbo_ratio = 1; - if (turbo_disabled() || - x86_match_cpu(has_glm_turbo_ratio_limits)) + if (turbo_disabled()) return; + if (glm_set_cpu_max_freq(&ratio, &turbo_ratio)) + goto set_value; + if (knl_set_cpu_max_freq(&ratio, &turbo_ratio)) goto set_value; -- 2.16.4