Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp2186352ybm; Sun, 31 May 2020 11:28:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMW+WDKOchtCPKMLXYSBt+YfGJ8/Xi+oTlYF7qivG6J0xQ+tm4qI4hqy5Dym7t5uR3F1EK X-Received: by 2002:a17:906:e0c5:: with SMTP id gl5mr15917494ejb.524.1590949713822; Sun, 31 May 2020 11:28:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590949713; cv=none; d=google.com; s=arc-20160816; b=LQroxbrdJ56qrC74qvQcvxfaRjouDj1mRTP+/dVY0m541ucg4Fc7pg9jdSik0hSk1m isu4GEozT/+6EULW8Nks57cKS31m6rLWVn6FSWb6Gjl67e6/BjbCRAFY3JlXWUCjmo2z UEFGtcTbyQhjYyy7j2b+SfG+4OrUoPjQE4StKfq2T1D32XYeCoZgO6304noW3rTWB5CP 17rUB/JD4zJHwzW/Ac7HTUXCrEEKj097eGGzlTYNsUIbfkdchNYlVtgi9RqjJspZBwZH HekoNVUKzLJYqOV09GBBe8lIGL6PjuhFPSs+aJRJjGnWqZN1XsgpnBDKJ4CRQrVdwrDF HG2w== 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=ofmOxnCJ4Fh9JpvCi43dfOC4VPt8Zt13qXE5yuj42q0=; b=aRIm37bUItGLo9qTU9NOLCP2mQyw62v+GjOsQbFCcbMH3B7MlwoSq5Hu0iZK+j1Jbi vZeCPeJOCzfB8KpE/Gfyr/JNfXd/1v9/uKPpYX9dvR9WlKcPIZj38jCnzebRLEggiUrv KpWMGg4szfRMVdsG/9x/g6oOqLnNcTy2rb68jUPjIzg/kvYUu1pi7vpr3mWrzipMMDi9 gCRsYksmJkHfZNnu+4CatvvLA0hK5xwN/ivjE+hGMrkv75vgyS+s7j1giPUVN0NIkuqQ lqm5G2sZ1jsUfx3vjZEOW7ANdE8bMu30PkZj1zC5Ro6zeJSMNgPg58nIj4LjqXrZspPK /VKA== 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 qc28si1256011ejb.292.2020.05.31.11.28.10; Sun, 31 May 2020 11:28:33 -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 S1728379AbgEaS0Z (ORCPT + 99 others); Sun, 31 May 2020 14:26:25 -0400 Received: from mx2.suse.de ([195.135.220.15]:52428 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726008AbgEaS0Q (ORCPT ); Sun, 31 May 2020 14:26:16 -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 07973AD5B; Sun, 31 May 2020 18:26:16 +0000 (UTC) From: Giovanni Gherdovich To: Srinivas Pandruvada , Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Borislav Petkov , "Rafael J . Wysocki" Cc: x86@kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Neri , Giovanni Gherdovich Subject: [PATCH v2 3/3] x86, sched: Bail out of frequency invariance if turbo_freq/base_freq gives 0 Date: Sun, 31 May 2020 20:24:53 +0200 Message-Id: <20200531182453.15254-4-ggherdovich@suse.cz> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200531182453.15254-1-ggherdovich@suse.cz> References: <20200531182453.15254-1-ggherdovich@suse.cz> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Be defensive against the case where the processor reports a base_freq larger than turbo_freq (the ratio would be zero). Signed-off-by: Giovanni Gherdovich Signed-off-by: Peter Zijlstra (Intel) Fixes: 1567c3e3467c ("x86, sched: Add support for frequency invariance") --- arch/x86/kernel/smpboot.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index fe154c8226ba..f619007f46cf 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -1976,6 +1976,7 @@ static bool core_set_max_freq_ratio(u64 *base_freq, u64 *turbo_freq) static bool intel_set_max_freq_ratio(void) { u64 base_freq, turbo_freq; + u64 turbo_ratio; if (slv_set_max_freq_ratio(&base_freq, &turbo_freq)) goto out; @@ -2009,9 +2010,15 @@ static bool intel_set_max_freq_ratio(void) return false; } - arch_turbo_freq_ratio = div_u64(turbo_freq * SCHED_CAPACITY_SCALE, - base_freq); + turbo_ratio = div_u64(turbo_freq * SCHED_CAPACITY_SCALE, base_freq); + if (!turbo_ratio) { + pr_debug("Non-zero turbo and base frequencies led to a 0 ratio.\n"); + return false; + } + + arch_turbo_freq_ratio = turbo_ratio; arch_set_max_freq_ratio(turbo_disabled()); + return true; } -- 2.16.4