Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp722910imm; Thu, 13 Sep 2018 06:50:52 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYIffT7eS4pmDQiXBrr1DxyGTd+NhMvtSpgTjKGeDbyTH8UEo03DXYHFR2YFInp+jybfS0U X-Received: by 2002:a62:9992:: with SMTP id t18-v6mr7566735pfk.239.1536846652704; Thu, 13 Sep 2018 06:50:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536846652; cv=none; d=google.com; s=arc-20160816; b=IegJqCTTivyv2v3udleHkt1lwW4aJXk6BJjywAkcm7G28D0N2l8eReJPnRJmLMjPQq 2rK/vOzh3/g9jqKEgnawtne8kf3cPFbLaYjzAYLCp8Kchi5BbqFtiUHRwZxKo51eDhki aCIw/mrEnyBSbK9T958Cl8/zkgdZIj6cK6CtlgNJmvvn22lSlsOgBpSMsRnbkULa1vJa PiyTXTSqY0e1ztpVwigw1Byn9uBRAV+YUMwV8C3amsUW1s6M3vP8ZXJNpZrQhxWzIb+M PpGOkc50ox3WdcWKkOcCKd54A3z15kz0EY3ot1DH1YxZzghgeDwB9MWOAK73mcvqqDx1 3A9A== 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=DSScQX6TZW/aRaaEZRp905nvGIoYnTvVQmST0EYK1Go=; b=SBKcb0BOrWHz18HqvxjykmgZzyyXFwcxct+qOQzNr3gAPyqrSjp1db2wHv/BImuKQ2 psoWi86Dkkw7cMDIb1o5+DLvse4Kk8p4NydFtIzVn8WtBfckQauuF4xnuZZBuYN9x7x4 zrR9eqa70yLxSi7p/cK+Eego71roUGG2Be/n9evfoJ41Mg/fNMxh8a79Ec1k/NFctAIS ZZQJ2PQ1m6WLKdU6rDO2QxDC37R5cKyPupTBxTiPr4NR9gM5hSyPKFoJBYJFtRcfdSVt LlopZnrg4GenpmeMntoLkpOigsySbKKEyV4HWXk6l1/KIfVEql/hIHVTam6FQl5iwcFZ rAtw== 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 g2-v6si4710216pgg.83.2018.09.13.06.50.37; Thu, 13 Sep 2018 06:50:52 -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 S1730425AbeIMS7d (ORCPT + 99 others); Thu, 13 Sep 2018 14:59:33 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33086 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729686AbeIMS7d (ORCPT ); Thu, 13 Sep 2018 14:59:33 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id A79B8D1A; Thu, 13 Sep 2018 13:49:58 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, luca abeni , "Peter Zijlstra (Intel)" , Daniel Bristot de Oliveira , Juri Lelli , Linus Torvalds , Mathieu Poirier , Mike Galbraith , Steven Rostedt , Thomas Gleixner , Ingo Molnar , Sudip Mukherjee Subject: [PATCH 4.14 097/115] sched/deadline: Fix switching to -deadline Date: Thu, 13 Sep 2018 15:31:57 +0200 Message-Id: <20180913131829.395953899@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180913131823.327472833@linuxfoundation.org> References: <20180913131823.327472833@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: Luca Abeni commit 295d6d5e373607729bcc8182c25afe964655714f upstream. Fix a bug introduced in: 72f9f3fdc928 ("sched/deadline: Remove dl_new from struct sched_dl_entity") After that commit, when switching to -deadline if the scheduling deadline of a task is in the past then switched_to_dl() calls setup_new_entity() to properly initialize the scheduling deadline and runtime. The problem is that the task is enqueued _before_ having its parameters initialized by setup_new_entity(), and this can cause problems. For example, a task with its out-of-date deadline in the past will potentially be enqueued as the highest priority one; however, its adjusted deadline may not be the earliest one. This patch fixes the problem by initializing the task's parameters before enqueuing it. Signed-off-by: luca abeni Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Daniel Bristot de Oliveira Cc: Juri Lelli Cc: Linus Torvalds Cc: Mathieu Poirier Cc: Mike Galbraith Cc: Peter Zijlstra Cc: Steven Rostedt Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1504778971-13573-3-git-send-email-luca.abeni@santannapisa.it Signed-off-by: Ingo Molnar Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- kernel/sched/deadline.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -1365,6 +1365,10 @@ enqueue_dl_entity(struct sched_dl_entity update_dl_entity(dl_se, pi_se); } else if (flags & ENQUEUE_REPLENISH) { replenish_dl_entity(dl_se, pi_se); + } else if ((flags & ENQUEUE_RESTORE) && + dl_time_before(dl_se->deadline, + rq_clock(rq_of_dl_rq(dl_rq_of_se(dl_se))))) { + setup_new_dl_entity(dl_se); } __enqueue_dl_entity(dl_se); @@ -2256,13 +2260,6 @@ static void switched_to_dl(struct rq *rq return; } - /* - * If p is boosted we already updated its params in - * rt_mutex_setprio()->enqueue_task(..., ENQUEUE_REPLENISH), - * p's deadline being now already after rq_clock(rq). - */ - if (dl_time_before(p->dl.deadline, rq_clock(rq))) - setup_new_dl_entity(&p->dl); if (rq->curr != p) { #ifdef CONFIG_SMP