Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2563102imm; Mon, 10 Sep 2018 03:10:05 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbBLfC8zdawCQik+OnbCoOfCk4a2yYQbC1ffi1M6ayBWe34eEYv/leYjKCT0NXpRPgmdaI+ X-Received: by 2002:a62:6c85:: with SMTP id h127-v6mr22888157pfc.65.1536574205368; Mon, 10 Sep 2018 03:10:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536574205; cv=none; d=google.com; s=arc-20160816; b=EVq5p8IQXJKPRq7QOAPTJp2CYjIdKLjtYvClzd7J/T96CvnQrXakU9+pS3FpT2ZGo/ qi8i/1eeAu/fadrIaPCwSFV6JzA7U86+LA0dSW7iSYH6fVvUhugjTTONEZ1bWhWABaZg ye3rVJRokioOS9VA4YrFxi+mJx/kzEEVqq68gpl324atbTiyx21kAkFon8VQj9SMgRPZ NcaMb8YIlHUHTHZ8BPRdXfQzixJ0n7kPNrjIGi12TpImIFEqVluuGmns3JlD/jJjEcTQ +l4/1kMFlEEv7ku3c0bC+FQOyFVu6W9s91Dtwup6EMbmjWgKew04LuO08oIzpJKfLhG3 b7VA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date; bh=ahvLWTVofSu5iMild4RStGIVl5V5hgTMNbTzw04L0pI=; b=qPMltLU8cVXOze0n6ELNsDlAINLgM5qli1Kd9juWYF+vz6hrUT9seesG1rtfhVMdTs fP3eYd4NHdqC7/xXfIKJ0htc8CR+RnWbmy4pyd9qaQagT9KTo5CDpkVZEnpsFuX7iGBf p0f6hqnf7SNXhL785SJZ3XxZ6WcR2nwtp+D9Ba0aM99y1E6D5IZFsqaqCyicEAxFq1Mp 4KIIOdK65tpccWYZDX+ARrow3yZznN4fdCXGsDbfJF6ifVsZnUHI3bQ0zptaotvFC/hN XLV1lOiQ14K8P3sYTEU2eN58FkfTGryGiDiWkrDwuX3k/RWNtPLT4/grb3abTqOVn/68 DAeg== 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 1-v6si16942495pgb.107.2018.09.10.03.09.50; Mon, 10 Sep 2018 03:10:05 -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 S1728245AbeIJPA6 (ORCPT + 99 others); Mon, 10 Sep 2018 11:00:58 -0400 Received: from terminus.zytor.com ([198.137.202.136]:39161 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726907AbeIJPA5 (ORCPT ); Mon, 10 Sep 2018 11:00:57 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w8AA7GDU1806967 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 10 Sep 2018 03:07:16 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w8AA7GiK1806964; Mon, 10 Sep 2018 03:07:16 -0700 Date: Mon, 10 Sep 2018 03:07:16 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Steve Muckle Message-ID: Cc: tglx@linutronix.de, dietmar.eggemann@arm.com, Morten.Rasmussen@arm.com, tkjos@google.com, peterz@infradead.org, quentin.perret@arm.com, smuckle@google.com, migueldedios@google.com, Patrick.Bellasi@arm.com, torvalds@linux-foundation.org, pjt@google.com, linux-kernel@vger.kernel.org, joaodias@google.com, mingo@kernel.org, hpa@zytor.com, Chris.Redpath@arm.com Reply-To: tglx@linutronix.de, dietmar.eggemann@arm.com, Morten.Rasmussen@arm.com, tkjos@google.com, peterz@infradead.org, smuckle@google.com, quentin.perret@arm.com, migueldedios@google.com, torvalds@linux-foundation.org, Patrick.Bellasi@arm.com, pjt@google.com, linux-kernel@vger.kernel.org, joaodias@google.com, mingo@kernel.org, hpa@zytor.com, Chris.Redpath@arm.com In-Reply-To: <20180831224217.169476-1-smuckle@google.com> References: <20180831224217.169476-1-smuckle@google.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:sched/core] sched/fair: Fix vruntime_normalized() for remote non-migration wakeup Git-Commit-ID: d0cdb3ce8834332d918fc9c8ff74f8a169ec9abe X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: d0cdb3ce8834332d918fc9c8ff74f8a169ec9abe Gitweb: https://git.kernel.org/tip/d0cdb3ce8834332d918fc9c8ff74f8a169ec9abe Author: Steve Muckle AuthorDate: Fri, 31 Aug 2018 15:42:17 -0700 Committer: Ingo Molnar CommitDate: Mon, 10 Sep 2018 10:13:47 +0200 sched/fair: Fix vruntime_normalized() for remote non-migration wakeup 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(), rq->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 John Dias . Suggested-by: Peter Zijlstra Tested-by: Dietmar Eggemann Signed-off-by: Steve Muckle Signed-off-by: Peter Zijlstra (Intel) Cc: Chris Redpath Cc: John Dias Cc: Linus Torvalds Cc: Miguel de Dios Cc: Morten Rasmussen Cc: Patrick Bellasi Cc: Paul Turner Cc: Quentin Perret Cc: Thomas Gleixner Cc: Todd Kjos Cc: kernel-team@android.com Fixes: b5179ac70de8 ("sched/fair: Prepare to fix fairness problems on migration") Link: http://lkml.kernel.org/r/20180831224217.169476-1-smuckle@google.com Signed-off-by: Ingo Molnar --- 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 8cff8d55ee95..c6b7d6daab20 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -9644,7 +9644,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;