From patchwork Mon Aug 17 15:10:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 266057 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78169C433DF for ; Mon, 17 Aug 2020 19:10:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5E21A20758 for ; Mon, 17 Aug 2020 19:10:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597691445; bh=G5K0RJa7nYZUNphGIKeV64484sMdLIh3FAx+a8erWrg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ykTi603V62z0nlYctIHizDWQQmq2Iw3UQ/aVp3S8fGUU6Sz4QBt22AYumPJREsNM/ ge56QTL4VfINVVZ8IKdbExue5+fPF4h7PC4HT2s2UdK86uGt/3O6NWsI5N8bWf+fJD ni/bVgnj8FwkiB3bkby8HvMvisRcwMWa4J2JeA5U= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730781AbgHQTKf (ORCPT ); Mon, 17 Aug 2020 15:10:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:51314 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730754AbgHQPlj (ORCPT ); Mon, 17 Aug 2020 11:41:39 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CCBDB20825; Mon, 17 Aug 2020 15:41:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597678898; bh=G5K0RJa7nYZUNphGIKeV64484sMdLIh3FAx+a8erWrg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fPeyLWY6nJBww4r2CmOfKDBX7mMfMCftUW25iCqoYW4n/xPpl/m4kFzTTdS8duQW+ Cg/qXd+LAYM+8nP4uMNmnj4ekAATsIA/tyeydtXl4Y/0BXrU8PEe6FHfXlouYe4yNa sRKjr4ItlSne/H5eGRmRyQmnsDSqhz5Ik0LNFUT4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Giovanni Gherdovich , "Peter Zijlstra (Intel)" , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 5.7 009/393] x86, sched: Bail out of frequency invariance if turbo_freq/base_freq gives 0 Date: Mon, 17 Aug 2020 17:10:59 +0200 Message-Id: <20200817143820.038425590@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143819.579311991@linuxfoundation.org> References: <20200817143819.579311991@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Giovanni Gherdovich [ Upstream commit f4291df103315a696f0b8c4f45ca8ae773c17441 ] Be defensive against the case where the processor reports a base_freq larger than turbo_freq (the ratio would be zero). Fixes: 1567c3e3467c ("x86, sched: Add support for frequency invariance") Signed-off-by: Giovanni Gherdovich Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Rafael J. Wysocki Link: https://lkml.kernel.org/r/20200531182453.15254-4-ggherdovich@suse.cz Signed-off-by: Sasha Levin --- 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 3917a2de1580c..e5b2b20a0aeee 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -1974,6 +1974,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; @@ -2007,9 +2008,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; }