Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2298686rwb; Wed, 30 Nov 2022 05:06:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf4zbQdFzS8Qo68TRWKz3uC1qW3vg5vxVX305hsFBaOWXCEEgE2k06Nwy0W6BV2oypNFFxuV X-Received: by 2002:a17:903:4051:b0:170:f343:ba14 with SMTP id n17-20020a170903405100b00170f343ba14mr42012255pla.70.1669813616523; Wed, 30 Nov 2022 05:06:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669813616; cv=none; d=google.com; s=arc-20160816; b=cHMh5qmm6+Ke32mQjZUtFGX6p7Ya1SzmKcu9orosChZtQBZlZ71CB8PkwcxZ9WXCXM GDZ4iExNeLsKt3IjPWANqbnkkf73LRxDMRPP7/aNwsvFWBrh/iGktlFdcnc+Viz8PsPE KBnGqOubjRdsny7XdRwzMx+2u5c/LlunWlREwRBxGf9PEvb8eiqggPG02ZX6YU49pYqR Rl07MOV6IiaFpnV6QBty5j8bFstUgMEagxwde0CHsBgS8HsBkP26/zhZ+wCSOUhjabh6 nM6XE6OxPsETfuR0+yHZH1b3OIpR3aja5uGDhy6bFIFw1V+9A1hgrtxaMNoyc4COtazR pEhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=ffLVilJfGN30ui/fAKJ/GAZJOVTJYPQ4bp9hp76WPQk=; b=07eP0yFP34RiijZV/X6ylQSdzFqT0d5G0df9nfQAzzepiR2WaCmQBNLsqhNabBOR7M unWy5BYktk9OzHrlxlzB9A2hZu5V/sdleMUN4rTxkdazAMTTfzgy8XS5ysaAGGFKg1br EmuuYdWmySuJTjrsBV6k8L1RcvRzFoxKLPgkywnaHQVgV9mIwO2tnlvzX98oCQVDAeJf PE/yXVucxZVc+mwEgsX7tJkNBEykYY0Us3TNv6yCz/BKBpVM2WSl1Mk/tgx9tc+ss9u5 PNnyZzqFZfQpddPB5vxi0X3DKRkNpBZeT1OU+Ke6bjV8VkvBzQDyhxJnvFxYK49ireHS XdLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OTsm2whI; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e13-20020a056a001a8d00b00572698b413esi1691496pfv.195.2022.11.30.05.06.42; Wed, 30 Nov 2022 05:06:56 -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=@redhat.com header.s=mimecast20190719 header.b=OTsm2whI; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235506AbiK3M7W (ORCPT + 86 others); Wed, 30 Nov 2022 07:59:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235589AbiK3M7N (ORCPT ); Wed, 30 Nov 2022 07:59:13 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B463F429B1 for ; Wed, 30 Nov 2022 04:58:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669813092; h=from:from: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; bh=ffLVilJfGN30ui/fAKJ/GAZJOVTJYPQ4bp9hp76WPQk=; b=OTsm2whIFmj1LcgwjwLOVj1buU9QrMFLruhWifLZ6VpfK/6SRzDCQxvbRlzABVovKsPcdv 0cTYWnpOS6S0Yl64OpmiFxZZD2cm/AlqoPDqPMKpxFThY363mclmR5XINKNdV1DILz8tIy 4Pw4vAAkOYd6i3iwQD+9Lq0z2VYCF4g= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-10-nlmAYYNWO5agwsTaxFDO9w-1; Wed, 30 Nov 2022 07:58:08 -0500 X-MC-Unique: nlmAYYNWO5agwsTaxFDO9w-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0159D811E67; Wed, 30 Nov 2022 12:58:08 +0000 (UTC) Received: from ypodemsk.tlv.csb (unknown [10.39.193.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B114742220; Wed, 30 Nov 2022 12:58:04 +0000 (UTC) From: Yair Podemsky To: peterz@infradead.org, mingo@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, rafael.j.wysocki@intel.com, ggherdovich@suse.cz, jlelli@redhat.com, mtosatti@redhat.com, nsaenz@kernel.org, linux-kernel@vger.kernel.org Cc: ypodemsk@redhat.com Subject: [PATCH] sched/core: Fix arch_scale_freq_tick() on tickless systems Date: Wed, 30 Nov 2022 14:51:21 +0200 Message-Id: <20221130125121.34407-1-ypodemsk@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 In order for the scheduler to be frequency invariant we measure the ratio between the maximum cpu frequency and the actual cpu frequency. During long tickless periods of time the calculations that keep track of that might overflow, in the function scale_freq_tick(): if (check_shl_overflow(acnt, 2*SCHED_CAPACITY_SHIFT, &acnt)) ยป goto error; eventually forcing the kernel to disable the feature for all cpus, and show the warning message "Scheduler frequency invariance went wobbly, disabling!". Let's avoid that by limiting the frequency invariant calculations to cpus with regular tick. Fixes: e2b0d619b400 ("x86, sched: check for counters overflow in frequency invariant accounting") Signed-off-by: Yair Podemsky Suggested-by: "Peter Zijlstra (Intel)" --- V1 -> V2: solution approach was changed from detecting long tickless periods to frequency invariant measurements on housekeeping cpus only. Link: ee89073a1e9de11c7bd7726eb5da71a0e8795099.camel@redhat.com --- kernel/sched/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index daff72f00385..1bb0a840c817 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -5469,7 +5469,9 @@ void scheduler_tick(void) unsigned long thermal_pressure; u64 resched_latency; - arch_scale_freq_tick(); + if (housekeeping_cpu(cpu, HK_TYPE_TICK)) + arch_scale_freq_tick(); + sched_clock_tick(); rq_lock(rq, &rf); -- 2.31.1