Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3773258yba; Tue, 23 Apr 2019 09:21:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqwKVHjILw/8js9JX6yY7K3nkSWDjB7Kshu1wzXHBxDJ9rr1CjOp4Cgs4lltsLPXTlW2dtRf X-Received: by 2002:a17:902:2827:: with SMTP id e36mr26351942plb.45.1556036501601; Tue, 23 Apr 2019 09:21:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556036501; cv=none; d=google.com; s=arc-20160816; b=PGdXxTXl601VzuL+94hGVKACbOzofMDTwn3f/AypHo9/Jkmk0gQ6IanwePT6GoyWEJ hcgisPPDztCHIvhq1ZbNxC1uHDjWl7Vuhm7JYQbSDFE5Tw3xgI2/GJ1W/8pGXyzIUA2T KrFKM6CjpiDbCOsG6dEAugzcPLzaAEAVt0Yif7NwKjM4zsSCYTcL3cMN1Qyd4P1hy6vd iak9fFbLKEM90ozfIUFBPnCSgVmUNhIWsd3+vcPNwhMMY2tKcNb//y4S/7mRFy4iRHEA meisjEONhbLuvSmoOsG7babWKv2+YguQc7TEGQG4UqO3KCogsAyTfmxpGfqhCyQBN8m0 cnUg== 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=DmnzcXMKT614LUDfOLtCanfiofJBz9AMy+7b3x70jWE=; b=PS4xY9UYIJ2SI0SqLHEPfKbdOP+wDFg6P/lvcMo1m/ize38nHXD5p9v3WwpLAlLKEm 97flSf+e+0MKDTAoCviduLRDQ2GGhQE1fV8zxdcddTZ3KMIL3O9EHOAgG5ON3oBwhAbu yq5ikKX770eszWLEB0yFdoE9sFOSPGcJofXJby86r/c81xsdjjKXUyN2c8XAvB+XcTWg OhyF5iLq3gikduAlk3up3m7y8oPwFXdfJzD30uFtIy1uKDaeb59r1vO1RR3liPwdSCYz 5SFRApxUr8WAjuifknvNsWuhOlIgnVyT796ZypbWwC8vWi3UVHA7R1gOmbjZyuuk/rrz rBhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@digitalocean.com header.s=google header.b="hm8ET/me"; 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 e19si15127498pgv.63.2019.04.23.09.21.26; Tue, 23 Apr 2019 09:21:41 -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="hm8ET/me"; 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 S1728572AbfDWQUC (ORCPT + 99 others); Tue, 23 Apr 2019 12:20:02 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:39983 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728573AbfDWQSl (ORCPT ); Tue, 23 Apr 2019 12:18:41 -0400 Received: by mail-it1-f194.google.com with SMTP id k64so1086290itb.5 for ; Tue, 23 Apr 2019 09:18:40 -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=DmnzcXMKT614LUDfOLtCanfiofJBz9AMy+7b3x70jWE=; b=hm8ET/me6hfHHm8HpmhPzjzR4WVmOLpriPniYE4BgXE9Nc1BMmWcNdsykWOxD8C80G /iriwglBvMyDElHjPzQdc6JxSKtAFDrVC/iV5veJOOHbN/BRG0TuCxoRbFmbmtXPTzek ChvpIpCq9YpdBhwnDo71kR5PQTASSeshyjrDw= 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=DmnzcXMKT614LUDfOLtCanfiofJBz9AMy+7b3x70jWE=; b=J567JmlmSc87MoCQ+gkKqAlz98D9JN6oX3oYIsSsikCyeZvb1HgUu232V84tt8KkTw ZC6A7pVO0uBabe8aL0zYE3qV7TzcNYJbQ6SxxkdKykCqrIIuN5V8pY3lzdk6/T4fk9J1 mBILliDZcoiOdGYYHNnKe4EVaZID5/SDekB1Rh40XfpxUTR2EUATMRiud42EAS1nqvuz ub6MiQZYis9SqTKsXLN4s3AUe2jnZBcojTFQYm0XCt2tyAnlNQTGajYOg1hEyZ/qpDQz dICYu1TGOi8AdcOyS8UUlaeMogB1A6UkYbPXVYbl4GkIZmuR4O01bMK0HgxPO3bIt+KZ y2Mg== X-Gm-Message-State: APjAAAWpzLQU7ZgZTwxesEQRor9Wz2qreo1kWH9Sw3VX3osLEQnsphCk 7E5KK01OWxkq0T7oXNLZ0epiWQ== X-Received: by 2002:a24:4210:: with SMTP id i16mr190848itb.37.1556036320450; Tue, 23 Apr 2019 09:18:40 -0700 (PDT) Received: from swap-tester ([178.128.225.14]) by smtp.gmail.com with ESMTPSA id l8sm5600925iob.39.2019.04.23.09.18.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Apr 2019 09:18:39 -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 v2 04/17] sched/{rt,deadline}: Fix set_next_task vs pick_next_task Date: Tue, 23 Apr 2019 16:18:09 +0000 Message-Id: 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 (Intel) 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 133fbcc58ea1..b8e15c7aa889 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -1695,12 +1695,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, @@ -1759,15 +1768,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; } @@ -1814,7 +1815,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