Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753139AbdLKO4b (ORCPT ); Mon, 11 Dec 2017 09:56:31 -0500 Received: from mail-bl2nam02on0085.outbound.protection.outlook.com ([104.47.38.85]:11163 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753007AbdLKO4X (ORCPT ); Mon, 11 Dec 2017 09:56:23 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@cavium.com; Date: Mon, 11 Dec 2017 17:55:57 +0300 From: Yury Norov To: Christian Borntraeger Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Andrew Morton , Ashish Kalra , Christoffer Dall , Geert Uytterhoeven , Linu Cherian , Sunil Goutham Subject: Re: [PATCH] IPI performance benchmark Message-ID: <20171211145557.mooeknrcdfw53qpz@yury-thinkpad> References: <20171211141600.24401-1-ynorov@caviumnetworks.com> <27744344-f4f3-0952-94e2-d80071a137a7@de.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <27744344-f4f3-0952-94e2-d80071a137a7@de.ibm.com> User-Agent: NeoMutt/20170113 (1.7.2) X-Originating-IP: [50.233.148.156] X-ClientProxiedBy: VI1P189CA0007.EURP189.PROD.OUTLOOK.COM (2603:10a6:802:2a::20) To SN4PR0701MB3837.namprd07.prod.outlook.com (2603:10b6:803:4f::12) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 55386afd-afb0-46fc-80fc-08d540a75712 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(5600026)(4604075)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603307);SRVR:SN4PR0701MB3837; X-Microsoft-Exchange-Diagnostics: 1;SN4PR0701MB3837;3:UrT+/BHYRSbTmaGMXtEXgTp/HnWJus7Nag+AgiWGPBePVAvHjzDm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/K2+B0hzwBFrHLZKqCIKMwdpW3FcN5MNfGlyk2ElXv63e1PFcW2++iVyAU51yCNoFrzBYpzW/FRgNpjSLzSFQJMPcK7bL0Yg65x3YUdCA7PaZrgcDWnFhCP3AoxhWacEkAlO7e7gHjJoVCoF/VmQosYzVPQVwfPkdjgKpPRLWW+jbWrwEHAk2o1wb/5QSaXA/Z6GgkxEzCwIOxflNSrWWOK65rKPo519hbuaSY4uNvdXR/LGORPbwfsYYqthnWtPE9BroZVyk8gse6XpH0cGgEdoYrpra/ICBRiW+7tnkgxyYgfOQ/2vzaLJP/NyRpcD9QUhwE/fH7pKghPpEH4VYBLjyUHxv6TCEYnsCE+Mqpo49fwrm7QyCcCu/FCTRwf76suSYfAUaFdxX+0I/00cxksPaw=;4:T88gmaT++V0jCE3LEuqx7ZKps/kzQN184j27AyoAhHyCsCtQ0eznz5Gm2iH4nHPsKoRu23QS/U52F6Y/lTh7xz5XXFZGtTEtv0Ot5MBNgCasjrGHSgVjrWhIHqF5BkSXSJgHisk2sGoBzuGJCqSwBAquP9p2TCFTUSGHHqdWWOZbFZj9ioy/N2gdM6hLWGZZ9y0iRWUCHTa5JbTFvVcEGdyqTrLYe2oLL018syETQUEPkPJumLIQUQKqpKb7fKQqND7FnOuZU98XK/FaTxz3I4NUaTC2hU0N5hCW4yA1PJcPsMHVeT69lQ8xL7xCTbFD X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(209352067349851); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040450)(2401047)(8121501046)(5005006)(10201501046)(93006095)(3231022)(3002001)(6041248)(20161123560025)(20161123562025)(20161123564025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(6072148)(201708071742011);SRVR:SN4PR0701MB3837;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:SN4PR0701MB3837; X-Forefront-PRVS: 0518EEFB48 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6069001)(7916004)(366004)(346002)(376002)(199004)(189003)(24454002)(478600001)(16526018)(33896004)(54906003)(47776003)(6306002)(4326008)(53546010)(42882006)(59450400001)(9686003)(2950100002)(50466002)(33716001)(58126008)(53936002)(2906002)(6496006)(83506002)(107886003)(76176011)(52116002)(72206003)(6246003)(97736004)(16586007)(6916009)(25786009)(6486002)(966005)(6666003)(229853002)(6116002)(105586002)(3846002)(316002)(5660300001)(23726003)(1076002)(106356001)(575784001)(7736002)(68736007)(76506005)(81166006)(81156014)(66066001)(305945005)(8676002)(8936002)(2004002);DIR:OUT;SFP:1101;SCL:1;SRVR:SN4PR0701MB3837;H:localhost;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN4PR0701MB3837;23:a3xbQUYrduWEVB3zeyX2ACf8G3ec3EfqNgyyHKF?= =?us-ascii?Q?9f3wHNi0ORyhXQNNxGdWTpMXkz+gBhotreL0N5zN4eWhp+ucvSppatByeBSp?= =?us-ascii?Q?5PhzMTn8Isg4RL9uGYhvmkfYPP71kaL25fAaYDjDwUeooO6Q6fiDaoHDAIzm?= =?us-ascii?Q?A2lUO74YgZ1J28tPHu1O3oznQRALUKUlDK3PC2qHs/wGA/DgcwJsQOilfk2m?= =?us-ascii?Q?KH3GFQWVodR0dCozFVuz6xtyHzKlXDymE3mLgnDocCnBirj5u1z+umqmscgh?= =?us-ascii?Q?7kZgEMJAQpxJBiu4BGUN9IRnIRSU7r3KcohgaOpUu5OAU7glp8/rj5v92e0I?= =?us-ascii?Q?vgrevCAH6jYkY7FJVKnqW60KAhlSzoVMmDWYTyTWxNvjeE/F2eGpdStOYBrT?= =?us-ascii?Q?ykqVSIdHsJ6c1GwSL+EM/9rVzOqF4KjtsjTOx/m0Z2fDviT7rr7uLNBXT+tF?= =?us-ascii?Q?lMpexZ/zdlYKWWEwv/56u3JazDx9qmZopmaGr1KUQp3Q5xoczc6oDRkMvknp?=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Q/zvlvTTNryf9rJ5SoMmgg9qxji5nujTXrRi1iBoVo+Oc8/I6+35rt+8blnXmmK82rzfX+9SoQ6vahFuZFLVBpqd+FZvw6UAkX45ly73nvCE7r+HtUO51sx28we24I/q06fCHjqJauHcM3eR6IGr/um5SA5PoKM532SAVMV7OQ9uHQAQCTR8mNcjqkmQx25/1l7YJ/Us4qAJ+lD/axgSvdngmnz1SlY53NjRH14G2j9Lz8NLe/6fUPEAXrd7xbBGVV5SUmYXRvAGqPjEv5BAVww3E3MYUCaxMx4Xlgzdu/e1RNwHLxsAmnTpsrpi8vacTCPQVBCaFad+q30pW86+Z0/XS4r468=;5:nLy5w51oz1KqAgVik6QyjFEHzUtzdQUS4I4qAXAURDkS7BcSs0Ny1rWNDhqXj7Oln2cnGypWWocdrhAwn6OC4vHdw0iMrxr/St2iBBJ2kep1hV69RZICf4Z97Hb/pwg28QFK+WWy4wtSfVk/eRDLLTz0ZCgVD1v5eYPXtZ+ZGXQ=;24:bSpOAb2ovJhp/b80yaJkq65Ulb4xi7Dm3+qO/izReqvo2pS03nL0XV0i51Pp4jYN8AK+Sv+K8/kW5MOTpeLbdzcCwgtp3oE5dL+JLAy43wA=;7:wyAeiKtUmZ6U6Ha+y8s/BswWTEZPFDgVzXEereXtXW+oo1i0BhRBWZniqXJXVTlJqS39RRyW3u4tYCSLqVwiTpXc5BCxzTJ1GRdSmCQ7yj+QhqxoomvBYxYQyjbJurLB1mNy1nc4NkdCQ/3lV/IebZjlH061ANZXZ8hSjfc3ajHX2xgF2gcsoGHbVaczEse5GVOZ5XpEHpM84yHOyrBoOHQiXlbOKLFusSkVpkKo3IuXHhw/ks+k4aQluef4ab+C SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2017 14:56:18.8902 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 55386afd-afb0-46fc-80fc-08d540a75712 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR0701MB3837 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6525 Lines: 213 On Mon, Dec 11, 2017 at 03:35:02PM +0100, Christian Borntraeger wrote: > > > On 12/11/2017 03:16 PM, Yury Norov wrote: > > This benchmark sends many IPIs in different modes and measures > > time for IPI delivery (first column), and total time, ie including > > time to acknowledge the receive by sender (second column). > > > > The scenarios are: > > Dry-run: do everything except actually sending IPI. Useful > > to estimate system overhead. > > Self-IPI: Send IPI to self CPU. > > Normal IPI: Send IPI to some other CPU. > > Broadcast IPI: Send broadcast IPI to all online CPUs. > > > > For virtualized guests, sending and reveiving IPIs causes guest exit. > > I used this test to measure performance impact on KVM subsystem of > > Christoffer Dall's series "Optimize KVM/ARM for VHE systems". > > > > https://www.spinics.net/lists/kvm/msg156755.html > > > > Test machine is ThunderX2, 112 online CPUs. Below the results normalized > > to host dry-run time. Smaller - better. > > > > Host, v4.14: > > Dry-run: 0 1 > > Self-IPI: 9 18 > > Normal IPI: 81 110 > > Broadcast IPI: 0 2106 > > > > Guest, v4.14: > > Dry-run: 0 1 > > Self-IPI: 10 18 > > Normal IPI: 305 525 > > Broadcast IPI: 0 9729 > > > > Guest, v4.14 + VHE: > > Dry-run: 0 1 > > Self-IPI: 9 18 > > Normal IPI: 176 343 > > Broadcast IPI: 0 9885 > > > > CC: Andrew Morton > > CC: Ashish Kalra > > CC: Christoffer Dall > > CC: Geert Uytterhoeven > > CC: Linu Cherian > > CC: Sunil Goutham > > Signed-off-by: Yury Norov > > --- > > arch/Kconfig | 10 ++++ > > kernel/Makefile | 1 + > > kernel/ipi_benchmark.c | 134 +++++++++++++++++++++++++++++++++++++++++++++++++ > > 3 files changed, 145 insertions(+) > > create mode 100644 kernel/ipi_benchmark.c > > diff --git a/arch/Kconfig b/arch/Kconfig > > index 057370a0ac4e..80d6ef439199 100644 > > --- a/arch/Kconfig > > +++ b/arch/Kconfig > > @@ -82,6 +82,16 @@ config JUMP_LABEL > > ( On 32-bit x86, the necessary options added to the compiler > > flags may increase the size of the kernel slightly. ) > > > > +config IPI_BENCHMARK > > + tristate "Test IPI performance on SMP systems" > > + depends on SMP > > + help > > + Test IPI performance on SMP systems. If system has only one online > > + CPU, sending IPI to other CPU is obviously not possible, and ENOENT > > + is returned for corresponding test. > > + > > + If unsure, say N. > > + > > config STATIC_KEYS_SELFTEST > > bool "Static key selftest" > > depends on JUMP_LABEL > > diff --git a/kernel/Makefile b/kernel/Makefile > > index 172d151d429c..04e550e1990c 100644 > > --- a/kernel/Makefile > > +++ b/kernel/Makefile > > @@ -101,6 +101,7 @@ obj-$(CONFIG_TRACEPOINTS) += trace/ > > obj-$(CONFIG_IRQ_WORK) += irq_work.o > > obj-$(CONFIG_CPU_PM) += cpu_pm.o > > obj-$(CONFIG_BPF) += bpf/ > > +obj-$(CONFIG_IPI_BENCHMARK) += ipi_benchmark.o > > > > obj-$(CONFIG_PERF_EVENTS) += events/ > > > > diff --git a/kernel/ipi_benchmark.c b/kernel/ipi_benchmark.c > > new file mode 100644 > > index 000000000000..35f1f7598c36 > > --- /dev/null > > +++ b/kernel/ipi_benchmark.c > > @@ -0,0 +1,134 @@ > > +/* > > + * Performance test for IPI on SMP machines. > > + * > > + * Copyright (c) 2017 Cavium Networks. > > + * > > + * This program is free software; you can redistribute it and/or > > + * modify it under the terms of version 2 of the GNU General Public > > + * License as published by the Free Software Foundation. > > + * > > + * This program is distributed in the hope that it will be useful, but > > + * WITHOUT ANY WARRANTY; without even the implied warranty of > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > > + * General Public License for more details. > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > + > > +#define NTIMES 100000 > > + > > +#define POKE_ANY 0 > > +#define DRY_RUN 1 > > +#define POKE_SELF 2 > > +#define POKE_ALL 3 > > + > > +static void __init handle_ipi(void *t) > > +{ > > + ktime_t *time = (ktime_t *) t; > > + > > + if (time) > > + *time = ktime_get() - *time; > > +} > > + > > +static ktime_t __init send_ipi(int flags) > > +{ > > + ktime_t time; > > + unsigned int cpu = get_cpu(); > > + > > + switch (flags) { > > + case POKE_ALL: > > + /* If broadcasting, don't force all CPUs to update time. */ > > + smp_call_function_many(cpu_online_mask, handle_ipi, NULL, 1); > > + /* Fall thru */ > > + case DRY_RUN: > > + /* Do everything except actually sending IPI. */ > > + time = 0; > > + break; > > + case POKE_ANY: > > + cpu = cpumask_any_but(cpu_online_mask, cpu); > > + if (cpu >= nr_cpu_ids) { > > + time = -ENOENT; > > + break; > > + } > > + /* Fall thru */ > > + case POKE_SELF: > > + time = ktime_get(); > > + smp_call_function_single(cpu, handle_ipi, &time, 1); > > + break; > > + default: > > + time = -EINVAL; > > + } > > + > > + put_cpu(); > > + return time; > > +} > > + > > +static int __init __bench_ipi(unsigned long i, ktime_t *time, int flags) > > +{ > > + ktime_t t; > > + > > + *time = 0; > > + while (i--) { > > + t = send_ipi(flags); > > + if ((int) t < 0) > > + return (int) t; > > + > > + *time += t; > > + } > > + > > + return 0; > > +} > > + > > +static int __init bench_ipi(unsigned long times, int flags, > > + ktime_t *ipi, ktime_t *total) > > +{ > > + int ret; > > + > > + *total = ktime_get(); > > + ret = __bench_ipi(times, ipi, flags); > > + if (unlikely(ret)) > > + return ret; > > + > > + *total = ktime_get() - *total; > > + > > + return 0; > > +} > > + > > +static int __init init_bench_ipi(void) > > +{ > > + ktime_t ipi, total; > > + int ret; > > + > > + ret = bench_ipi(NTIMES, DRY_RUN, &ipi, &total); > > + if (ret) > > + pr_err("Dry-run FAILED: %d\n", ret); > > + else > > + pr_err("Dry-run: %18llu, %18llu ns\n", ipi, total); > > you do not use NTIMES here to calculate the average value. Is that intended? I think, it's more visually to represent all results in number of dry-run times, like I did in patch description. So on kernel side I expose raw data and calculate final values after finishing tests. If you think that average values are preferable, I can do that in v2. Yury