Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3723477ybz; Mon, 20 Apr 2020 08:17:59 -0700 (PDT) X-Google-Smtp-Source: APiQypLDAZK9VFtO61B/N4lxee785Lt/IPit51aYrMHe1c3cPfkfnpbCnTGhh27m9nv94Q9w5Nse X-Received: by 2002:a17:906:359b:: with SMTP id o27mr16817435ejb.282.1587395879409; Mon, 20 Apr 2020 08:17:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587395879; cv=none; d=google.com; s=arc-20160816; b=ilwX+KTykdB/n+yULQsEtzfCOpwQGEc4iJSfN0qDtjw5JDGXQ1DEsMACCFEej1a7BD 0wqhIXBmZ3DdM/dgbRLXZaPS6M1DqPdPBhOEZaN7Dvl1Z41W/gQTFSvclUsmq6Dl4g97 HWGHSf6WoBsWHe/DSPqCbVjjuifXhO99zNZYJi75FspdjElW5lP+5P4llAW93Jj4xo5r j1v7S5YeTz9zHxuGSUbNG+pvVDY7CPNlEqkXilfwHUgmEH5T2UYrGnzb2BFyrwqTXklA elj/mIZwEKNQnhXAWBj7mcKhBYofYFNBKfHsllD674+2hKq198h94tn621NM/lWm+VIF 5p/g== 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:message-id:date :subject:cc:to:from:ironport-sdr:ironport-sdr; bh=8qAOJ3EY74TadvAsijNnTkSvsVQClFJoe6TAybL8JYg=; b=MOdEapzppx5gksEcLAd28YVdy50LhokFnWpDNWU4RBX/Rmtwss1lDG37PMdsbiZQwm j3IU+j6H+LSIaRQHBFPNbnGtj3PWwUk5/jYpX0qZ3Gl2kvdiH0C1XHsKdvuhPgELRvMd e/TGmrM4wEJnZkXSfxsa8R/LXR6Fq5xv7FwtSsC7ZrUlMaTLDfQO2rua7wn+FQOMgMeW d7r2KxzGcNZZYeZ+uT536lj/DxXdC5wdF+tD2b/EBOdLaKPsyarRuYQqsoAVwHE+sVbX s3J0Tf0LMR/XNVOASoJJwQg9XAQE0iJ53PXu/Vbo55r9VhkI6RNjfy+0ArTccNu7eZHE m1yg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u1si975962edf.299.2020.04.20.08.17.36; Mon, 20 Apr 2020 08:17:59 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730049AbgDTPB3 (ORCPT + 99 others); Mon, 20 Apr 2020 11:01:29 -0400 Received: from mga17.intel.com ([192.55.52.151]:7304 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726615AbgDTPB3 (ORCPT ); Mon, 20 Apr 2020 11:01:29 -0400 IronPort-SDR: 76eank+CLq3di1HflN3KvpHKZYvYCxTg4zEeKcCjWbRVDREmbdghFgymGpZKgP2GvI3w8ZXN9e N2FWydLjz1Dw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2020 08:01:28 -0700 IronPort-SDR: nIj6jujxwQbHA6S73J7l/SKuTg21+ioDzcvtCM5i6/giANOJfbplrV7FxPqr6oeUkfigGml6Lq qlzs47tvpLBw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,406,1580803200"; d="scan'208";a="455725120" Received: from chenyu-office.sh.intel.com ([10.239.158.173]) by fmsmga005.fm.intel.com with ESMTP; 20 Apr 2020 08:01:25 -0700 From: Chen Yu To: Peter Zijlstra , Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman Cc: linux-kernel@vger.kernel.org, Chen Yu Subject: [PATCH 2/2][v2] sched: Extract the task putting code from pick_next_task() Date: Mon, 20 Apr 2020 23:01:55 +0800 Message-Id: <4f301770996c02f44d52a4868f510025d5a3a558.1587393807.git.yu.c.chen@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 + * 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); for_each_class(class) { p = class->pick_next_task(rq); -- 2.17.1