Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp225642ybz; Tue, 21 Apr 2020 07:56:42 -0700 (PDT) X-Google-Smtp-Source: APiQypJyqiZUguxUuCU7VU5o5BG+CDBOvT57g5sHFs+7a29tqmruSsTJXeBv5ukx++P4bAFt8T/G X-Received: by 2002:a17:906:f106:: with SMTP id gv6mr22269140ejb.271.1587481002679; Tue, 21 Apr 2020 07:56:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587481002; cv=none; d=google.com; s=arc-20160816; b=drtglVi5rSRKQXecU4CKAZqWAIbKHBrGhi1V2tifMlEh4dI/5c0mTKNCCXcL1SmkWy G8lA0doZ4oZlYIHtFtUXXVoIWcihgEhA85WsShFl2gASGl+HbIT9Hh8ivqTZ5dsLofwa VimFgzg3Z09szhpPFvQqoIzPBRyXFXWPAPgHta8+sRHrAOmMOjwnnMIMTZfakjrlFReL TpNsWqf3YQNG59wvNxiPbGrvNBJeyZ+taCHdzGN8Lk6VpGOVFTzW0qHuLURx6dyUxQcU W59UKg/DlbmALFrIsCgKzbWiNP9EAGjNRdi/zup+fJVeiN291esQERZzRJlcgM7lklRE G6dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=FCrTDQsKQHDWbYxlfVnieiay8DadhrLSbXTjO6Z/IzU=; b=aCyvKE8tmo6sG5IkXwiICuITnPcS06+FLNFKzzXlBf4Pv1uqbrZx7xHFZXIF7JCpGC GoiP/lAHG6gLFVs5TpcvyIIyEcbUa2n6nZ24nIZgS590E3PBFTGgifi5GCB0euL2CjC9 bvGlmjrNDfsqH6UXQPU1q6M2ma8ynLLSxjr/Rp6XP/oHSXKXketRWoS32sWCzPIzGQWJ 3Z0iU/kqDuMCMFAl94ExR3WgKuH+L0+8NCYFsq8dApGniYJ8deJRCQmLhrcASW2fveZ/ ocwiWjX+VQjCDvvCoewem5h/taecYAemwOiEauTkYtoozqWpVRiP5GKHTJmrL68AIo8f 5FyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QUcOLew+; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c3si1842376edx.91.2020.04.21.07.56.19; Tue, 21 Apr 2020 07:56:42 -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; dkim=pass header.i=@linaro.org header.s=google header.b=QUcOLew+; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728881AbgDUOxT (ORCPT + 99 others); Tue, 21 Apr 2020 10:53:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726018AbgDUOxT (ORCPT ); Tue, 21 Apr 2020 10:53:19 -0400 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93369C061A10 for ; Tue, 21 Apr 2020 07:53:18 -0700 (PDT) Received: by mail-lf1-x142.google.com with SMTP id r17so11344789lff.2 for ; Tue, 21 Apr 2020 07:53:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FCrTDQsKQHDWbYxlfVnieiay8DadhrLSbXTjO6Z/IzU=; b=QUcOLew+D8JbCYH59ZZNCyUoBqKA5tyrK5sV6IQIrhib6qFkqEfqXaVg5InUXegzx5 taTirHWKsZZ5pJ1/bHXue1gy3etsKRWBFdpo/XAt+211fE5wUDXG7CPT19+GIKpKx9Kw Z8k7liseB1wB4PxL7Nay/UuQUjkbpbuivU03okNZMQrVSOuTott0Z42nztBN1HP7ctcm kxhx2BuTmZBaGDwzSn11K3AciQnBLRh/A9dsLjBTUMJwDjPmEQTMKOgvv8jjDbkN4Cgi dp9OchDAJzGsN0RXZ31h+5TjTi958ar+wxbM9TZ5SvvtZP9CA3SmthxCEwaTGvjSkxTQ c5hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FCrTDQsKQHDWbYxlfVnieiay8DadhrLSbXTjO6Z/IzU=; b=G7bmGkZqFa+e33v/9Vk1cpBEHn/cFhvuZYaMJ4Eka4236u7TYIT0IcErYbLPkpjdWL tHHd/vYUeLEwcM9sC7MFuu0na/Vhzu8GbEo+sJ0oZoFImWFIxf+TUOcgaOxL1XMnAwzl pCjtiumWgb27JR4t2gw4Wtvy1SLGlGwtfHCTuYCnB1hZsT3mzbzUrlt5kLtBGtt5i23L ZomsSj9i09O3RDwHU2hCPmgsmAH1GAUcSeS7DY1aTbhKYZg8z6tqqjfRIF38Fe58X3pk KvdSHZOQQKa+y5Z9UGExJQ6KiNkhijci/6SEHHB8dLKXE0jOknTFCicWgXKqViIoIs3t 79Mw== X-Gm-Message-State: AGi0PuYcPVXxB+ny3aww3lJV0VDq0oVJY5Fl2qu3GucPm986lVmJN36s d2xDELG8FgQ2N0mMIoCDNdRnf+Kv1gstKUpkgLi8PiK7 X-Received: by 2002:ac2:5e65:: with SMTP id a5mr13917273lfr.189.1587480796967; Tue, 21 Apr 2020 07:53:16 -0700 (PDT) MIME-Version: 1.0 References: <5a99860cf66293db58a397d6248bcb2eee326776.1587464698.git.yu.c.chen@intel.com> In-Reply-To: <5a99860cf66293db58a397d6248bcb2eee326776.1587464698.git.yu.c.chen@intel.com> From: Vincent Guittot Date: Tue, 21 Apr 2020 16:53:05 +0200 Message-ID: Subject: Re: [PATCH 2/2][v3] sched: Extract the task putting code from pick_next_task() To: Chen Yu Cc: linux-kernel , Peter Zijlstra , Steven Rostedt , Valentin Schneider , Ingo Molnar , Juri Lelli , Dietmar Eggemann , Mel Gorman , Ben Segall Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 21 Apr 2020 at 12:50, Chen Yu wrote: > > 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 > Reviewed-by: Valentin Schneider > Signed-off-by: Chen Yu Reviewed-by: Vincent Guittot > --- > v3: According to Steven's suggestion, fix the comment > to change put_next_task() to put_prev_task() > > Rename finish_prev_task() to put_prev_task_balance() > as this reflects what we do before picking a new task. > > Per Valentin's suggestion, put the declaration of > struct sched_class within the ifdef, given it isn't > used outside of it. > --- > 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..c9d7880f6bf2 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 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: > */ > @@ -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); > + put_prev_task_balance(rq, prev, rf); > > for_each_class(class) { > p = class->pick_next_task(rq); > -- > 2.17.1 >