Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2962770rwb; Mon, 16 Jan 2023 01:39:49 -0800 (PST) X-Google-Smtp-Source: AMrXdXt0LIjPK6XZKaMnH+YHKpm+KCTzCuEbOXqqrM4kBecbqwUzu4rJIzTTM/yz7UVZmFMHipu+ X-Received: by 2002:aa7:9d92:0:b0:58a:aaa3:f72e with SMTP id f18-20020aa79d92000000b0058aaaa3f72emr20250556pfq.6.1673861989148; Mon, 16 Jan 2023 01:39:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673861989; cv=none; d=google.com; s=arc-20160816; b=chuCVJo+IyHTyLvufiBcKZkF4wCjS8NM9A4dChmqIEeHf2WH2jrjC5CpX58Omk1psF k9O8LIwE9lrenxZRDPVxjdFUSZeMrkkQ00nI66CPdaG2WXuxdU9OcjhL4l3mJAQgLpIy EVdT4FSFePsj1cEgdzO7I5bQnAmHfogUv7rj/uw1jPJ68PZUTv0HzO7vaPi7lpIWNTwO NtdyrRgA2pKzSB3QL+Sz2n5awaWw10C+gBLlWtyE5LUFRQx2v18QCUWTv9G9w4tMCPK7 UM4F7uUGk+huLrVVpTbf4O8NZh+xwjT2bbeWr9+VOt8wvZNBukoHTmXWtyzNfwL7G4xQ OPkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=G5OPga9s9el+CHbJ947Z6+l1jBqfCaiyuLxg70TImQI=; b=acyEl4Rh3GM3jIysl6xWSOPLhAuPFAt48yUbPAb11a/q8crF6P+wQH9wMldxjv5Xnl 9e0DOoVGCTEmpq423S8uAJImzUqLHeNJ7TSa7K9UNDE+d26M63abV09VpbfhBl964CtE 6dcgIsDicVAjWLAk14X5CwI4R3MNb6yoKKF1qQqS6bKctg6icxFBcUJ3xDRDFhdT3SnE cI+e55xBsY0nSMOLNBZz5AQVqZ7tfvOkrG1YMeKhp3SKEPhlcRMBhxNH/TkG70nbDAO3 +vA3/MZmTZdv83s17xpU8SnI9H55N3RLcE6BvRY3ys/pgyBIFIvcjWQVuY92OWifFpAN bsIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="mXgF/mdv"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o20-20020a056a0015d400b00582687fb9f4si31349843pfu.152.2023.01.16.01.39.43; Mon, 16 Jan 2023 01:39:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="mXgF/mdv"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231897AbjAPJ3y (ORCPT + 51 others); Mon, 16 Jan 2023 04:29:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232702AbjAPJ2z (ORCPT ); Mon, 16 Jan 2023 04:28:55 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEB0A16AC4; Mon, 16 Jan 2023 01:28:53 -0800 (PST) Date: Mon, 16 Jan 2023 09:28:51 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1673861332; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G5OPga9s9el+CHbJ947Z6+l1jBqfCaiyuLxg70TImQI=; b=mXgF/mdvSH/Q6YlDNvzjgbl5+BUz48NBSFltjq16o4dE9A5N909n/tT6vuxMCodrmPhiyA PFLopFJ6OY/j1jBDiXYJZG0zUxXgOZq0rsdnkk+ftZ+8JSZkbqFZZ4sOkdK6UprtxmbYgZ +F9S9e/fj9/fbTE4KR7ksAX0tOFotCrvYXjkCsr3x7kLD2+GMVJhDTpS6CdrW6J74xdaHo KH768kK+PDYHBwGFjtSCQDK1+6IkaowxJNavZy0JJ2jQLUJCCutTZRuDFypq6cRa6MRLAq remUama9eA3fuheTERoMI3qe1bcJdsuwCWUjJU+m5fZIv3C5Cpp7qrkl4OvrTg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1673861332; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G5OPga9s9el+CHbJ947Z6+l1jBqfCaiyuLxg70TImQI=; b=VQufeeKpZGn1kYgRPd4AKwfCq0hIRDSc47/Oz8WNSfT25i+HGUAF2uC/Fg26A9SBHNpLPv o/ph6TS07ugK64CA== From: "tip-bot2 for Yair Podemsky" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/urgent] x86/aperfmperf: Erase stale arch_freq_scale values when disabling frequency invariance readings Cc: Yair Podemsky , Ingo Molnar , Peter Zijlstra , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230110160206.75912-1-ypodemsk@redhat.com> References: <20230110160206.75912-1-ypodemsk@redhat.com> MIME-Version: 1.0 Message-ID: <167386133169.4906.2168836143666979819.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/urgent branch of tip: Commit-ID: 5f5cc9ed992cbab6361f198966f0edba5fc52688 Gitweb: https://git.kernel.org/tip/5f5cc9ed992cbab6361f198966f0edba5fc52688 Author: Yair Podemsky AuthorDate: Tue, 10 Jan 2023 18:02:06 +02:00 Committer: Ingo Molnar CommitterDate: Mon, 16 Jan 2023 10:19:15 +01:00 x86/aperfmperf: Erase stale arch_freq_scale values when disabling frequency invariance readings Once disable_freq_invariance_work is called the scale_freq_tick function will not compute or update the arch_freq_scale values. However the scheduler will still read these values and use them. The result is that the scheduler might perform unfair decisions based on stale values. This patch adds the step of setting the arch_freq_scale values for all cpus to the default (max) value SCHED_CAPACITY_SCALE, Once all cpus have the same arch_freq_scale value the scaling is meaningless. Signed-off-by: Yair Podemsky Signed-off-by: Ingo Molnar Acked-by: Peter Zijlstra Link: https://lore.kernel.org/r/20230110160206.75912-1-ypodemsk@redhat.com --- arch/x86/kernel/cpu/aperfmperf.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/x86/kernel/cpu/aperfmperf.c b/arch/x86/kernel/cpu/aperfmperf.c index 1f60a2b..fdbb5f0 100644 --- a/arch/x86/kernel/cpu/aperfmperf.c +++ b/arch/x86/kernel/cpu/aperfmperf.c @@ -330,7 +330,16 @@ static void __init bp_init_freq_invariance(void) static void disable_freq_invariance_workfn(struct work_struct *work) { + int cpu; + static_branch_disable(&arch_scale_freq_key); + + /* + * Set arch_freq_scale to a default value on all cpus + * This negates the effect of scaling + */ + for_each_possible_cpu(cpu) + per_cpu(arch_freq_scale, cpu) = SCHED_CAPACITY_SCALE; } static DECLARE_WORK(disable_freq_invariance_work,