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 5F154C32771 for ; Sun, 18 Sep 2022 10:46:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C1A0F940008; Sun, 18 Sep 2022 06:46:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BA2CA940007; Sun, 18 Sep 2022 06:46:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A45AD940008; Sun, 18 Sep 2022 06:46:13 -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 8FB63940007 for ; Sun, 18 Sep 2022 06:46:13 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 66B2EC0314 for ; Sun, 18 Sep 2022 10:46:13 +0000 (UTC) X-FDA: 79924876626.09.9116E3C Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) by imf14.hostedemail.com (Postfix) with ESMTP id 01602100012 for ; Sun, 18 Sep 2022 10:46:12 +0000 (UTC) Received: by mail-lf1-f42.google.com with SMTP id o2so40209100lfc.10 for ; Sun, 18 Sep 2022 03:46:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=yYCfKeGcTkqu5qBAQbw2UoaLHIe9hcO+llsGClyycow=; b=hGFfiY0Wz5xErgR5lACH1RDbjWQt/TlVQEPjsH3SuB5/ChBjHnICd7ny9b/Kkk3tN1 gn+30+WMs6LhNh01ice24gccg0LwFj8LGldRI/jBvqOBoaPBSdFnxec2AOfromMwJmgQ 2AWOzvLQemSnte957BOqzl+pbcKhNl6U7FThVCNXuCTAe4ReBVJ7TlsV9u1ega5tDF3v cPXqrPIX0XNT1DIGR8/kXTvBJLg4FzzDYZh1DvUmCNIhGZOBI4E0o06RNkO2+hFSNnsD KxZgCzT0ri3vEABwcc2hLQrAr7zNgmUAW9H6V00t5Dk+NZ/EPN4oglyMWlSttGlc/2ak weog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=yYCfKeGcTkqu5qBAQbw2UoaLHIe9hcO+llsGClyycow=; b=bs6ytHxHwiRjUreWwSgD4NOOCh6evSrVOfnP223IpQ6L2UexL8Hz9Rkn91oSolIDfJ e98BcGz8eldRzezNDc0zg4vj7YqQRIStHMxIRzZsMwUPwg/EKbKTtKvl23kBVByyiFH+ O/Xip4QNBGBmgB0AbIxgTpNNikrfkFVnarqLGDax/cyeDMuNv4PQTkQlzDkFjv4L7zqk TJEpt9tTN5zNXjf2hbP3gwlXzzW7gDLpvnn8bypDsW0RBgQ9pbDfqS+UAoVn4StAGkYK wQCOypxehbsKMdcWzRJyH0aRMLePKv0fjcXZ2QL5kCVZYBgQd0P88WzMajJoYqWZURzf JymQ== X-Gm-Message-State: ACrzQf0imz/sZqd35h9cTdx7wM+o8+lx2tsoKuM+AzMiT/rWjcxERwoG 3XyYIU9cydP+34gfm6GSH/qvyzwEsctOYZ9eQT9jHA== X-Google-Smtp-Source: AMsMyM4XHZqWlMmGERuWfYO2Ek0+FZnhSmEZQC1+4kBmVpuYQkBVbAYe7kz+vPi/LvidClc7dA8IF8HPEpTH6o99lOA= X-Received: by 2002:ac2:454a:0:b0:49c:6212:c44d with SMTP id j10-20020ac2454a000000b0049c6212c44dmr4691876lfm.430.1663497971314; Sun, 18 Sep 2022 03:46:11 -0700 (PDT) MIME-Version: 1.0 References: <20220916080305.29574-6-vincent.guittot@linaro.org> <20220916120245.2951-1-hdanton@sina.com> <20220917225819.817-1-hdanton@sina.com> In-Reply-To: <20220917225819.817-1-hdanton@sina.com> From: Vincent Guittot Date: Sun, 18 Sep 2022 12:46:00 +0200 Message-ID: Subject: Re: [PATCH v4 5/8] sched/fair: Take into account latency priority at wakeup To: Hillf Danton Cc: peterz@infradead.org, mgorman@suse.de, valentin.schneider@arm.com, parth@linux.ibm.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=linaro.org header.s=google header.b=hGFfiY0W; spf=pass (imf14.hostedemail.com: domain of vincent.guittot@linaro.org designates 209.85.167.42 as permitted sender) smtp.mailfrom=vincent.guittot@linaro.org; dmarc=pass (policy=none) header.from=linaro.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663497973; a=rsa-sha256; cv=none; b=krkJw0uBOYwCy/dMScX7BAx5GVCSWLKnv4IIVUCjvx8gIqjIm1P2C5kteOWKEZjGLqTbPd GOyY7aWhTVxERSDnjqI7/mWa7fCp6Y8C0AcRY+Y/RtoTUFVwa89as7u6wBc9KcfHlCQNBO XDyASbTMkg6ly7/ALcYDrsClPzbc/AU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663497973; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=yYCfKeGcTkqu5qBAQbw2UoaLHIe9hcO+llsGClyycow=; b=NPuuStKmAaDoGq0uH2L7efIA5soHV87JzCkMUpMVNMV4j0GxuSUl4AKLfMPRtNPLYwJpfm T7BApDmQJnxAT9r2AnMEA3L9jxhHfp3eJw//Mg1YqY5SMdz5Qsy4spLxYajzytaFfK8R6i 35+4DmlfGRFnwjeVDpEg9IgnCldJOug= Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=linaro.org header.s=google header.b=hGFfiY0W; spf=pass (imf14.hostedemail.com: domain of vincent.guittot@linaro.org designates 209.85.167.42 as permitted sender) smtp.mailfrom=vincent.guittot@linaro.org; dmarc=pass (policy=none) header.from=linaro.org X-Stat-Signature: aq88t33upewyqyie9fx5p86da3cqk95y X-Rspamd-Queue-Id: 01602100012 X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1663497972-710769 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sun, 18 Sept 2022 at 00:58, Hillf Danton wrote: > > On 16 Sep 2022 15:36:53 +0200 Vincent Guittot wrote: > > > > Hi Hillf, > > > > On Fri, 16 Sept 2022 at 14:03, Hillf Danton wrote: > > > > > > Hello Vincent > > > > > > On 16 Sep 2022 10:03:02 +0200 Vincent Guittot wrote: > > > > > > > > @@ -4606,6 +4608,7 @@ check_preempt_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr) > > > > > > > > se = __pick_first_entity(cfs_rq); > > > > delta = curr->vruntime - se->vruntime; > > > > + delta -= wakeup_latency_gran(curr, se); > > > > > > > > if (delta < 0) > > > > return; > > > > > > What is derived from the latency nice you added is the runtime granulaity > > > which has a role in preempting the current task. > > > > > > Given the same defination of latency nice as the nice, the runtime granularity > > > can be computed without introducing the latency nice. > > > > > > Only for thoughts now. > > > > > > Hillf > > > > > > +++ b/kernel/sched/fair.c > > > @@ -4569,7 +4569,7 @@ dequeue_entity(struct cfs_rq *cfs_rq, st > > > static void > > > check_preempt_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr) > > > { > > > - unsigned long ideal_runtime, delta_exec; > > > + unsigned long ideal_runtime, delta_exec, granu; > > > struct sched_entity *se; > > > s64 delta; > > > > > > @@ -4594,6 +4594,14 @@ check_preempt_tick(struct cfs_rq *cfs_rq > > > return; > > > > > > se = __pick_first_entity(cfs_rq); > > > + > > > + granu = sysctl_sched_min_granularity + > > > + (ideal_runtime - sysctl_sched_min_granularity) * > > > + (se->latency_nice + 20) / LATENCY_NICE_WIDTH; > > > > There is no latency_nice field in se but a latency_offset instead > > > > Also at this step, we are sure that curr has run at least > > sysctl_sched_min_granularity and we want now to compare curr vruntime > > with first se's one. We take the latency offset into account to make > > sure we will not preempt curr too early > > > > > + > > > + if (delta_exec < granu) > > > + return; > > > + > > > delta = curr->vruntime - se->vruntime; > > > > > > if (delta < 0) > return; > > if (delta > ideal_runtime) > resched_curr(rq_of(cfs_rq)); > > After another look, curr is not preempted without the gap in vruntime > between curr and the first entity growing more than ideal runtime, while Curr can be preempted as it has run more than the ideal time (1st test). This one is to make sure that the diff does not become too large. Here we reuse the same comparison as wakeup to make sure that a newly curr will get a chance to run its ideal time after having preempted at wakeup the previous current > with latency_offset, since the gap becomes larger, preempt happens later > than ideal runtime thoughts IMO.