From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751980AbdIRHxp (ORCPT ); Mon, 18 Sep 2017 03:53:45 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:38296 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750882AbdIRHxn (ORCPT ); Mon, 18 Sep 2017 03:53:43 -0400 X-Google-Smtp-Source: AOwi7QDwTn8POxptlyVBE5LokaYbwJQZtRaJetF9CHGpEvvOqrqsFO+joXr76eWliNdEsmQ8GygW8Q== From: Uladzislau Rezki X-Google-Original-From: Uladzislau Rezki Date: Mon, 18 Sep 2017 09:53:33 +0200 To: Peter Zijlstra Cc: "Uladzislau Rezki (Sony)" , LKML , Ingo Molnar , Mike Galbraith , Oleksiy Avramchenko , Paul Turner , Oleg Nesterov , Steven Rostedt , Mike Galbraith , Kirill Tkhai , Tim Chen , Nicolas Pitre Subject: Re: [RFC v1] sched/fair: search a task from the tail of the queue Message-ID: <20170918075331.titxxkm3kuzqx3oy@pc636> References: <20170824221131.3949-1-urezki@gmail.com> <20170828084155.3mopma55cdikqqcc@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170828084155.3mopma55cdikqqcc@hirez.programming.kicks-ass.net> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 28, 2017 at 10:41:55AM +0200, Peter Zijlstra wrote: > On Fri, Aug 25, 2017 at 12:11:31AM +0200, Uladzislau Rezki (Sony) wrote: > > From: Uladzislau Rezki > > > > As a first step this patch makes cfs_tasks list as MRU one. > > It means, that when a next task is picked to run on physical > > CPU it is moved to the front of the list. > > > > Thefore, the cfs_tasks list is more or less sorted (except woken > > tasks) starting from recently given CPU time tasks toward tasks > > with max wait time in a run-queue, i.e. MRU list. > > > > Second, as part of the load balance operation, this approach > > starts detach_tasks()/detach_one_task() from the tail of the > > queue instead of the head, giving some advantages: > > > > - tends to pick a task with highest wait time; > > - tasks located in the tail are less likely cache-hot, > > therefore the can_migrate_task() decision is higher. > > > > hackbench illustrates slightly better performance. For example > > doing 1000 samples and 40 groups on i5-3320M CPU, it shows below > > figures: > > > > default: 0.644 avg > > patched: 0.637 avg > > > > Signed-off-by: Uladzislau Rezki (Sony) > > --- > > kernel/sched/fair.c | 19 ++++++++++++++----- > > 1 file changed, 14 insertions(+), 5 deletions(-) > > > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > > index c77e4b1d51c0..cda281c6bb29 100644 > > --- a/kernel/sched/fair.c > > +++ b/kernel/sched/fair.c > > @@ -6357,7 +6357,7 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev, struct rq_flags *rf > > if (hrtick_enabled(rq)) > > hrtick_start_fair(rq, p); > > > > - return p; > > + goto done; > > simple: > > cfs_rq = &rq->cfs; > > #endif > > @@ -6378,6 +6378,14 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev, struct rq_flags *rf > > if (hrtick_enabled(rq)) > > hrtick_start_fair(rq, p); > > > > +done: __maybe_unused > > + /* > > + * Move the next running task to the front of > > + * the list, so our cfs_tasks list becomes MRU > > + * one. > > + */ > > + list_move(&se->group_node, &rq->cfs_tasks); > > + > > return p; > > > > idle: > > Could you also run something like: > > $ taskset 1 perf bench sched pipe > > to make sure the added list_move() doesn't hurt, I'm not sure group_node > and cfs_tasks are in cachelines we already touch for that operation. > > And if you can see that list_move() hurt in "perf annotate", try moving > those members around to lines that we already need anyway. @Peter: just in case if you missed my email. I uploaded one more patch provided where i provided latest result as well. Please have a look at following links: https://lkml.org/lkml/2017/9/13/167 https://lkml.org/lkml/2017/9/13/168 Best Regards, Uladzislau Rezki