From patchwork Wed Mar 28 07:46:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 10312509 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EDE3C60353 for ; Wed, 28 Mar 2018 07:47:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFFAA29F4E for ; Wed, 28 Mar 2018 07:47:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D494A29F61; Wed, 28 Mar 2018 07:47:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 52E6929F4E for ; Wed, 28 Mar 2018 07:47:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=+gQdRoWubrFfWCN0xitQkLjR/pJPgVXQdNiR2BI7iSs=; b=lEQ slpr9vAx0Mr/2t1KOk+sNtrpog2SHs5jtXE/79npLS3AruLM6+8TElkT//t1C0MRDGmiSB4FZLnFz WMfikSYJEKnvqGblDRJMMNfqO553cUwxJY0sXhfj2JpAI1xlrMlYg3pjyc/62ulsFLrNNJXevMCt7 QXPgeURU0aN2ZvpH/XcrQZDPaSIYbhUfz+ZjuBv0lgd9u0jdtkHSRk5em6axfelFrIx/0ix7WPz6t N/3910wzdWo1fLkloSxSivELZChpVRAtebvNUOhN3fGb2H12fgTAC8X3I/O4QjdykBWY5XuI0NiBJ rkxT82jzwdYQpVhtmbAsH6jlllNziMg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f15nj-0001PQ-76; Wed, 28 Mar 2018 07:47:19 +0000 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f15nf-0001Nq-TT for linux-arm-kernel@lists.infradead.org; Wed, 28 Mar 2018 07:47:17 +0000 Received: by mail-wr0-x242.google.com with SMTP id p53so1258748wrc.10 for ; Wed, 28 Mar 2018 00:47:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=N/NZAt9E9VbSBuQZaA+/cOvS1+1WjnfwpcgpGkW4YBs=; b=AjD3uqTW6J18t6zAOW0aEBmQxyY7Guuglew7GM4BXoLqfEU1+AruQ0VWrzHppFbFEh mFT3uOSQtVZcYXVeP7pdC+VrbvfWfSQXMkVjwqPoBKMqesxlb0T8AXU+pGUK0en623EN cKcFyJefLLhnJ5JOphcUdy191m/szNBhu1C8w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=N/NZAt9E9VbSBuQZaA+/cOvS1+1WjnfwpcgpGkW4YBs=; b=f3hBU267X7tHGrpokIJ/cL1yILSUl5OYn89c9LobdkKP0bk+mdKhgbOs8A6MTvvR99 lLAxi5LoNEHryq3m3/pNuoFTzTDqGu6CDZ0UWIFu4HceqtkfvSHIqUZIVzYCdX34HXnD qWG9Qw8NDRg3GMWhpaYJmYvjTjCQZNhtave6x/qCAK6al9tUCVl/UDj4cGuPxvTKYoLL teg2Y9YzFdtZxqhB4LPFwWNjUVOLnnd9zhEFcT3qfnyRHuDa8ifD7ixeY2nQV2bkwhnF y7sqa0yDoPasRmGAO8SHggu+rVbjVkNIJA2M9mj1VFYs7BGu9WGzPXvH1lpfsPXrO1l0 0ajQ== X-Gm-Message-State: AElRT7HcLeXLZfLZX1T8bzHkX9b5Y/KExtykN8P7f9F6gpK2qgQ53J6c SFahtypqK20QqjNZJoUekCnDlw== X-Google-Smtp-Source: AIpwx4+1xxUhCHWDmHtbEU6mh096polU2MiutzVy/adtFLiQDgurhJFqS83y1xKyS35TvZp5tb7PIg== X-Received: by 10.223.161.135 with SMTP id u7mr1991417wru.184.1522223223669; Wed, 28 Mar 2018 00:47:03 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:f:6020:a5f7:3db:a520:d281]) by smtp.gmail.com with ESMTPSA id k184sm3229251wmk.45.2018.03.28.00.47.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Mar 2018 00:47:02 -0700 (PDT) From: Vincent Guittot To: catalin.marinas@arm.com, will.deacon@arm.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH] sched: support dynamiQ cluster Date: Wed, 28 Mar 2018 09:46:55 +0200 Message-Id: <1522223215-23524-1-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180328_004715_957892_51B5D187 X-CRM114-Status: GOOD ( 15.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vincent Guittot , peterz@infradead.org, linux-kernel@vger.kernel.org, dietmar.eggemann@arm.com, chris.redpath@arm.com, Morten.Rasmussen@arm.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Arm DynamiQ system can integrate cores with different micro architecture or max OPP under the same DSU so we can have cores with different compute capacity at the LLC (which was not the case with legacy big/LITTLE architecture). Such configuration is similar in some way to ITMT on intel platform which allows some cores to be boosted to higher turbo frequency than others and which uses SD_ASYM_PACKING feature to ensures that CPUs with highest capacity, will always be used in priortiy in order to provide maximum throughput. Add arch_asym_cpu_priority() for arm64 as this function is used to differentiate CPUs in the scheduler. The CPU's capacity is used to order CPUs in the same DSU. Create sched domain topolgy level for arm64 so we can set SD_ASYM_PACKING at MC level. Some tests have been done on a hikey960 platform (quad cortex-A53, quad cortex-A73). For the test purpose, the CPUs topology of the hikey960 has been modified so the 8 heterogeneous cores are described as being part of the same cluster and sharing resources (MC level) like with a DynamiQ DSU. Results below show the time in seconds to run sysbench --test=cpu with an increasing number of threads. The sysbench test run 32 times without patch with patch diff 1 threads 11.04(+/- 30%) 8.86(+/- 0%) -19% 2 threads 5.59(+/- 14%) 4.43(+/- 0%) -20% 3 threads 3.80(+/- 13%) 2.95(+/- 0%) -22% 4 threads 3.10(+/- 12%) 2.22(+/- 0%) -28% 5 threads 2.47(+/- 5%) 1.95(+/- 0%) -21% 6 threads 2.09(+/- 0%) 1.73(+/- 0%) -17% 7 threads 1.64(+/- 0%) 1.56(+/- 0%) - 7% 8 threads 1.42(+/- 0%) 1.42(+/- 0%) 0% Results show a better and stable results across iteration with the patch compared to mainline because we are always using big cores in priority whereas with mainline, the scheduler randomly choose a big or a little cores when there are more cores than number of threads. With 1 thread, the test duration varies in the range [8.85 .. 15.86] for mainline whereas it stays in the range [8.85..8.87] with the patch Signed-off-by: Vincent Guittot --- The SD_ASYM_PACKING flag is disabled by default and I'm preparing another patch to enable this dynamically at boot time by detecting the system topology. arch/arm64/kernel/topology.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c index 2186853..cb6705e5 100644 --- a/arch/arm64/kernel/topology.c +++ b/arch/arm64/kernel/topology.c @@ -296,6 +296,33 @@ static void __init reset_cpu_topology(void) } } +#ifdef CONFIG_SCHED_MC +unsigned int __read_mostly arm64_sched_asym_enabled; + +int arch_asym_cpu_priority(int cpu) +{ + return topology_get_cpu_scale(NULL, cpu); +} + +static inline int arm64_sched_dynamiq(void) +{ + return arm64_sched_asym_enabled ? SD_ASYM_PACKING : 0; +} + +static int arm64_core_flags(void) +{ + return cpu_core_flags() | arm64_sched_dynamiq(); +} +#endif + +static struct sched_domain_topology_level arm64_topology[] = { +#ifdef CONFIG_SCHED_MC + { cpu_coregroup_mask, arm64_core_flags, SD_INIT_NAME(MC) }, +#endif + { cpu_cpu_mask, SD_INIT_NAME(DIE) }, + { NULL, }, +}; + void __init init_cpu_topology(void) { reset_cpu_topology(); @@ -306,4 +333,7 @@ void __init init_cpu_topology(void) */ if (of_have_populated_dt() && parse_dt_topology()) reset_cpu_topology(); + + /* Set scheduler topology descriptor */ + set_sched_topology(arm64_topology); }