Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp932108ybz; Wed, 15 Apr 2020 22:49:39 -0700 (PDT) X-Google-Smtp-Source: APiQypK+4rQKa8+NOLz0jd3EuRviyeNu6qJkZmyWwFcfAGVINNanEv6f7LP2Xjx2+ivkiyf5ga83 X-Received: by 2002:a17:906:af94:: with SMTP id mj20mr7886778ejb.347.1587016179686; Wed, 15 Apr 2020 22:49:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587016179; cv=none; d=google.com; s=arc-20160816; b=XLlN0/Qo4JSZ8xs7KO/c5OvYCFxcF8f97JSigs+lPIbhYBOUcwQGHM1N4iwGK5Phyc SPwNsk9F2qWAZufiIT2EfqkzQYje/GDs3W1mbM9HWRZrmcwO8Auv8xwrMk+6Emwf3yIz n7SH0SM0ctvxBy7OfWfDYQJ9jq2907dittPpH1+VkJONYQwKh4LLiiy7RZdrT4abFrAJ 1GIgIE6E+qcsJ8lhgxVtlIjUjuX/fnat0qL4dehKeyb/QaA+eGJEhfrc2ARXH8T21lOt ah24SC/pSw6PJ0M/drT82FxA6gGytkjb7qopQfiDS/UOiBERObZ1ps+ja70JTAKiT+Jk YJ2w== 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=EB/Bg1XhnE2TpF74N/z/Sp06s8ad6Dc+hrk7yX89CcQ=; b=0Qmy1R1Wtitk0cAV4GuLRPgc4vY/chB/yPA5+tQGkw/zXS1GKBthylKY5IId53RWbo 79osH5aGDvy+/Aezg/4j3++gQooaPpAFAJJIS0GrxyvvIqkL6F8MpziHePbXyJjT3wW+ EsVk5Q5lpzrgXrsuo+f/aDR+W3RqA6eQukvxB9UwAbO4u8635c3vUkCyXYII6STLCKgX SeIrGw8RpIHThapfdq4Jk+9t0Uq9Ao74V1tuVKE+j12+PpGQ+XUS8v4E2QU/OBxcgoFk 19tVbneHnsvhLERljls211v3i/u+AUHPC4jdaOq6lUWHppJM2sRR7USGewbbwTKihAu+ DsBg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m24si11351166edr.231.2020.04.15.22.49.15; Wed, 15 Apr 2020 22:49:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407167AbgDPFsR (ORCPT + 99 others); Thu, 16 Apr 2020 01:48:17 -0400 Received: from mx2.suse.de ([195.135.220.15]:38402 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406744AbgDPFsM (ORCPT ); Thu, 16 Apr 2020 01:48:12 -0400 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 BBEA6AD6C; Thu, 16 Apr 2020 05:48:07 +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 , Doug Smythies , Like Xu , Neil Rickert , Chris Wilson , Giovanni Gherdovich Subject: [PATCH 1/4] x86, sched: Bail out of frequency invariance if base frequency is unknown Date: Thu, 16 Apr 2020 07:47:42 +0200 Message-Id: <20200416054745.740-2-ggherdovich@suse.cz> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200416054745.740-1-ggherdovich@suse.cz> References: <20200416054745.740-1-ggherdovich@suse.cz> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some hypervisors such as VMWare ESXi 5.5 advertise support for X86_FEATURE_APERFMPERF but then fill all MSR's with zeroes. In particular, MSR_PLATFORM_INFO set to zero tricks the code that wants to know the base clock frequency of the CPU (highest non-turbo frequency), producing a division by zero when computing the ratio turbo_freq/base_freq necessary for frequency invariant accounting. It is to be noted that even if MSR_PLATFORM_INFO contained the appropriate data, APERF and MPERF are constantly zero on ESXi 5.5, thus freq-invariance couldn't be done in principle (not that it would make a lot of sense in a VM anyway). The real problem is advertising X86_FEATURE_APERFMPERF. This appears to be fixed in more recent versions: ESXi 6.7 doesn't advertise that feature. Signed-off-by: Giovanni Gherdovich Fixes: 1567c3e3467c ("x86, sched: Add support for frequency invariance") --- arch/x86/kernel/smpboot.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index fe3ab9632f3b..3a318ec9bc17 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -1985,6 +1985,15 @@ static bool intel_set_max_freq_ratio(void) return false; out: + /* + * Some hypervisors advertise X86_FEATURE_APERFMPERF + * but then fill all MSR's with zeroes. + */ + if (!base_freq) { + pr_debug("Couldn't determine cpu base frequency, necessary for scale-invariant accounting.\n"); + return false; + } + arch_turbo_freq_ratio = div_u64(turbo_freq * SCHED_CAPACITY_SCALE, base_freq); arch_set_max_freq_ratio(turbo_disabled()); -- 2.16.4