From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72E52C761AF for ; Thu, 30 Mar 2023 07:53:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E5A6F6B0078; Thu, 30 Mar 2023 03:53:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E0AEC6B007B; Thu, 30 Mar 2023 03:53:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD2E96B007D; Thu, 30 Mar 2023 03:53:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id BF96E6B0078 for ; Thu, 30 Mar 2023 03:53:37 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 937D9160F6A for ; Thu, 30 Mar 2023 07:53:37 +0000 (UTC) X-FDA: 80624800074.21.09D3748 Received: from mail3-162.sinamail.sina.com.cn (mail3-162.sinamail.sina.com.cn [202.108.3.162]) by imf02.hostedemail.com (Postfix) with ESMTP id 911628000B for ; Thu, 30 Mar 2023 07:53:32 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf02.hostedemail.com: domain of hdanton@sina.com designates 202.108.3.162 as permitted sender) smtp.mailfrom=hdanton@sina.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1680162815; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eHe6S6K0b9f8/rQ25XNyXZ2bc4akTj0uI2I7iNSYlx8=; b=qwyMJAAW1xlGNkyLsSPnvUwYolNxn1nESz0WXuRbJWPeL2DKhjdRX0co0gXt89CJhgb49V upg/RVrOiuQBOIfCRJ9NY3TDamDSK3erw5OoAas3Gy1LZTatVtMmUVHPYWZ1N5hc9+N4fj 8puQx9wBPePaVkfo4ABvqWq9F5Dyf9Y= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf02.hostedemail.com: domain of hdanton@sina.com designates 202.108.3.162 as permitted sender) smtp.mailfrom=hdanton@sina.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680162815; a=rsa-sha256; cv=none; b=cKMMKdMUQRZrh8l4/oQ5IZSm4w7oEmDA6zTA1Njj930Mseo7nvhbjyAJovqLlabJxfNPz/ PLj8JzSi6dHWoabdnh78gOFNJoDVWAMSbUnv+jzwkPxEqByqccJzQexLD38/I+MbOhzBEF 52wLANsflppvavYWdZxkwW0S/wzsKKA= X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([114.249.59.75]) by sina.com (172.16.97.27) with ESMTP id 64253FE20003740F; Thu, 30 Mar 2023 15:53:08 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com X-SMAIL-MID: 36953849283448 From: Hillf Danton To: Peter Zijlstra Cc: mingo@kernel.org, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org, 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, joshdon@google.com, timj@gnu.org, kprateek.nayak@amd.com, yu.c.chen@intel.com, youssefesmat@chromium.org, linux-mm@kvack.org, joel@joelfernandes.org, efault@gmx.de Subject: Re: [PATCH 15/17] [RFC] sched/eevdf: Sleeper bonus Date: Thu, 30 Mar 2023 15:53:18 +0800 Message-Id: <20230330075318.2892-1-hdanton@sina.com> In-Reply-To: <20230328110354.641979416@infradead.org> References: <20230328092622.062917921@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 911628000B X-Stat-Signature: rhy8rg9xmata8apxb3j5f96uu4rde8pf X-HE-Tag: 1680162812-135949 X-HE-Meta: U2FsdGVkX1+Xwr/5e/h63nz8yVWM7RISydz0BDY30KD5VZJIZP0efxDEP52PFD5XdzcG/hT1jiF8b0dMth6WDlNlh8AdL6/Jzd0uP3UZdiUT1xAzShK3botyQRie7VNMBOHZf2jq89w8j+YVKGC1g8/CYMGol8N6dHVoSYX5NpHcOZCWMf9y6w/6qyXZXKjF0hFtKdIdda7FkgKviSj35F57Dl+Tvgqe9Q/wCfkcxECIRme5R5hV1c8X5SbS/8r9uDo1kElqRe3wSTSZvAeZMDZabuVtUGFODiISSNreCKADaoArtvufYgeYKKTxxaqp6ezkVo2ktLLBRAWcN0m1nG3wfio0FEVxDsxO7OvnzIJYqTwV1wgg8JVizCSW8AyZAhi6IgdBbYet424zy73rbPE4V1xR/FHHqHt4Gc6j98j5A5hqcLLGoDdXyI8AxIY93C8agNArbSxqQXdfMfzyg5OTnbB741kDC36Og5NNzEiOYq48MisfJLjd18ZT5OnpBoGaxeRj86TtILAO+IARqISqu3CPXN7gzhCxTxhHcDEtgl+x8sh+tfmS5YBoqkWxcPBzcLo2QVa/Z/rw8ibspGataY3ts7nSbUR+ju8HS5ATJiUk8qgOHGQ6WI7o63D0Uy1/s4dodJxf5vRPPduK5C9afMz0QVN7LncKO9RBvCyJ1b0a+e36pAJBpKqXI0gSjwjT+05xL6vDiMUvmldhVxarzh7sSi/VYrRUDWQK3wzyZsTgT/zhGAPIs4H6RoCg/l/fdzWs8vKenB8YqbtxjDbwrD15xYbsFAJVf0x/qnft/u9/SO/C+7o73wlzWxXSRn2C3twig9/xhtVMRa2CafO8hstUpgR4hnBDF+SwrxLPXAhSOxb4aXgCwjenK2vCuGX1KL1vpU8rYbNXlliXXilOgY1ynXvODRM9+QoI29T1zMgK3ur4R2Z8k8Xa13M6L9IL19+b6BIBq8LADnW cHmCMMWH DUH3XH0OLkNujhkXB8qygaBzTFYLQWSVrjYbvG+JHSEpTE1B6BSlQ5rykC3NFaoGl1OerYKjH0q+YLYnm1g0+ZPy+DfpO6lTyZpUviBuphQlxFJ0LkLvy47dJ5Q== X-Bogosity: Ham, tests=bogofilter, spamicity=0.001509, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 28 Mar 2023 11:26:37 +0200 Peter Zijlstra (Intel) > @@ -4878,22 +4878,55 @@ place_entity(struct cfs_rq *cfs_rq, stru > if (WARN_ON_ONCE(!load)) > load = 1; > lag = div_s64(lag, load); > + > + vruntime -= lag; > + } > + > + /* > + * Base the deadline on the 'normal' EEVDF placement policy in an > + * attempt to not let the bonus crud below wreck things completely. > + */ > + se->deadline = vruntime; > + > + /* > + * The whole 'sleeper' bonus hack... :-/ This is strictly unfair. > + * > + * By giving a sleeping task a little boost, it becomes possible for a > + * 50% task to compete equally with a 100% task. That is, strictly fair > + * that setup would result in a 67% / 33% split. Sleeper bonus will > + * change that to 50% / 50%. > + * > + * This thing hurts my brain, because tasks leaving with negative lag > + * will move 'time' backward, so comparing against a historical > + * se->vruntime is dodgy as heck. > + */ > + if (sched_feat(PLACE_BONUS) && > + (flags & ENQUEUE_WAKEUP) && !(flags & ENQUEUE_MIGRATED)) { > + /* > + * If se->vruntime is ahead of vruntime, something dodgy > + * happened and we cannot give bonus due to not having valid > + * history. > + */ > + if ((s64)(se->vruntime - vruntime) < 0) { > + vruntime -= se->slice/2; > + vruntime = max_vruntime(se->vruntime, vruntime); > + } > } > > - se->vruntime = vruntime - lag; > + se->vruntime = vruntime; > > /* > * When joining the competition; the exisiting tasks will be, > * on average, halfway through their slice, as such start tasks > * off with half a slice to ease into the competition. > */ > - if (sched_feat(PLACE_DEADLINE_INITIAL) && initial) > + if (sched_feat(PLACE_DEADLINE_INITIAL) && (flags & ENQUEUE_INITIAL)) > vslice /= 2; > > /* > * EEVDF: vd_i = ve_i + r_i/w_i > */ > - se->deadline = se->vruntime + vslice; > + se->deadline += vslice; > } Because lag makes no sense for more-than-a-second sleepers, it is simpler to make them able to preempt the current at the next tick, in line with what fork can do at best.