Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp392864ybt; Wed, 17 Jun 2020 03:52:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbsRsjlTrOtKnthgcyRakA/wDhMEGQkwvmzIkxzPmkKBvv2ccv0vp7GTq6Bg4aAO1LQeED X-Received: by 2002:a17:906:c452:: with SMTP id ck18mr7363752ejb.116.1592391176287; Wed, 17 Jun 2020 03:52:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592391176; cv=none; d=google.com; s=arc-20160816; b=De9o0ky4u3ebJXWjz1tUuoQtQjRAbN0evqV7Cr5Y4QDDNxGlq6LQXsgre87RCBd6+b Dt1Dm7IqjPjgW1Ajkz5bD8CXeQVgrq0Y8yRNRHnGwt2yb/3NgeIwxUm2yayUNO5g5WUt 2AppcxAmut/RermS6yPffatzptB+tMq3m23FtW6zBd/LnG421ORYQBTdZtM1wtXjJUSi CjKojWSFnidwRdcpJFauyhInAB5ZXxE1sXqIS0X5C2Bu84Up9pPnQ7N0tMZu+Ou2GkHs 9ZQTbmQZknAqm+Z7qMDrR48hcIGKFtIJ2ctu1pDS8ahQQSysA6CCUu2c7/FHGVxPr8Bs ptJA== 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=LleeTFhrKMa8FZ4VkAtWbPPRYnCv2Km4j3RPkPdWTgM=; b=tg6/XknZjJrc4q/cTWCosC0n4hzT+4OxgoqUEhgSrmRvZJMrUlv9FXbo9zKNuZ3ZJH drzsrmWrYXtxQ7zPsff4wRm+braQBSpAdkRGuqOxEgi1yi7sbmMV8+gRbV2AbjjHNcS1 hOtTsijhglztLLbUY5OGepdskJeVyPkgyskIduQ+40gK+tlvD7hcaWlL1A/1puuXrLN6 xk8htNqpIv43Xi6+k97IFtqQGvJSmavf5LlcoEBagwAV9o/HIu2rhaPxuacPrfr2HKCV BdqPdCr/BiFmacyPirsuUkuVLbeD9K8YEssMRJ4byvg39A9Z5sypN/vH4eT5Fug5kwFa YoAA== 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 f11si4880200edn.268.2020.06.17.03.52.34; Wed, 17 Jun 2020 03:52:56 -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 S1726599AbgFQKua (ORCPT + 99 others); Wed, 17 Jun 2020 06:50:30 -0400 Received: from foss.arm.com ([217.140.110.172]:55476 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725894AbgFQKua (ORCPT ); Wed, 17 Jun 2020 06:50:30 -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 B38A331B; Wed, 17 Jun 2020 03:50:29 -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 492583F71F; Wed, 17 Jun 2020 03:50:28 -0700 (PDT) References: <20200616164801.18644-1-peter.puhov@linaro.org> User-agent: mu4e 0.9.17; emacs 26.3 From: Valentin Schneider To: peter.puhov@linaro.org Cc: linux-kernel@vger.kernel.org, robert.foley@linaro.org, Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman Subject: Re: [PATCH] sched/fair: update_pick_idlest() Select group with lowest group_util when idle_cpus are equal In-reply-to: <20200616164801.18644-1-peter.puhov@linaro.org> Date: Wed, 17 Jun 2020 11:50:22 +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 16/06/20 17:48, peter.puhov@linaro.org wrote: > From: Peter Puhov > We tested this patch with following benchmarks: > perf bench -f simple sched pipe -l 4000000 > perf bench -f simple sched messaging -l 30000 > perf bench -f simple mem memset -s 3GB -l 15 -f default > perf bench -f simple futex wake -s -t 640 -w 1 > sysbench cpu --threads=8 --cpu-max-prime=10000 run > sysbench memory --memory-access-mode=rnd --threads=8 run > sysbench threads --threads=8 run > sysbench mutex --mutex-num=1 --threads=8 run > hackbench --loops 20000 > hackbench --pipe --threads --loops 20000 > hackbench --pipe --threads --loops 20000 --datasize 4096 > > and found some performance improvements in: > sysbench threads > sysbench mutex > perf bench futex wake > and no regressions in others. > One nitpick for the results of those: condensing them in a table form would make them more reader-friendly. Perhaps something like: | Benchmark | Metric | Lower is better? | BASELINE | SERIES | DELTA | |------------------+----------+------------------+----------+--------+-------| | Sysbench threads | # events | No | 45526 | 56567 | +24% | | Sysbench mutex | ... | | | | | If you want to include more stats for each benchmark, you could have one table per (e.g. see [1]) - it'd still be a more readable form (or so I believe). [1]: https://lore.kernel.org/lkml/20200206191957.12325-1-valentin.schneider@arm.com/ > --- > kernel/sched/fair.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 02f323b85b6d..abcbdf80ee75 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -8662,8 +8662,14 @@ static bool update_pick_idlest(struct sched_group *idlest, > > case group_has_spare: > /* Select group with most idle CPUs */ > - if (idlest_sgs->idle_cpus >= sgs->idle_cpus) > + if (idlest_sgs->idle_cpus > sgs->idle_cpus) > return false; > + > + /* Select group with lowest group_util */ > + if (idlest_sgs->idle_cpus == sgs->idle_cpus && > + idlest_sgs->group_util <= sgs->group_util) > + return false; > + > break; > } update_sd_pick_busiest() uses the group's nr_running instead. You mention in the changelog that using nr_running is a possible alternative, did you try benchmarking that and seeing how it compares to using group_util? I think it would be nice to keep pick_busiest() and pick_idlest() aligned wherever possible/sensible. Also, there can be cases where one group has a few "big" tasks and another has a handful more "small" tasks. Say something like sgs_a->group_util = U sgs_a->sum_nr_running = N sgs_b->group_util = U*4/3 sgs_b->sum_nr_running = N*2/3 (sgs_b has more util per task, i.e. bigger tasks on average) Given that we're in the 'group_has_spare' case, I would think picking the group with the lesser amount of running tasks would make sense. Though I guess you can find pathological cases where the util per task difference is huge and we should look at util first...