Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp689586rdg; Wed, 11 Oct 2023 02:46:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEhsx4SBs2cbGtnLoWyX/zmQqqlflUCyoxtDQSuXXPBcxSzuLFMpMtLK75VtjkFEWviypvl X-Received: by 2002:a25:361e:0:b0:d9a:6b46:f49d with SMTP id d30-20020a25361e000000b00d9a6b46f49dmr3402546yba.59.1697017606322; Wed, 11 Oct 2023 02:46:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697017606; cv=none; d=google.com; s=arc-20160816; b=tb7PpYcs1SV97L0BL6ilu/nDcdp9RvLYOKxd2M/BciMBJBZl3HrXy8CoSTVl2LeEqM 2h1KirG+erMnDdHSgP1m0EMq8Z0MMieuNBx3OkpoaKe+XT0zhY2BYlAG6eiU35vBg7nN 0DpF93xJNIGlqly78NjjVmxx0uQ9oRJnoHienV4VwnsPsdHa4O32V6W4sa4xAmZm6th0 2ejLMgM2OtPxMf76rRVSACYytRksYexJQPr7KNzkPA6KAkhvlx2lGmbKOX6O1sSvS+sS aUUFVMqs6+0+hYJURpaE5LNm6rALLhB+2DSRlgTDmw6el7kyjDnia1SRATNhJ+RhTDKr Pn0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Dgg0f5mykpLnIpLdCR3KMmNcFJ4Ezwj2Gw0v2uiSW9w=; fh=XpiPn/MVFfhC5CRzn5cT5q5iGdWPmFDEHOvC4FluDcY=; b=mdF+I1Nb+WODmnStz9chhWkR6OtuUxVX9tdGceEnfTzGbUx9BxMbgc9fZjVhnh9l9B wbQ3Vnghe6Vk4b6yytbbSX4XvrhkSr1WZNPHnDtPSKGFM/H+oPZABreTJyuBfi5F5B5u VX0Dc8TKxFreDTE4t5j8Mx9viz4nCxYcV+9gpRQC11aqRsdu2NESlx3rUG1VWBgppXTA xF+0tUoIVDyeC486PC6AEuPXp6XTMAyukJ0Ozg2fVZOmvLtQvNYIKGnmv8PKLhp9Xl4b 2c9dKCMAurHOZes6f3ZGA+tdc9ZpGLUTeF8N3nyMd5RsvqujPN3pVMGV4GsdcWfxNWVn l04Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=ZJH6NlvP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id 21-20020a630115000000b0058986bf41easi12405755pgb.8.2023.10.11.02.46.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 02:46:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=ZJH6NlvP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 14BA181444FE; Wed, 11 Oct 2023 02:46:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345652AbjJKJqg (ORCPT + 99 others); Wed, 11 Oct 2023 05:46:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231341AbjJKJqd (ORCPT ); Wed, 11 Oct 2023 05:46:33 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EB309D for ; Wed, 11 Oct 2023 02:46:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Dgg0f5mykpLnIpLdCR3KMmNcFJ4Ezwj2Gw0v2uiSW9w=; b=ZJH6NlvPEifpHkW5Xje8JCr8pd iZK7OG3YY1dGdBKmFC9wX6mUMTcMgehRuZ7moVcOQQPpV48T2uAc5sL074M/+Kr3+ddRXhiN1zHek G41M+J8odHa5roHXricGEUYrTmAlK75RjN77vInplG35a4eShYPmXN39UavvXczxyzuuwOz6Di5Yr BFO5sYSmTFKgICl1vwhPeZxGiWEVcV65WZPOaahfpB57ESGsiz5E5XtEl2dV9XaioLLBcMje6oxCU OTI4wNSC7gz6p+XJRTZeDEhv8bO1G7YpgHekyGlzw8T1Ifi5zy0ogyncZSIH1/v+oNiSchi+crmzr YwMWNcCQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qqVmc-0007d9-0n; Wed, 11 Oct 2023 09:45:40 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 5CE3F30026F; Wed, 11 Oct 2023 11:45:39 +0200 (CEST) Date: Wed, 11 Oct 2023 11:45:39 +0200 From: Peter Zijlstra To: Abel Wu Cc: mingo@kernel.org, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org, juri.lelli@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, corbet@lwn.net, qyousef@layalina.io, chris.hyser@oracle.com, patrick.bellasi@matbug.net, pjt@google.com, pavel@ucw.cz, qperret@google.com, tim.c.chen@linux.intel.com, joshdon@google.com, timj@gnu.org, kprateek.nayak@amd.com, yu.c.chen@intel.com, youssefesmat@chromium.org, joel@joelfernandes.org, efault@gmx.de, tglx@linutronix.de Subject: Re: Re: [PATCH 01/15] sched/fair: Add avg_vruntime Message-ID: <20231011094539.GE6307@noisy.programming.kicks-ass.net> References: <20230531115839.089944915@infradead.org> <20230531124603.654144274@infradead.org> <75adcb1a-c02f-4d7c-bd9c-ab4f403af3e8@bytedance.com> <20231011073001.GI14330@noisy.programming.kicks-ass.net> <3156c8fe-5488-4044-8282-79495bf89f6d@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3156c8fe-5488-4044-8282-79495bf89f6d@bytedance.com> 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_NONE,URIBL_BLOCKED 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 11 Oct 2023 02:46:45 -0700 (PDT) On Wed, Oct 11, 2023 at 04:30:26PM +0800, Abel Wu wrote: > On 10/11/23 3:30 PM, Peter Zijlstra Wrote: > > On Wed, Oct 11, 2023 at 12:15:28PM +0800, Abel Wu wrote: > > > On 5/31/23 7:58 PM, Peter Zijlstra wrote: > > > > +/* > > > > + * Compute virtual time from the per-task service numbers: > > > > + * > > > > + * Fair schedulers conserve lag: > > > > + * > > > > + * \Sum lag_i = 0 > > > > + * > > > > + * Where lag_i is given by: > > > > + * > > > > + * lag_i = S - s_i = w_i * (V - v_i) > > > > > > Since the ideal service time S is task-specific, should this be: > > > > > > lag_i = S_i - s_i = w_i * (V - v_i) > > > > It is not, S is the same for all tasks. Remember, the base form is a > > differential equation and all tasks progress at the same time at dt/w_i > > while S progresses at dt/W. > > IIUC it's V progresses at dt/W and is same for all tasks, not S which is > measured in real time (V*w_i). Clearly I should wake up before replying ;-) V = S/W, so dV = dt/W and dS = dt Anyway, the point is that both V and S are the same across all tasks, all tasks execute in parallel with infinitely small time increments. In reality this can't work ofc, so we get the approximations v_i and s_i and lag is the deviation from the ideal.