Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1569480rdb; Mon, 2 Oct 2023 13:55:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFpOoP/xFRvuamnwNNchUwdiD+7QH145cLG+UEVUJWompk8QnjD8f3d7eDTE8mqjRGo5anS X-Received: by 2002:a05:6a20:5512:b0:15d:ec88:3570 with SMTP id ko18-20020a056a20551200b0015dec883570mr9452187pzb.22.1696280114854; Mon, 02 Oct 2023 13:55:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696280114; cv=none; d=google.com; s=arc-20160816; b=hGlNnyEZqpFPfNQqt7qjOyaNJmC6+GzqxmDk98W6UZQagl3GVd1X/6b8AsRZ8fCWlD 1NVBjPSCEgizqfmE+dGHxS1K+povZavouiT7wwltox02G950G4voAth+WwzbEr1uW2H4 jcRo8K/k0WMzfDu/PINy0sqcBoT8JdA+Jo3KI8Aq5U7Xxf/Z6A2hYHgE0emcBgo/LTiN jmXYgD/vZ8vgYmuTbEO0r97vx0PULcZRghOGSEREUppvRFlssFN50Do7tMcMJGhM0SNB Gb2ZKo/9g7i8NuqYA2FIWjpYKaQUGTAN9j30aAyXiuFFqLuNESwv6F/IHCSFln+xzTYP SPrA== 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=2uF5B4jlJDMw2wEtd51kntvtEJhbdl5wGQqW1fZr3ik=; fh=7ozNXih/wEUCG0bBffm2r6Iawg1VQD5v7Y9XyRqxl+s=; b=iRVZrmdesuGcYmoxekAYhGacMXGq0ZBbUsp9ceppVRUWDcN6j4vycc+GOkEhWTDAwt Yxb//YC+ZQtLLg+Kt9WPaG7JQ9zvwp8zXaeCWqwRTZvkfDVL9tk7E+EsdIh/+eUzZAw8 dr9PluLAyMe/2JHpYLofa1sGRLaTzcBv+4rrJjrXBChMV02lYEQd8p76YByz8RKhTxh9 mPluzZedpGEehS6WCTF0NRQbNihZG36WQR9SIsu8Jg34aDSynRJl6L7JgC+at5wUNLr1 UmyOCkrFv69j1ZibS+X7FDh/YKsca8PzSxhgDro/35O4OlkUNAy9qxPaFLPtBKpFmEby NcJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=QL+uQIhl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id b12-20020a056a00114c00b0068fc9557cddsi28593879pfm.81.2023.10.02.13.55.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 13:55:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=QL+uQIhl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 76A5180763F8; Mon, 2 Oct 2023 10:40:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238319AbjJBRjy (ORCPT + 99 others); Mon, 2 Oct 2023 13:39:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238132AbjJBRjx (ORCPT ); Mon, 2 Oct 2023 13:39:53 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DCB6BD for ; Mon, 2 Oct 2023 10:39:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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=2uF5B4jlJDMw2wEtd51kntvtEJhbdl5wGQqW1fZr3ik=; b=QL+uQIhlTp2Y9i4CnmEROK5BKw ChdMIvA1Tc0A4/e5l0sHozPpe5Edna8JxG8UuZckmaIoZLGz3jT0EdE5ITgtNpA00BSlDCgDG8S4L xbDc5Z/CDunt+T6pCn657W2/rUutTm6cnKlWtgOz0N82e3vtIhN0kWqhpDBphdZhmsz0rpRtr2kV4 Oj6xvPmJn2lhP4s7VN+IKb0vxiCbVRwH3c2gjiZg5acXoxm7udrRBjUHanMxCEwPRTEbR/+U/V/2K bZMRPPPi1IrC+tio0FpRnLHvgFzbGzygIVCuEZpfshTKcQ2XVQoVazUeFCFwYl9/XJ+3OJzQZRUnR lEFH/dfw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1qnMss-00AJEh-1A; Mon, 02 Oct 2023 17:39:06 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 94730300454; Mon, 2 Oct 2023 19:39:04 +0200 (CEST) Date: Mon, 2 Oct 2023 19:39:04 +0200 From: Peter Zijlstra To: Benjamin Segall Cc: mingo@kernel.org, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org, juri.lelli@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, 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: [PATCH 05/15] sched/fair: Implement an EEVDF like policy Message-ID: <20231002173904.GA27267@noisy.programming.kicks-ass.net> References: <20230531115839.089944915@infradead.org> <20230531124603.931005524@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Mon, 02 Oct 2023 10:40:13 -0700 (PDT) On Fri, Sep 29, 2023 at 02:40:31PM -0700, Benjamin Segall wrote: > > +static struct sched_entity *pick_eevdf(struct cfs_rq *cfs_rq) > > +{ > > + struct rb_node *node = cfs_rq->tasks_timeline.rb_root.rb_node; > > + struct sched_entity *curr = cfs_rq->curr; > > + struct sched_entity *best = NULL; > > + > > + if (curr && (!curr->on_rq || !entity_eligible(cfs_rq, curr))) > > + curr = NULL; > > + > > + while (node) { > > + struct sched_entity *se = __node_2_se(node); > > + > > + /* > > + * If this entity is not eligible, try the left subtree. > > + */ > > + if (!entity_eligible(cfs_rq, se)) { > > + node = node->rb_left; > > + continue; > > + } > > + > > + /* > > + * If this entity has an earlier deadline than the previous > > + * best, take this one. If it also has the earliest deadline > > + * of its subtree, we're done. > > + */ > > + if (!best || deadline_gt(deadline, best, se)) { > > + best = se; > > + if (best->deadline == best->min_deadline) > > + break; > > + } > > + > > + /* > > + * If the earlest deadline in this subtree is in the fully > > + * eligible left half of our space, go there. > > + */ > > + if (node->rb_left && > > + __node_2_se(node->rb_left)->min_deadline == se->min_deadline) { > > + node = node->rb_left; > > + continue; > > + } > > + > > + node = node->rb_right; > > + } > > I believe that this can fail to actually find the earliest eligible > deadline, because the earliest deadline (min_deadline) can be in the > right branch, but that se isn't eligible, and the actual target se is in > the left branch. A trivial 3-se example with the nodes represented by > (vruntime, deadline, min_deadline): > > (5,9,7) > / \ > (4,8,8) (6,7,7) > > AIUI, here the EEVDF pick should be (4,8,8), but pick_eevdf() will > instead pick (5,9,7), because it goes into the right branch and then > fails eligibility. > > I'm not sure how much of a problem this is in practice, either in > frequency or severity, but it probably should be mentioned if it's > an intentional tradeoff. Well, that is embarrassing :-( You're quite right -- and I *SHOULD* have double checked my decade old patches, but alas. Re-reading the paper, your proposal is fairly close to what they have. Let me go stare at your patch in more detail.