Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1218460rwb; Wed, 14 Dec 2022 07:49:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf7omUzwBvhYsx7uquwj/CMtphF1rShE5WWXQ+AMOhnCTtgzqZrPt4KcZ8cq1EjU6gOiaQl4 X-Received: by 2002:a05:6a20:9e49:b0:a6:7529:7c99 with SMTP id mt9-20020a056a209e4900b000a675297c99mr32360213pzb.5.1671032993068; Wed, 14 Dec 2022 07:49:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671032993; cv=none; d=google.com; s=arc-20160816; b=RqXkURD56fz2Xq+RTeKfEc1/aab8dWZc6Lrxju299+z7LPj+hPL3ep5u8JLqC4VUgl aU2uPIh33QkeSPwMOyUbW7i97U2x8YaiAn3FIbfiImQ+WxIGKalmj9ak/kIJW593BB4p qwFcQb9EPgT5JY+ZBpKmSvKQ+SVhpiJJ8FEPzW4yWb+nE8N7o2bSiBgZm9DCoI54GG74 svioidllMdkThnVwVhNM3KMGcIIPXEcuHgH1yn3JV9c94dxJXHXYf293UgPbqivcee/J MDbGYV+u//P5Qe6uxDvA5hkkAF0FY0Pq0ARYSa4KUz1i18fikPpxy25p7fzt0MaVI6qC 0IkA== 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 :user-agent:references:in-reply-to:date:to:from:subject:message-id :dkim-signature:dkim-signature; bh=7pUv0ZD9S0AfJgVsaPfgue1q7h983DFZ7YFXKqbWqWk=; b=SfgRmo8DZt+uK1ARRk98e/YZ6WY/lifWlXRG+MY6RFuo54AKo5SCU2ldWRl53hmAi+ LxWI23wjq9/LRZZxVbdGA36klWPcAIC+sWSFHwA4VgybmvAuzpSSyHBDyeUpOY7yjFxf MjIuyomZdRMJMhuwtu52dsm6UgCUVOt+gy1EVul2W4tS87d+qJ9+ixV4FdS0oAHSu6wr KNDL7++RU+kwqBkFoQQtKMGuvedk5B0UGuLJ9glTevId2TGN6udNEp+3pKYaNHZQrnIH kXOrKJ43UMFDp0/8+mjJMDEHotKkruX1oZ3/fQ+65pBkQp8lAy4hqxi7xv/6MCj+8y5S dM+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=da8b2STZ; dkim=neutral (no key) header.i=@suse.cz; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c17-20020a170903235100b0018696ec99e9si3606067plh.492.2022.12.14.07.49.44; Wed, 14 Dec 2022 07:49:53 -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=@suse.cz header.s=susede2_rsa header.b=da8b2STZ; dkim=neutral (no key) header.i=@suse.cz; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238683AbiLNPgH (ORCPT + 69 others); Wed, 14 Dec 2022 10:36:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238804AbiLNPf4 (ORCPT ); Wed, 14 Dec 2022 10:35:56 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A97162CB for ; Wed, 14 Dec 2022 07:35:46 -0800 (PST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 51DE81FDCF; Wed, 14 Dec 2022 15:35:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1671032145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7pUv0ZD9S0AfJgVsaPfgue1q7h983DFZ7YFXKqbWqWk=; b=da8b2STZ6liRAYvUX3vud9/he8lHncPlz27t6+fjEs1Dgj6SYfauTzs+bKQk+Cm4p5y7vG UYQ83J09YlpXZcQpt2y5zPIbeSfFpp+KTWqHpuv0DgWPqb8WjNf92P5pm6n98Lh95OKKM0 n8NOpTDTu6ot98k/TELSYydU7SGG8fE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1671032145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7pUv0ZD9S0AfJgVsaPfgue1q7h983DFZ7YFXKqbWqWk=; b=b1EisxYg7ncTSkLB1MsjuZfyHsxq/RSD4t3C0sa60hrEUNdcxFzuheqfGFnWBHDTb+vJWB W7BnEJlp2K+boqDQ== Received: from ggherdovich.udp.ovpn2.nue.suse.de (unknown [10.163.44.102]) by relay2.suse.de (Postfix) with ESMTP id A44432C141; Wed, 14 Dec 2022 15:35:44 +0000 (UTC) Message-ID: <4dff11851bf3fd306ff623bbcc29fca4b2e690e1.camel@suse.cz> Subject: Re: [PATCH] sched/core: Fix arch_scale_freq_tick() on tickless systems From: Giovanni Gherdovich To: Yair Podemsky , 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, jlelli@redhat.com, mtosatti@redhat.com, nsaenz@kernel.org, linux-kernel@vger.kernel.org Date: Wed, 14 Dec 2022 16:35:42 +0100 In-Reply-To: <20221130125121.34407-1-ypodemsk@redhat.com> References: <20221130125121.34407-1-ypodemsk@redhat.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_SOFTFAIL 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 On Wed, 2022-11-30 at 14:51 +0200, Yair Podemsky wrote: > 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)" Acked-by: Giovanni Gherdovich > --- > 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);