Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp563100ybg; Wed, 3 Jun 2020 07:56:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwp2h58ePOieS64INmg6qlPc6ylPzIq4viNWuPA7cBM5+D2v+ayhiy65At+NzrR/zJAWvG4 X-Received: by 2002:a05:6402:2d5:: with SMTP id b21mr33122709edx.293.1591196198982; Wed, 03 Jun 2020 07:56:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591196198; cv=none; d=google.com; s=arc-20160816; b=X4OVIiGeaMjCeN2P2ue3hp0APaxPE+hJSN0JlVoFCdHbHoOghDe5pZiJx9OFdRVrEk WdDarZV/W56Lu+CP95fVmaDKefHUmn4jKEAMx+AvVQXNdmzYnGcJpYf/DFbjRsi4FL4R H7IsgQwSBTpneaAGV900f+lmkT3hlnDGRoX4Nt1O26nmv/pPHgqSQlj/QgR1l4NL1qqH E0GDSDchZwTer9UUjnX7gEhaznVxm+JJE2HkuROOBGevUqLHyLXdrQRzz35viGem9sbn uciKQm2qXMH72fS0ix+uBUz2Rvyft4i6O4SRGmLmy779gizpySGsVPvZYyfQDTkZ+/F/ 90iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=+IFxkwdJki1WIWWrFUItKHxjWSf4ueSBqfwRQQudi88=; b=gzvGE8HvC+cA5EcYzD8srKEnOsbHqE2j9VlH6tdG2fkb3pyC2NPwJQOLVX9yE/j5cb GJh8EHIw2lkDURvVW8Zze52db9edxkU/7BnGXSRT9IUd4Ly8Aq1SlRjYwLcubbIlnSd3 hqgBUarXdwVAa0HMZvb4chRnQsG52Dim71X6fS6UO1/ryMSam+kDDOGbwH46IrSOSRBi fGSNphC8gUDM5fLej0h7wfaM1bkFSAivAugzXdC5rBiAwrAgrSuwPUibt7loIS82x859 32KMqTqdMckP14ufE6iCp3cySvCO9XRtFsc5lQPOy2MwKMzzYy//T8PlbkWGhmtpAKVy vY6w== 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u20si1345880eda.569.2020.06.03.07.56.15; Wed, 03 Jun 2020 07:56:38 -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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726356AbgFCOvj (ORCPT + 99 others); Wed, 3 Jun 2020 10:51:39 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:39396 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725854AbgFCOvg (ORCPT ); Wed, 3 Jun 2020 10:51:36 -0400 Received: by mail-ot1-f66.google.com with SMTP id g5so2069432otg.6; Wed, 03 Jun 2020 07:51:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+IFxkwdJki1WIWWrFUItKHxjWSf4ueSBqfwRQQudi88=; b=tMR8MNQ3Y2eCFDh4CEbiq7m9U3AmQ8uElTDhB+WiEofCYQ062bEdcCeb5bKX1a00Ax N20KlQSzK6AarYZNvo+OuknoB7BzsUlwnY/W/IZmIWkInpE/l8r8tfd30B17UhV5kU+/ 1Sdt3kkRLB3sq1KrICnvfDk+4mNUqSjUsyvqVlRpOMXr3/rtb0ZkfgWn8x7g5QckhGHl fxsWQl8QVYV4IPJYblLmXpt/1GCkqhKyV57gqBj8Kg9iBsD3XMYoDHiuj8sa99qXeWrO yJwIh+OuRIqJoCzJmsVfTP8eHzWFR7BoA1KN6ifkgTylNTzOPWAi3+cGisonDx6M+oKJ DqXw== X-Gm-Message-State: AOAM5309TkeoeYeWil9LGPWKSNjQ2FbR2gGrDy9ms0wM5vDPh0ujWvI9 y6Ik6h1ujlzsfmcsJk5zr4vb6IOerDaAJOtVUsE= X-Received: by 2002:a9d:3d05:: with SMTP id a5mr272952otc.262.1591195892184; Wed, 03 Jun 2020 07:51:32 -0700 (PDT) MIME-Version: 1.0 References: <20200531182453.15254-1-ggherdovich@suse.cz> <20200531182453.15254-4-ggherdovich@suse.cz> In-Reply-To: <20200531182453.15254-4-ggherdovich@suse.cz> From: "Rafael J. Wysocki" Date: Wed, 3 Jun 2020 16:51:21 +0200 Message-ID: Subject: Re: [PATCH v2 3/3] x86, sched: Bail out of frequency invariance if turbo_freq/base_freq gives 0 To: Giovanni Gherdovich Cc: Srinivas Pandruvada , Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Borislav Petkov , "Rafael J . Wysocki" , "the arch/x86 maintainers" , Linux PM , Linux Kernel Mailing List , Ricardo Neri Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, May 31, 2020 at 8:26 PM Giovanni Gherdovich wrote: > > 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") Reviewed-by: Rafael J. Wysocki > --- > 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 >