Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp947864ybz; Fri, 1 May 2020 11:27:21 -0700 (PDT) X-Google-Smtp-Source: APiQypIxweFF2kP8deIBHYog5+kPI5oaoifJs7mL3S6yZC91lGapW41j5SU2dHit2WMu33JTpOvm X-Received: by 2002:a50:eb8e:: with SMTP id y14mr4667800edr.270.1588357640923; Fri, 01 May 2020 11:27:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588357640; cv=none; d=google.com; s=arc-20160816; b=V4yNWH0v8aXHOk58zahmKqMGhSm2OUauyJgG5/gQGILPrrefMnjSonCW5fcA56xYVb +Gu/qrRZHr1VxOJmeTiyJ2HhlrVCojs1I+Cml+6gziqmcCHwS8OFKKb7ZhOmn8lypZtr 9K6Oj16mvZkkRddxAYrm/z21aFCJJH1T98axY5tICWVufJxAq8nIU45r7I79xd4/SKhc W0txlSmswouqCs585InVvgbFFVY25/5TovFGA7PTAy9yliPFAj9ptVt37bJsO6A9u5F/ +/2ZTMT1eXjRkyrvalCfFPSMuRobWaRuk+MsEoKf3COFhVtFxmLc9Z9B6cFV7H3rfgUc mkJg== 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 :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=RP4UPQ5p76KHQOwuxyZ9nNmwzhpCRdQj/L30oiGt508=; b=EBIz3O2rslBuJqNZ4f/6hWNaqTz9pQ0UvCbpCWKcHuN+8RJa1MrMEAwcl2jRnhw7hN vhTIVahAkfrOF1dfZHB5BVQCPeBIk9fdzPOCtyQnLejHDE5PjKbH/bp7BkOIXYs2Ipcm xh52YmIJQ1hfzpthd5BcGFBOFdOVsmD9KMV78ABI9n0wAHL7WE/B6s3EFgC5FVdVssiY LdWJNX6l5C2t1osdOvFzSsKJ1NP0m7uq/2OcKVRQYzuQyv6LwNfKFmDXCMt3U+Bz6JXt xmQwJdLL2bhjtjXFwXbcVs2caYA15zkl+tQHLTQuuma+AUQ23/vC7v6oGF/HDbxIgjFB zjyQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn16si2238306edb.488.2020.05.01.11.26.57; Fri, 01 May 2020 11:27:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730730AbgEASWd (ORCPT + 99 others); Fri, 1 May 2020 14:22:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1730656AbgEASWZ (ORCPT ); Fri, 1 May 2020 14:22:25 -0400 Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81899C08ED7D; Fri, 1 May 2020 11:22:25 -0700 (PDT) Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jUaIg-0003Y0-KS; Fri, 01 May 2020 20:22:14 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 403981C0330; Fri, 1 May 2020 20:22:09 +0200 (CEST) Date: Fri, 01 May 2020 18:22:09 -0000 From: "tip-bot2 for Chen Yu" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched: Extract the task putting code from pick_next_task() Cc: Peter Zijlstra , Chen Yu , Valentin Schneider , Vincent Guittot , "Steven Rostedt (VMware)" , x86 , LKML In-Reply-To: <5a99860cf66293db58a397d6248bcb2eee326776.1587464698.git.yu.c.chen@intel.com> References: <5a99860cf66293db58a397d6248bcb2eee326776.1587464698.git.yu.c.chen@intel.com> MIME-Version: 1.0 Message-ID: <158835732921.8414.15225436466370563890.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/core branch of tip: Commit-ID: 457d1f465778ccb5f14f7d7a62245e41d12a3804 Gitweb: https://git.kernel.org/tip/457d1f465778ccb5f14f7d7a62245e41d12a3804 Author: Chen Yu AuthorDate: Tue, 21 Apr 2020 18:50:43 +08:00 Committer: Peter Zijlstra CommitterDate: Thu, 30 Apr 2020 20:14:40 +02:00 sched: Extract the task putting code from pick_next_task() Introduce a new function put_prev_task_balance() to do the balance when necessary, and then put previous task back to the run queue. This function is extracted from pick_next_task() to prepare for future usage by other type of task picking logic. No functional change. Suggested-by: Peter Zijlstra Signed-off-by: Chen Yu Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Valentin Schneider Reviewed-by: Vincent Guittot Reviewed-by: Steven Rostedt (VMware) Link: https://lkml.kernel.org/r/5a99860cf66293db58a397d6248bcb2eee326776.1587464698.git.yu.c.chen@intel.com --- kernel/sched/core.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 9a2fbf9..2e6ba9e 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3899,6 +3899,28 @@ static inline void schedule_debug(struct task_struct *prev, bool preempt) schedstat_inc(this_rq()->sched_count); } +static void put_prev_task_balance(struct rq *rq, struct task_struct *prev, + struct rq_flags *rf) +{ +#ifdef CONFIG_SMP + const struct sched_class *class; + /* + * We must do the balancing pass before put_prev_task(), such + * that when we release the rq->lock the task is in the same + * state as before we took rq->lock. + * + * We can terminate the balance pass as soon as we know there is + * a runnable task of @class priority or higher. + */ + for_class_range(class, prev->sched_class, &idle_sched_class) { + if (class->balance(rq, prev, rf)) + break; + } +#endif + + put_prev_task(rq, prev); +} + /* * Pick up the highest-prio task: */ @@ -3932,22 +3954,7 @@ pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags *rf) } restart: -#ifdef CONFIG_SMP - /* - * We must do the balancing pass before put_next_task(), such - * that when we release the rq->lock the task is in the same - * state as before we took rq->lock. - * - * We can terminate the balance pass as soon as we know there is - * a runnable task of @class priority or higher. - */ - for_class_range(class, prev->sched_class, &idle_sched_class) { - if (class->balance(rq, prev, rf)) - break; - } -#endif - - put_prev_task(rq, prev); + put_prev_task_balance(rq, prev, rf); for_each_class(class) { p = class->pick_next_task(rq);