Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1781874imm; Thu, 27 Sep 2018 02:22:44 -0700 (PDT) X-Google-Smtp-Source: ACcGV63eUtfFE2eg6/9g5UogqCV1O3EFq08VqF1FWTNBgEwMaZ+g3wm5kmsRXJmacW/t+Zxa6Dus X-Received: by 2002:a17:902:d909:: with SMTP id c9-v6mr10006057plz.165.1538040164260; Thu, 27 Sep 2018 02:22:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538040164; cv=none; d=google.com; s=arc-20160816; b=HyT/yreNwpjfhIu5grSCTU/1IdsDqwK3cdy1SXpLX84/djb89dOs58+G4G/dBTq2wU kN1bRDsKFGuURvgebbLkA2Hqqy/HE6WyiRf0eIQYMoxXAcoI5+K2pjCKzEkklkyryJFZ dnJdthZYhgMm5Z+x6AkgQV386GS3VNmTtb2lZlvEnvTwVSOfmRbIuuZ/eYU42odrAvW1 FldFHK0uTTU82XSTZqDpO8XWwBFpW+Jhnl61VVw/Hf1wAonh6XxyChDNz/SRXK6lKrkG fGeEm3oLR0XeM6kFh/MWs8uA3sxrxmpB7xCtLhLd4J3T0InWcxwmnW/N7pL5vUulwYWF 8k4g== 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=0Xcjn4WWCxZI4ZCV7OAPcg3g5m74gQI9IBluqh71XRM=; b=NuIxSe8D1hCSZb9YyRqQZco2MlIxL/n4OMuXbn28qdKeY9L+PPM9xJxzEvwFC2eU/Z YBZP/km3J2y29I0opDVVEewpj/+C9Q3QZbQPdq0cKBE+Aupz3L79B2sNy/UWnNuXcAqt r9CChNN1kBTTLP/K5VlmyzvxuSZEc4C/iZJPemBk4dzOl2dXtWPP6JFd5OXYhlk7UIdr LidW2f5oTpeSfXnhUaMEQoH5kcg+l5BTT3VJBUwJpjAWtHNBlHpfqiedbfFogJXYDxzu 8mrWprZDVsGQQ8dfIn2d5E2hlsVJMc5BE7Fm/CbLhvwkcKEFZ9ipuYW8C/IX/hILASHo 08XA== 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 d7-v6si1486421pll.162.2018.09.27.02.22.29; Thu, 27 Sep 2018 02:22:44 -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 S1728652AbeI0Pcy (ORCPT + 99 others); Thu, 27 Sep 2018 11:32:54 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:55616 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727706AbeI0Pcx (ORCPT ); Thu, 27 Sep 2018 11:32:53 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id C534F1117; Thu, 27 Sep 2018 09:15: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.18 86/88] sched/fair: Fix vruntime_normalized() for remote non-migration wakeup Date: Thu, 27 Sep 2018 11:04:07 +0200 Message-Id: <20180927090311.031340865@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180927090300.631426620@linuxfoundation.org> References: <20180927090300.631426620@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.18-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 @@ -10019,7 +10019,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;