Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3860405ybz; Mon, 20 Apr 2020 10:46:13 -0700 (PDT) X-Google-Smtp-Source: APiQypLThcybGlfXOtOPNtTLlQ07i/EJG9QyEtJUsAugfS1FJrE+jhrZzoDox1yyXKAclMf9/2Gy X-Received: by 2002:a17:907:b11:: with SMTP id h17mr18189581ejl.371.1587404773377; Mon, 20 Apr 2020 10:46:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587404773; cv=none; d=google.com; s=arc-20160816; b=ja9KK6R0hvlAsc5mFcolxHyzGjSu7qUyDZ4fI/gYgIExjJgt+7KdpUNkK/SbQrIh4c immGLeTlbyBi1/jkksY+QPxbAoZaYaqOXjHfLhaUwiLuskFk44sO3EldHd5v2OgTyZI6 M1pHONRbUSM02GHw1HIV+N2byjVwWHXl21Mq/7mcuJVMqJXaEvXd+/tPybo7kDUcULpf 9l12xwgxKR9H8KJjMm62zywaHqfy/DDpr/VW19FQxPfejB0qDI+eQZWGMukuXFmV0AlE HOzeGodfZPnR1SjwZe1wBQBRsrZib0Q2g3Co23kl3oF+bnzxTrqwy3XnxYK0QDF+G3c8 TMVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:in-reply-to :subject:cc:to:from:user-agent:references; bh=i6nIEjiRXWQBOMAa/RON7hFjVfQy+aKaFr3mAIsdZZ8=; b=qi2lcbfMrYWNM1AWyLDA9UTFzYr6Rk1NpHPc1G2ZR5jPxFoR9WxQ7qvcEHkg/fkUEf kuIipBwoxI6K2wukf06Uh0TiY23WQMDWiNSu7EVeQ+PP8mIoP8DERu8GZHIXqWTMluVN R1m7H/d7uQZcHtEMt+D64yWlmUHJxoSHL+f2QgOYh7pPo4Urc2+8Nrjez73bdgYjZvgV rOnBsQafq1/aFNannHf1jqBX9MmvnBQTMZl/+CKJODFA5zh0GBtRsJ9wWRzYshisDJvy J1aLKtgBNs2kZvu/6/XpVVm1zBUvYgAeV2IFLzXz8QIkJ844NUtItWVAKoRyruEJYd12 YSAw== 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 z3si78406edp.327.2020.04.20.10.45.49; Mon, 20 Apr 2020 10:46:13 -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 S1726908AbgDTRog (ORCPT + 99 others); Mon, 20 Apr 2020 13:44:36 -0400 Received: from foss.arm.com ([217.140.110.172]:52878 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725784AbgDTRog (ORCPT ); Mon, 20 Apr 2020 13:44:36 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 675BA31B; Mon, 20 Apr 2020 10:44:33 -0700 (PDT) Received: from e113632-lin (e113632-lin.cambridge.arm.com [10.1.194.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 03DBB3F73D; Mon, 20 Apr 2020 10:44:31 -0700 (PDT) References: <4f301770996c02f44d52a4868f510025d5a3a558.1587393807.git.yu.c.chen@intel.com> User-agent: mu4e 0.9.17; emacs 26.3 From: Valentin Schneider To: Chen Yu Cc: Peter Zijlstra , Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2][v2] sched: Extract the task putting code from pick_next_task() In-reply-to: <4f301770996c02f44d52a4868f510025d5a3a558.1587393807.git.yu.c.chen@intel.com> Date: Mon, 20 Apr 2020 18:44:29 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20/04/20 16:01, 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. > With the absolutely tiny nit below: Reviewed-by: Valentin Schneider > 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 Nit: I would've put that declaration within the ifdef, given it isn't used outside of it. > + /* > + * 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); > +} > + > /* > * Pick up the highest-prio task: > */