Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1784166imm; Thu, 27 Sep 2018 02:25:16 -0700 (PDT) X-Google-Smtp-Source: ACcGV63S+g8jY/SaE64dBopT9CEhQbontmkKvaYWs/8cUqfG6296bjlRZ0uZWd57B00ts/7WuIAv X-Received: by 2002:a17:902:b94b:: with SMTP id h11-v6mr9873585pls.221.1538040316056; Thu, 27 Sep 2018 02:25:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538040316; cv=none; d=google.com; s=arc-20160816; b=xc0SNcgUucE8NKu1qadJckuCaySwjWuFpLclUKQ6v+v0cfeId3AcyNGbB7ZVDFs+sg uvKyB1qx230trPml8SIjy9HZyRKOUFsEnHCtEYOOsDlVbKGJGfqGsciOXqHVRRrOPi8E rjfYbxsIHOC99AaRr2pATHkVnQBB1weYN4upljuEfzR8sHU2dDrRudszV67sCLnuF7Ca qzJus85WAuSnGrbG7gnRl7QxdY4hh8NzPdAqQXsmMp3sbT2i+NlMjQs7LFEuNYhS02aC YmARLMQTasurbQLAeYi8Hdj3oY6tuLmI3uicWTH7cyNUOiKS1AgaQh3Mw8nINAc9UMqH yInA== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=BUOep0awXAi7qwofg3a70z+ePF3f5uN7eV886N1IUyI=; b=qeLbWx2SVTe2bG3yiDpTxazoyqhyHVZPx0LxB48raoizn2nJAi12rUHRh8qJoWcgY/ A9hm0+rMyAbFsbs90MjkW6YBpk5QaGNOoLbIc/Tb0JH92Kr/9zNO1aQzUG1JYFU5wFez B1LiGWD2wE4NY2s7xtquHkwOObH06LhC3uS4pbi7W4x5/LtmOQAOeNEq48RY8debRtzk G0vmiIRB1uxyPv5ZHjEpB3sRLn1Msj1Fod2D2GB4bPAKrKMt7JDg/k58AsKhkHmQ3rYj lV47UYu9NAZy6HCi2K+7shRish5euQvKo1/6F3n46rvfjl80Kl++T04DAx7Lq62Z4L6k qI5w== 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 f7-v6si1549987plo.109.2018.09.27.02.25.00; Thu, 27 Sep 2018 02:25:16 -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 S1728873AbeI0Pl5 (ORCPT + 99 others); Thu, 27 Sep 2018 11:41:57 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:56692 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727432AbeI0Pl5 (ORCPT ); Thu, 27 Sep 2018 11:41:57 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id C807D1113; Thu, 27 Sep 2018 09:24:35 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Zijlstra , Dietmar Eggemann , Steve Muckle , Chris Redpath , John Dias , Linus Torvalds , Miguel de Dios , Morten Rasmussen , Patrick Bellasi , Paul Turner , Quentin Perret , Thomas Gleixner , Todd Kjos , kernel-team@android.com, Ingo Molnar Subject: [PATCH 4.14 59/64] sched/fair: Fix vruntime_normalized() for remote non-migration wakeup Date: Thu, 27 Sep 2018 11:04:16 +0200 Message-Id: <20180927090258.007180357@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180927090249.801943776@linuxfoundation.org> References: <20180927090249.801943776@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Steve Muckle commit d0cdb3ce8834332d918fc9c8ff74f8a169ec9abe upstream. 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 Signed-off-by: Greg Kroah-Hartman --- kernel/sched/fair.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -9137,7 +9137,8 @@ static inline bool vruntime_normalized(s * - 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;