Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp604630rdg; Thu, 12 Oct 2023 15:36:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYOsPTQSUuhXYzHp0IRCgwgvHxYsVSF41/dnjYWwNT4PyUZLJprxRX/HrkQOTwD18+4DZ7 X-Received: by 2002:a05:6a20:4323:b0:16b:c734:4515 with SMTP id h35-20020a056a20432300b0016bc7344515mr17607695pzk.14.1697150166889; Thu, 12 Oct 2023 15:36:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697150166; cv=none; d=google.com; s=arc-20160816; b=J4QP2VV8DGu0N1lQUS2OYGYVCX3zdAYvI0CLTPGGQxk1NXgzFueyXS1Gp21bvqjVCo 0euBtzgNeo4/hJNRi/SJd0FhN0uol//R/W31oFX5PuoxCJ4rpL4fMp8UF/mmbd+PLNTN HLeqZMzQD4F9tjWrgmVsypqnyUG0xpsQYBIpSm2rIPKxNgo9DKWLPSGfk8ySm6RnIZPa 3v9B1y1OR6HoIW+O+s9++Pzb4YJsU5JMjcChoE9YdGlGTBUV/xQggLCHyUIJESWYMShJ 4QMgQ2tCMIq4Lx0GQtV4mVjcAYDPOFLcnCvbWmIRAtp6vj/VCcVfKIDLTvSJYtGiyqFf RMMA== 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=b253Sj7wmuIogC42d3JJmtTfARbHB8IHESHD45gbU34=; fh=7ozNXih/wEUCG0bBffm2r6Iawg1VQD5v7Y9XyRqxl+s=; b=JPfOpBzrN6mKWsa15hX0U0c/GQzraunFNGnBJERu32uvbmALnq+JQyaQuAPIPvhzgH mpE1NJbC767oqBHlOduIBgTwcfApDqKW8HZqMhnCX+UIEwlWaS30AkZA4cpvfsMZG2RZ O15D6YNd1kEVfzJdcQqBsSNkfuSoPinS59MWdGVRR9HRsS/trc3MyKX8T9dhKs3OMlVP n9tG/XMxcR6h4Gcw0N5wtXtN0AxqUeTH9Uz4M7KMuIW32feECFhsjvOOZZrek62rs003 C0ThxWMfrDARK29l1esQ9KwZUP8yH4H70OrKsl6IO2OtG0bBu6zpdUTomR7FwO42iOE2 IYSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=EkygVsOH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id a10-20020a63cd4a000000b00578a2da0e4bsi3318964pgj.302.2023.10.12.15.36.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 15:36:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=EkygVsOH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 7CD8280A32C3; Thu, 12 Oct 2023 15:36:04 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443077AbjJLWfk (ORCPT + 99 others); Thu, 12 Oct 2023 18:35:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443052AbjJLWfe (ORCPT ); Thu, 12 Oct 2023 18:35:34 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5CE1D6 for ; Thu, 12 Oct 2023 15:35:32 -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=b253Sj7wmuIogC42d3JJmtTfARbHB8IHESHD45gbU34=; b=EkygVsOH9hrpVo0xM/OUd0hcvC KUzmW0K+RuzaXUL/CatKX58b5V7vaZ+FvsOppmVhqAeANVAhM1n0SBINotWoS5q1PIsfG75asmC14 0mo53qXGHGHapwOVj2oozA4WOCmE/gHvxGXBJuDmzFyYri6o7+sgdF52UlQVAl41BeJr273qJskuH vrC1KZi/cfxtexC8WJbhj8RJw83gISWtJQM5+TkPmD65s04ZFBG9Q83C2sj481y+/7H5U8Rz42VXZ gDuQEGAbMD+2bBYNwjEfIjPxV7/Nf5bScaAe/N5U9bTuiymB350GBv/vYXzAt2fjLNJ1KrYxjoJZW 6L3uMw+A==; 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 1qr4GC-001sP8-RB; Thu, 12 Oct 2023 22:34:28 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 7E00830036C; Fri, 13 Oct 2023 00:34:28 +0200 (CEST) Date: Fri, 13 Oct 2023 00:34:28 +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 03/15] sched/fair: Add lag based placement Message-ID: <20231012223428.GP6307@noisy.programming.kicks-ass.net> References: <20230531115839.089944915@infradead.org> <20230531124603.794929315@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.8 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 morse.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 (morse.vger.email [0.0.0.0]); Thu, 12 Oct 2023 15:36:04 -0700 (PDT) On Thu, Oct 12, 2023 at 12:15:12PM -0700, Benjamin Segall wrote: > Peter Zijlstra writes: > > > @@ -4853,49 +4872,119 @@ static void > > place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int initial) > > { > > u64 vruntime = avg_vruntime(cfs_rq); > > + s64 lag = 0; > > > > - /* sleeps up to a single latency don't count. */ > > - if (!initial) { > > - unsigned long thresh; > > + /* > > + * Due to how V is constructed as the weighted average of entities, > > + * adding tasks with positive lag, or removing tasks with negative lag > > + * will move 'time' backwards, this can screw around with the lag of > > + * other tasks. > > + * > > + * EEVDF: placement strategy #1 / #2 > > + */ > > So the big problem with EEVDF #1 compared to #2/#3 and CFS (hacky though > it is) is that it creates a significant perverse incentive to yield or > spin until you see yourself be preempted, rather than just sleep (if you > have any competition on the cpu). If you go to sleep immediately after > doing work and happen to do so near the end of a slice (arguably what > you _want_ to have happen overall), then you have to pay that negative > lag in wakeup latency later, because it is maintained through any amount > of sleep. (#1 or similar is good for reweight/migrate of course) > > #2 in theory could be abused by micro-sleeping right before you are > preempted, but that isn't something tasks can really predict, unlike > seeing more "don't go to sleep, just spin, the latency numbers are so > much better" nonsense. Right, so I do have this: https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git/commit/?h=sched/eevdf&id=344944e06f11da25b49328825ed15fedd63036d3 That allows tasks to sleep away the lag -- with all the gnarly bits that sleep time has. And it reliably fixes the above. However, it also depresses a bunch of other stuff. Never a free lunch etc. It is so far the least horrible of the things I've tried.