Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1377489imm; Sun, 2 Sep 2018 21:28:35 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY0TOsTAetxkngk07ItcCTm531t2PNonQluMe7q3LcBngrzPDwi1YPZtqLAsHW9QRpDChc/ X-Received: by 2002:a17:902:8f8c:: with SMTP id z12-v6mr26413453plo.4.1535948915436; Sun, 02 Sep 2018 21:28:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535948915; cv=none; d=google.com; s=arc-20160816; b=TBh0jeSpURvsXkS+ORbgocYj5wAdLID3AtmwM4EKUEKF0H3ifjEwAfm0sbNGSoxaot nUYM0WfQIlX3zAE5j2SL7m2dawBN2lRTga1WaeHnW4Rrcz+wmVZegcbxyo9BR/6QyrZE NafSUptSQbyIycFhi8JqJc2/F5R5bSwyIFbW9tppLpK6mw+icgIICbIlMEeYVj9tvd/p 7d67MzgKnbo7KxQxbHyQEq5hpofgaUOa6dioViBiqhlcTegMhI+pvFYsUSM3YWDI1XRB rOqpGopYxxKdFsIaa4CRm5W2lJkLLL2hmibObrioL3V/dn+KOCZbyTa7Vifqwq2nUaeT 0qIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=lS196D+1s3wcjRzRypyImI961vhy8/KQ/rfOJcBgYoM=; b=WyZSElX13mXfm8MOqpfve/NODyAGLhtWRFIx9p2IHeNV2oCw3bJBx8Nip4k4PVlzqZ InWEEgm3cjFXm8WEmDIGOYLJalCEJflL5mmby74GCNDWxCLd5dtXoK2NMRWox/wfkK6S j7/NQerXu6yICgcYxW9qyEVCkYodGNwog2s9yUdHOIXZYX8yfgiY+f6EWeDd5+tuSDPi mGUn1ZLLfXH3bNJqbGrQP6sS5aU50pD6gZVIvtHzELyoH/g/bVF9Y4dYKR54jTLRP8Xg 8ihvxGDgXQeytcjiQVCiCrBTlPkXZkZVsAOWSv9q614znuJKtdefv0QsSkH03FdONYVH qgxg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p23-v6si9897377plr.423.2018.09.02.21.28.20; Sun, 02 Sep 2018 21:28:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725984AbeICIpj (ORCPT + 99 others); Mon, 3 Sep 2018 04:45:39 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:49952 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725854AbeICIpj (ORCPT ); Mon, 3 Sep 2018 04:45:39 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A38A680D; Sun, 2 Sep 2018 21:27:17 -0700 (PDT) Received: from [192.168.1.76] (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F0E143F575; Sun, 2 Sep 2018 21:27:16 -0700 (PDT) Subject: Re: [PATCH] sched/fair: fix vruntime_normalized for remote non-migration wakeup To: Steve Muckle , Peter Zijlstra , Ingo Molnar Cc: linux-kernel@vger.kernel.org, kernel-team@android.com, Todd Kjos , Paul Turner , Quentin Perret , Patrick Bellasi , Chris Redpath , Morten Rasmussen , Miguel de Dios , John Dias References: <20180831224217.169476-1-smuckle@google.com> From: Dietmar Eggemann Message-ID: Date: Sun, 2 Sep 2018 21:27:16 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180831224217.169476-1-smuckle@google.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/31/2018 03:42 PM, Steve Muckle wrote: > When a task which previously ran on a given CPU is remotely queued to > wake up on that same CPU, there is a period where the task's state is > TASK_WAKING and its vruntime is not normalized. This is not accounted > for in vruntime_normalized() which will cause an > error in the task's vruntime if it is switched from the fair class > during this time, for example if it is boosted to RT priority via > rt_mutex_setprio. The rq's min_vruntime will not be subtracted from the > task's vruntime but it will be added again when the task returns to the > fair class. The task's vruntime will have been erroneously doubled and > the effective priority of the task will be reduced. > > Note this will also lead to inflation of all vruntimes since the doubled > vruntime value will become the rq's min_vruntime when other tasks leave > the rq. This leads to repeated doubling of the vruntime and priority > penalty. > > Fix this by recognizing a WAKING task's vruntime as normalized only if > sched_remote_wakeup is true. This indicates a migration, in which case > the vruntime would have been normalized in migrate_task_rq_fair(). > > Based on a similar patch from joaodias@google.com. > > Suggested-by: Peter Zijlstra > Signed-off-by: Steve Muckle > --- > kernel/sched/fair.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index b39fb596f6c1..b3b62cf37fb6 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -9638,7 +9638,8 @@ static inline bool vruntime_normalized(struct task_struct *p) > * - A task which has been woken up by try_to_wake_up() and > * waiting for actually being woken up by sched_ttwu_pending(). > */ > - if (!se->sum_exec_runtime || p->state == TASK_WAKING) > + if (!se->sum_exec_runtime || > + (p->state == TASK_WAKING && p->sched_remote_wakeup)) > return true; > > return false; > Tested-by: Dietmar Eggemann