Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3087403rdb; Wed, 15 Nov 2023 22:38:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IGMOzehuDXrYH8QOtnQFgfAGiwvscIknB+/XcUzk1i57QEeC0XkYVzEyCp5XNE4vH2jUyIq X-Received: by 2002:a17:902:e546:b0:1cc:51b8:80f3 with SMTP id n6-20020a170902e54600b001cc51b880f3mr9048785plf.16.1700116735719; Wed, 15 Nov 2023 22:38:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700116735; cv=none; d=google.com; s=arc-20160816; b=PScnQaSLxVfC7F/GKUYn/KxTUME7n7SPl2AXZlPHH5ozXFIudXYNal/DrvAarrl0l+ 3W6COIJrthBMTGvPZLCYO9hE4X5lVsr0Gq3kbqgvt4n9dBRxXaO9QCbc8TmWVdQjB1e+ bnidu4HryI6jtPEDi7oFpQNzveEmGi8fLXzz/3V/3rmaqti46HBQaGXidqdZO92ZiRmU LM3PhpeNrbgxSBI/PFgui3c0cP/rdyTB95DVdlYEOrvjsKn+VfBa4d8S0MoDCQd4zTQJ UJtNAHURZ6TiP9trNhQr/wd0bHpLsnPqfq800LwmM3ZRSivdJDoAxV2vYdYyHgdabll/ 76Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :content-language:from:references:cc:to:subject:user-agent :mime-version:date:message-id; bh=kM0AAoGzgdPIn/w1EYDCbuL/B4IoYnBbtlxL8aDhh8U=; fh=BP81ARlCW8dFQoBlCq7YpCeU4fZA636m23qD8QLpJhQ=; b=Ex3Oj0R4lHXv9dv10T0VhrF2bycjkZ4PF+Anh2Z/Q5UWu6lX1llpbChKNI/sDLnY+w pVhYR4aRve6wXWcm0oCUt+E/qpUwXq1KZgzVbTk35IyaaoBTdHFcmcCQIoGwD0nFd0FB XmR0MVpo1K4CXYVL3Fymm3b1Jko0xzdiRi8t8uqWrR7rDZexqNz5yXMDm3f7RGgMYSo8 dEfjfrmx/GROGMcZZnlH3WJeJvpjkssS/tjqEsOx67P2hSDaktiK/4kJIQAWgpnoGxgL VT2sT2Z8mmNQ+9jrThyQb2zMQUB+8+sGX/5PCd+m08V1ufCMQ3U/eX7wGOVMFOg/aTgs HafQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id j7-20020a170902758700b001c3671d3151si11700078pll.92.2023.11.15.22.38.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 22:38:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 2E4E180E855C; Wed, 15 Nov 2023 22:38:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229806AbjKPGim (ORCPT + 99 others); Thu, 16 Nov 2023 01:38:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229484AbjKPGil (ORCPT ); Thu, 16 Nov 2023 01:38:41 -0500 Received: from out30-110.freemail.mail.aliyun.com (out30-110.freemail.mail.aliyun.com [115.124.30.110]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 837C8A4 for ; Wed, 15 Nov 2023 22:38:37 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R351e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045192;MF=cruzzhao@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0VwVG5Ww_1700116704; Received: from 30.97.49.18(mailfrom:cruzzhao@linux.alibaba.com fp:SMTPD_---0VwVG5Ww_1700116704) by smtp.aliyun-inc.com; Thu, 16 Nov 2023 14:38:35 +0800 Message-ID: Date: Thu, 16 Nov 2023 14:38:24 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH 3/4] sched/fair: introduce core_vruntime and core_min_vruntime To: Peter Zijlstra Cc: 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, joel@joelfernandes.org, linux-kernel@vger.kernel.org References: <20231115113341.13261-1-CruzZhao@linux.alibaba.com> <20231115113341.13261-4-CruzZhao@linux.alibaba.com> <20231115122027.GZ8262@noisy.programming.kicks-ass.net> <246dee1f-5e14-e075-13c7-ce876305cb54@linux.alibaba.com> <20231115152259.GB8262@noisy.programming.kicks-ass.net> From: cruzzhao Content-Language: en-US In-Reply-To: <20231115152259.GB8262@noisy.programming.kicks-ass.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.7 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Wed, 15 Nov 2023 22:38:53 -0800 (PST) 在 2023/11/15 下午11:22, Peter Zijlstra 写道: > On Wed, Nov 15, 2023 at 09:42:13PM +0800, cruzzhao wrote: >> >> >> 在 2023/11/15 下午8:20, Peter Zijlstra 写道: >>> On Wed, Nov 15, 2023 at 07:33:40PM +0800, Cruz Zhao wrote: >>>> To compare the priority of sched_entity from different cpus of a core, >>>> we introduce core_vruntime to struct sched_entity and core_min_vruntime >>>> to struct cfs_rq. >>>> >>>> cfs_rq->core->core_min_vruntime records the min vruntime of the cfs_rqs >>>> of the same task_group among the core, and se->core_vruntime is the >>>> vruntime relative to se->cfs_rq->core->core_min_vruntime. >>> >>> But that makes absolutely no sense. vruntime of different RQs can >>> advance at wildly different rates. Not to mention there's this random >>> offset between them. >>> >>> No, this cannot be. >> >> Force idle vruntime snapshot does the same thing, comparing >> sea->vruntime - cfs_rqa->min_vruntime_fi with seb->vruntime - >> cfs_rqb->min_vruntime_fi, while sea and seb may have wildly different rates. > > But that subtracts a from a and b from b, it doesn't mix a and b. > > Note that se->vruntime - cfs_rq->min_vruntime is a very poor > approximation of lag. We have actual lag now. > > Note that: > > (sea - seb) + (min_fib - min_fia) = > (sea - min_fia) + (min_fib - seb) = > (sea - min_fia) - (seb - min_fib) = > 'lag'a - 'lag'b > > It doesn't mix absolute a and b terms anywhere. > >> Actually, cfs_rq->core->core_min_vruntime does the same thing as >> cfs_rq->min_vruntime_fi, providing a baseline, but >> cfs_rq->core->core_min_vruntime is more accurate. > > min(cfs_rqa, cfs_rqb) is nonsense. And I can't see how min_vruntime_fi > would do anything like that. > >> I've tried to implement a fair enough mechanism of core_vruntime, but >> it's too complex because of the weight, and it costs a lot. So this is a >> compromise solution. > > 'this' is complete nonsense and not motivated by any math. > >> BTW, is there any other solutions to solve this problem? > > Well, this is where it all started: > > https://lkml.kernel.org/r/20200506143506.GH5298%40hirez.programming.kicks-ass.net > > The above lag thing is detailed in a follow up: > > https://lkml.kernel.org/r/20200515103844.GG2978%40hirez.programming.kicks-ass.net Many thanks, I'll study the discussion about this. > > Anyway, I think the first of those links has the start of the > multi-queue formalism, see the S_k+l bits. Work that out and see where > it ends. > > I did go a bit further, but I've forgotten everything since, it's been > years. > > Anyway, nothing like this goes in without a fairly solid bit of math in > the changelog to justify it. > > Also, I think Joel complained about something like this at some point, > and he wanted to update the core tree more often, because IIRc his > observation was that things got stale or something. Many thanks for reviewing. I'll think about this more comprehensively. Best, Cruz Zhao