Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4090063ybz; Mon, 20 Apr 2020 15:34:06 -0700 (PDT) X-Google-Smtp-Source: APiQypL4X84/dG6s41TPBmImg2HbsgFsBOF/Ko4JTbccjkNrYUh/SwOmd86m7w57DH01ogHFrAdW X-Received: by 2002:a05:6402:120a:: with SMTP id c10mr15316747edw.15.1587422046036; Mon, 20 Apr 2020 15:34:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587422046; cv=none; d=google.com; s=arc-20160816; b=HWDimlPvYbkNMZF6opO2n05+WA28muAFwXJ2U/cSV/TWDQaTv9uLh52lY19+Af/EuX iwbIviAm+9fsYFPQtff015rEmUZ1XCzoem891SzhSYnGmhCrf1qmaLiBJrFgWYP3eOYX kIWfTc4NIpScH4hEGgaSfDuPQ0IJ8ij7xlN+x06Ptl+OVwLh7WAHNZnlEY8bNdAU8phL VqtoAiPPF520vu8MPoVCyfE/1SsxRbEAPnBCY+1igjSqK8y7sfy+42drozYvM+lJKi6x kpizV+t2hDS3vTvm2VJPkHhwYmIj7o8NeAcMK94Cc6GycQGJgj+zVsr1yFgpPSlHEweK 2ojA== 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 :references:in-reply-to:message-id:subject:cc:to:from:date; bh=n9akk1tWHtlXz0icjxcg80OLmiwBiGUI50GUfBuhC0c=; b=q7J08gLQZXRGeIF8SMBLqqa+nQfNaoNpj4clzE8D9rSSNWNGzr7jJv+2z3I9RWNAxj ubwJlABPwLRLq92Hb5zSuXv5nif091CwkPIRLsINtYjr9Oy1N1TyTlxXlEZ+DhF79r86 vU5V7V2CKSujONOnA2TjiHIvH95Q12PDfJf2TwmX6RGPfQuzWxJ9PWQ0ZQXJmnJm9Cj0 a5JmzJ+jv5yBROUZqtkchQxvecAzbIu8fTYdO6wiSblSrXQ2agTYXi5gpjJbboFir/yD RkEKG0mf51/Ku2qcpSrYfg0s4P7Z5c91Jc+RksAVYdgeOOvvI5UfvrIOPNLwl4OgcvjB NN6Q== 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 s15si474297edr.462.2020.04.20.15.33.36; Mon, 20 Apr 2020 15:34:06 -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 S1726389AbgDTWcf (ORCPT + 99 others); Mon, 20 Apr 2020 18:32:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:50110 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725918AbgDTWcf (ORCPT ); Mon, 20 Apr 2020 18:32:35 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6478520857; Mon, 20 Apr 2020 22:32:34 +0000 (UTC) Date: Mon, 20 Apr 2020 18:32:32 -0400 From: Steven Rostedt To: Chen Yu Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman Subject: Re: [PATCH 2/2] sched: Extract the task putting code from pick_next_task() Message-ID: <20200420183232.16b83374@gandalf.local.home> In-Reply-To: <7c1eab789cb4b53ec5f54644c089ce27ea14088a.1587309963.git.yu.c.chen@intel.com> References: <7c1eab789cb4b53ec5f54644c089ce27ea14088a.1587309963.git.yu.c.chen@intel.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 20 Apr 2020 00:31:52 +0800 Chen Yu wrote: > Introduce a new function finish_prev_task() 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 > --- > 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 3a61a3b8eaa9..bf59a5cf030c 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -3904,6 +3904,28 @@ static inline void schedule_debug(struct task_struct *prev, bool preempt) > schedstat_inc(this_rq()->sched_count); > } > > +static void finish_prev_task(struct rq *rq, struct task_struct *prev, > + struct rq_flags *rf) > +{ > + const struct sched_class *class; > +#ifdef CONFIG_SMP > + /* > + * We must do the balancing pass before put_next_task(), such I know this is just a cut and paste move, but I'm thinking that this comment is wrong. Shouldn't this be "put_prev_task()" as we have no "put_next_task()" function. > + * 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: > */ > @@ -3937,22 +3959,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); > + finish_prev_task(rq, prev, rf); I'm not sure I like the name of this function. Perhaps "balance_and_put_prev_task()"? Something more in kind to what the function does. -- Steve > > for_each_class(class) { > p = class->pick_next_task(rq);