Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6813428ybi; Wed, 29 May 2019 13:40:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqx3cswV68yrVo0Vr1LtTBd4aObSUVKj3SdxelpOIKUIllBD7fDB9Vcw3D+PQq1y3rWv3OCn X-Received: by 2002:a17:902:14e:: with SMTP id 72mr98856928plb.36.1559162401614; Wed, 29 May 2019 13:40:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559162401; cv=none; d=google.com; s=arc-20160816; b=MMQxZzP6D+ViFpC406qHWCVJ70iT21FMd/c8hgKlXlZfrdB2qXWZSw17PJLdujfAt7 jehdo0E152UzBF+rA22igluMVXU1yzwZU+Pem4Wel/hscJ/3KwRg3QBhuRXf5NIxm8ca OFEqxdGkhqsRZdGUzR8bL+2Eeb9Xqh9lRUhHi1QhC/O8ROunAN6kOLZJvdzmwPtBlp13 PPErbNptLDv3ZoAbs2Antzm7OCJJzcXuJUnUXHEmR2Z7VmOM7Zb1DKGLsG7VZ+9+L2xW oG4lTAc0iPHkWiipYHMqKTTdY7Nyrx0SBkNjxDbQRLyeMhnzYYeeXbrZ1oF7kL1rBtq2 UetA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=G0IRZhtbIKeaZkChlh1OzdrtZcJGCkc1xSr+O9r8B4A=; b=cxBLhG1yOCa095A3gznxxA3uOO9Q4k9G4WZH2QJ0Ps+nKDKXLu42slzZji3ALZQ2fH 6svlz5zhqD6NOxRUfDXF2BGF3hd1LPizic5BWmZyPXloFQK9YpzK1wmFghg47+oxtveQ FG+DOiW0zKDr0OGRt9wrSa/KOzWpKiynSkxpFLzXsGgv5qx+RH1hQlNu15RBq0iqxfqN WqpdqABCxHg5s87i0OC3+vaXCXRuOitnuoKMqVN8lTm2CqJPy4aYFf/6F46u8y8/QhOJ O4voF8jPgxgcF89iO9JUWcwyrS9ew02AlCCAO0WkcesM8qZRIe4+QCsGUrdAhx3/vIhe 868Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@digitalocean.com header.s=google header.b=XfqTF9U8; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=digitalocean.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q20si460023pjp.96.2019.05.29.13.39.46; Wed, 29 May 2019 13:40:01 -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; dkim=pass header.i=@digitalocean.com header.s=google header.b=XfqTF9U8; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=digitalocean.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726977AbfE2UiB (ORCPT + 99 others); Wed, 29 May 2019 16:38:01 -0400 Received: from mail-it1-f195.google.com ([209.85.166.195]:55803 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726652AbfE2UhC (ORCPT ); Wed, 29 May 2019 16:37:02 -0400 Received: by mail-it1-f195.google.com with SMTP id g24so6235648iti.5 for ; Wed, 29 May 2019 13:37:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=digitalocean.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=G0IRZhtbIKeaZkChlh1OzdrtZcJGCkc1xSr+O9r8B4A=; b=XfqTF9U8bytYV7Iqoj+RDzMO5rbryTRYkoLmkUd1ovcAQ+Vs1nZT+W781PY9UNEqOl eWg7YyCW5fl18c/Jhf/GcnRXgoiJR/k3/7oCiGmM283Rjon4U6iabol62H6TWsxhkE6h t/SPWIpwfBjiV1S0k7EBlKlo8OEttx9vHLZaU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=G0IRZhtbIKeaZkChlh1OzdrtZcJGCkc1xSr+O9r8B4A=; b=aQLkw5XvU0ApJaQH8YU1VqsQmNJjfl6LpeHLwSlvUxgcUKpY9FYH3uDO/RtxNt4p39 wfsSNDWXOFOlcJJlnm7P4fEY55FaSZXqep9MpFGBRLDAr5MR4tk+yzd3ZhfmdldNSsdW bNVdoB9a+SNSpQDSCYTxGhinq5U46CadJXW0N0ct9RQtpzKiJIhd+eZxb5/79F/BMMyF cZho7hUJil8n4Q133eQ+UQFr5z/nvp+D5Z8Ms1DwjVU9zxg1DzW109GbIqWAzKSYyY2j y1T9vPi3KOahbNbHbhUlzJ3u1DX6vDpmHCkcE3RH0pjTLgWA2gatm5nFo0HSRuWv9cCw Nk2A== X-Gm-Message-State: APjAAAXolCdtisZstp1EieBF77F+tXz4/2XcvFr3HdJrqWYI9zS8RK/2 rxupMl2TXPrtVV13Q/pBbY9MTA== X-Received: by 2002:a24:78d1:: with SMTP id p200mr161999itc.69.1559162221330; Wed, 29 May 2019 13:37:01 -0700 (PDT) Received: from swap-tester ([178.128.225.14]) by smtp.gmail.com with ESMTPSA id t63sm161997ita.42.2019.05.29.13.37.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 29 May 2019 13:37:00 -0700 (PDT) From: Vineeth Remanan Pillai To: Nishanth Aravamudan , Julien Desfossez , Peter Zijlstra , Tim Chen , mingo@kernel.org, tglx@linutronix.de, pjt@google.com, torvalds@linux-foundation.org Cc: linux-kernel@vger.kernel.org, subhra.mazumdar@oracle.com, fweisbec@gmail.com, keescook@chromium.org, kerrnel@google.com, Phil Auld , Aaron Lu , Aubrey Li , Valentin Schneider , Mel Gorman , Pawan Gupta , Paolo Bonzini Subject: [RFC PATCH v3 04/16] sched/{rt,deadline}: Fix set_next_task vs pick_next_task Date: Wed, 29 May 2019 20:36:40 +0000 Message-Id: <38c61d5240553e043c27c5e00b9dd0d184dd6081.1559129225.git.vpillai@digitalocean.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Zijlstra Because pick_next_task() implies set_curr_task() and some of the details haven't matter too much, some of what _should_ be in set_curr_task() ended up in pick_next_task, correct this. This prepares the way for a pick_next_task() variant that does not affect the current state; allowing remote picking. Signed-off-by: Peter Zijlstra (Intel) --- kernel/sched/deadline.c | 23 ++++++++++++----------- kernel/sched/rt.c | 27 ++++++++++++++------------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index e683d4c19ab8..0783dfa65150 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -1694,12 +1694,21 @@ static void start_hrtick_dl(struct rq *rq, struct task_struct *p) } #endif -static inline void set_next_task(struct rq *rq, struct task_struct *p) +static void set_next_task_dl(struct rq *rq, struct task_struct *p) { p->se.exec_start = rq_clock_task(rq); /* You can't push away the running task */ dequeue_pushable_dl_task(rq, p); + + if (hrtick_enabled(rq)) + start_hrtick_dl(rq, p); + + if (rq->curr->sched_class != &dl_sched_class) + update_dl_rq_load_avg(rq_clock_pelt(rq), rq, 0); + + if (rq->curr != p) + deadline_queue_push_tasks(rq); } static struct sched_dl_entity *pick_next_dl_entity(struct rq *rq, @@ -1758,15 +1767,7 @@ pick_next_task_dl(struct rq *rq, struct task_struct *prev, struct rq_flags *rf) p = dl_task_of(dl_se); - set_next_task(rq, p); - - if (hrtick_enabled(rq)) - start_hrtick_dl(rq, p); - - deadline_queue_push_tasks(rq); - - if (rq->curr->sched_class != &dl_sched_class) - update_dl_rq_load_avg(rq_clock_pelt(rq), rq, 0); + set_next_task_dl(rq, p); return p; } @@ -1813,7 +1814,7 @@ static void task_fork_dl(struct task_struct *p) static void set_curr_task_dl(struct rq *rq) { - set_next_task(rq, rq->curr); + set_next_task_dl(rq, rq->curr); } #ifdef CONFIG_SMP diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 3d9db8c75d53..353ad960691b 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -1498,12 +1498,23 @@ static void check_preempt_curr_rt(struct rq *rq, struct task_struct *p, int flag #endif } -static inline void set_next_task(struct rq *rq, struct task_struct *p) +static inline void set_next_task_rt(struct rq *rq, struct task_struct *p) { p->se.exec_start = rq_clock_task(rq); /* The running task is never eligible for pushing */ dequeue_pushable_task(rq, p); + + /* + * If prev task was rt, put_prev_task() has already updated the + * utilization. We only care of the case where we start to schedule a + * rt task + */ + if (rq->curr->sched_class != &rt_sched_class) + update_rt_rq_load_avg(rq_clock_pelt(rq), rq, 0); + + if (rq->curr != p) + rt_queue_push_tasks(rq); } static struct sched_rt_entity *pick_next_rt_entity(struct rq *rq, @@ -1577,17 +1588,7 @@ pick_next_task_rt(struct rq *rq, struct task_struct *prev, struct rq_flags *rf) p = _pick_next_task_rt(rq); - set_next_task(rq, p); - - rt_queue_push_tasks(rq); - - /* - * If prev task was rt, put_prev_task() has already updated the - * utilization. We only care of the case where we start to schedule a - * rt task - */ - if (rq->curr->sched_class != &rt_sched_class) - update_rt_rq_load_avg(rq_clock_pelt(rq), rq, 0); + set_next_task_rt(rq, p); return p; } @@ -2356,7 +2357,7 @@ static void task_tick_rt(struct rq *rq, struct task_struct *p, int queued) static void set_curr_task_rt(struct rq *rq) { - set_next_task(rq, rq->curr); + set_next_task_rt(rq, rq->curr); } static unsigned int get_rr_interval_rt(struct rq *rq, struct task_struct *task) -- 2.17.1