Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp968289ybz; Wed, 15 Apr 2020 23:43:00 -0700 (PDT) X-Google-Smtp-Source: APiQypLdPS51dP69peHD552hRrHhPfrYx1TIKtuQY71MSmdx0coc+U2IbPfpwczP4ORvJa0TbYkU X-Received: by 2002:a05:6402:b14:: with SMTP id bm20mr26875403edb.365.1587019380676; Wed, 15 Apr 2020 23:43:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587019380; cv=none; d=google.com; s=arc-20160816; b=Pf0j2FPLfNRH6QrM+mk8sOK2OOLsUlc0D67Kll4J7zMbaIdekaDAd1W4RQVP302ya+ a1kHWpPvzlyTAXNNXVM5RffXWZ2c/JQ+A8LJabz3DQ1FPoSWygIJD2hATzKcF/Zshmq4 R0VPXdS0B3GBSFU0dRGfvIHfQGUyxcyVBBeIPLhyalpNpRBR9CAEdMrdsk1oCp5jYpwW yh1G2l6l0zH7ausXxTYf3ao1s7tQppcpZN4/JfG/ugRF/OVrk2+7wz5hhwIt7VhpMTQC 8kOOh5FduXFUrUhB7X0p375RtwCn7v1HjYA6W8RgrSbOpigwDPFJ+ZTMhsZZlmuCCqo0 97RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=PCbLdEaae3wOz9r3SeGO8QmxyH7llrIWwMcSzc3QEKE=; b=OGJoXMo4ck2NRM335QcG4LcL8ckUOJ1yReZ2rPVTpS0NpSvZPIVQmFjIzeB8BLEase wp3ilkbd3Y9YyVOA36xR9+ukQtwu+4Cp8PubZ8pgqr9j7MVacM7WGH2gfiSbortfzh7N eSw8ZW5tPj6VObtCPS3OKhRH3nipLBiEPHmbI4I0eEbpPzeHWM6G8JuNxRBP+8wbJQU1 tk64T/nJruuZcWh3ZkJLf5TmUQIqpyrix2wl4XBVsgwuY2n3SLEGvVkfUKyNa6R462z1 2s59yTI2Z2AOqjLtq8aTCDZwApRB7TyVgEDwupKyJS+odjxOUUb2jTS6xtMsR1hIB6U3 q4Tw== 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 x6si11113320edq.424.2020.04.15.23.42.37; Wed, 15 Apr 2020 23:43:00 -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 S2408146AbgDPGld (ORCPT + 99 others); Thu, 16 Apr 2020 02:41:33 -0400 Received: from mx2.suse.de ([195.135.220.15]:57568 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2408204AbgDPGlN (ORCPT ); Thu, 16 Apr 2020 02:41:13 -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 7EE9AACB1; Thu, 16 Apr 2020 06:41:10 +0000 (UTC) Message-ID: <1587019269.32139.24.camel@suse.cz> Subject: Re: [PATCH 1/4] x86, sched: Bail out of frequency invariance if base frequency is unknown 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 , Dario Faggioli Date: Thu, 16 Apr 2020 08:41:09 +0200 In-Reply-To: <20200416054745.740-2-ggherdovich@suse.cz> References: <20200416054745.740-1-ggherdovich@suse.cz> <20200416054745.740-2-ggherdovich@suse.cz> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.6 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +Dario Faggioli On Thu, 2020-04-16 at 07:47 +0200, Giovanni Gherdovich wrote: > 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());