Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752701AbdLMKsM (ORCPT ); Wed, 13 Dec 2017 05:48:12 -0500 Received: from mail-bn3nam01on0071.outbound.protection.outlook.com ([104.47.33.71]:29443 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752103AbdLMKsH (ORCPT ); Wed, 13 Dec 2017 05:48:07 -0500 Date: Wed, 13 Dec 2017 13:47:47 +0300 From: Yury Norov To: Konrad Rzeszutek Wilk 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: <20171213104747.m4b5pbnlcroodfe7@yury-thinkpad> References: <20171211141600.24401-1-ynorov@caviumnetworks.com> <20171211153332.GG15649@char.us.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171211153332.GG15649@char.us.oracle.com> User-Agent: NeoMutt/20170113 (1.7.2) X-Originating-IP: [42.107.79.35] X-ClientProxiedBy: HE1PR06CA0158.eurprd06.prod.outlook.com (2603:10a6:7:16::45) To MWHPR0701MB3836.namprd07.prod.outlook.com (2603:10b6:301:7f::29) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4cd9816e-69a9-41ad-c09b-08d54216fd99 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307);SRVR:MWHPR0701MB3836; X-Microsoft-Exchange-Diagnostics: 1;MWHPR0701MB3836;3:gjwaHuQ4DY8dhtY0atfS/aoEwrTfngK3LsxWRdAYKmSsvfgRHIceBMHV7hwcTN8KcK1w2OyTBwY3FBBqzB++YelTxCOnHzGPjnnjwJRMPkCuBEsj5k1XPjsgY0w3fg8Y7LgoulE/3dvQTKBgkAStfBMDGzry8g1+bi+xKJlPkrgME3f+Nriu2XDiVZtn3BJAKiY6MSRB/tCvSrGgQ8VlSC7SbztFEDoNweqgvLEarb9MAYJQksI5mMmi2F8tz2uA;25:THoL82TDakzFmm86LxNDpEtAS9KBxTCEgJ8v3s2nGCmHV5h/uSmEpbhcA9Qw5R9zL3gcktr9Yd7ntYEPiqg/AtrGxxtw5PjN0nBgJ1Lh16HoRhwBIXs/LXzPP3jxJBsiMRWxawnGAuEuSLcPwzp1rmPgYyOefc5feNW+kpJLqoC0kj569GzxULrlHc0++2wITEwWZptxsOpbJpeRdcLMuJaKG0Yvvxrbnd4FQnEOG0eXxa25Bflt62t7NA0MEQkVOV7Is5yMfL0cqvjCL9D32dKHq3ALxallTMucFXBiiBk5sNI52U2tOwnyX+fKMDPTe1ulJ7dB3j8LEyKBtepMG9DjW6/gINIjlma0V3c7d1M=;31:Oy6DU6zR5kN1CiM49VUQNQ+ME25V6NiJBb4sP6nALg1FTSCobUNbPG3Vatp3ahy7ChJZpzh/X3zRWHF3V7ICO3oJJRUC++Sy3GZAQWG2DSKBIGJbyFOoBNyqB7B6AMAJXIdWVijzIRJHl5d1uYmkvy2cY0tKdDh7UL7L1cyZpG2GX90lzM7GPWgT+8TTRyk9S78riBfzlt2PP0jglg7cH9jLikS46jwkt0iZoV8aQFY= X-MS-TrafficTypeDiagnostic: MWHPR0701MB3836: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@cavium.com; X-Microsoft-Exchange-Diagnostics: 1;MWHPR0701MB3836;20:YdpJsQC5u5Kh1UdmDPlkobdVXIW+ewFOARBVXJMOXSfks9HLMmGImSAJvvmNf8aw7A2Fo4bjZhKS6GAthQArW67OZwZZWkccQtLBEJqGVGuEzeQ2U4wznH4Rxv+W63mrtfbo5R2PIJfmahjNS/bsYrDZGmlZIirXZ9n33cXDdMLk5ym4TfbLaDZOcah8cZdzJjc+GLj617QazxZDu68O140kaEqbRHZ64T253zVk8vj++aK/KfrGtAbafW9EqPUdPq5OUTozFWK9JLYlxE4sglQil4wZYCyHa+67x539xoQH6SkA3seOZvH4cxgQmQXx/HZDvmjw3bxLoDBaflLBCqHlDWQMsjpgOBqh0x0bnz5IGGB3yjvvr+uaTgclDq2NLAY0x0K8GWLkgHH7JIPI8gi2tcNZZpymModr+ZWvhfBduhwK9HU6rS0qSBZWI2/rux85KHS/nPq2JxEZRFwokVtMPjV4s6OlinWphKB5SHUkUUXFDQCPd622KABXz8V3jew52gUF20xbRHT1iCOd5u/1m1j6BHMy6VrloC7UQhh2dXv7/pWgBWubB6By7Jg6yhUMhvs35mK9DdMdQHnUy8YCFtXdeUSUUZEJrTATfXc=;4:x9byOu8GCKm9ZByMPPTEGy6hL9teb6E9zc9SqlGTUVgyXj3Iuox9ncmuSYRfha6pZ++O1696Sx3r56O/edavsX/70TOL8lSDP7xbfD7JNu2KPhwdwRcTs2QLqn/wEHCuYTnfg/ru+XY521hWWt3fWQB5Tp+wg/ShEuIJjJI9BlpcZ2GslxSQROsv8fNBSeKryldkM2WNTcRmdVNJeeqvwZ4GOwFRfVEjV4YQ7Nd27ODayRMKJpvtfmez9R0ChnIKg01jtyuFqGtEo/Sy6D2iSa2q4j70blH2Gqy/BMc+I5KO4A3zcDZmrkEKNAwP8CEd X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(209352067349851); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040450)(2401047)(5005006)(8121501046)(93006095)(3231023)(10201501046)(3002001)(6041248)(20161123562025)(20161123555025)(20161123558100)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(6072148)(201708071742011);SRVR:MWHPR0701MB3836;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:MWHPR0701MB3836; X-Forefront-PRVS: 052017CAF1 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6069001)(7916004)(366004)(346002)(376002)(189003)(199004)(24454002)(107886003)(16526018)(6246003)(106356001)(53936002)(52116002)(105586002)(16586007)(9686003)(316002)(54906003)(76176011)(6496006)(33896004)(2906002)(58126008)(25786009)(76506005)(68736007)(59450400001)(23726003)(386003)(3846002)(478600001)(6306002)(72206003)(1076002)(4326008)(6116002)(6666003)(6486002)(229853002)(66066001)(97736004)(575784001)(5660300001)(81166006)(7736002)(50466002)(42882006)(2950100002)(81156014)(6916009)(83506002)(305945005)(8676002)(33716001)(5009440100003)(47776003)(966005)(8936002)(2004002);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR0701MB3836;H:localhost;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;MWHPR0701MB3836;23:Oronadk6L/xmQaD32/vYsfCB9RoVq0YlFiDOR23?= =?us-ascii?Q?GXtMQuS4WMQF9HSvc3st2wK0klj+zpBN1MvK3x8YfjGovFOc6nrK09ey8k9T?= =?us-ascii?Q?eh+PDxi+GaMZDozAGEQUApKEKOsPsBruca9kkVzSLhTlVyo1QzeRYcSJkFju?= =?us-ascii?Q?5Tj1NWUMxdr8vSpP91PvJUm6IfA7mF666hRD5J2PFP0ZF8w0rgQMBVf8AzVy?= =?us-ascii?Q?DW1NYYekwZRuSGY3tfS2JHPhv20Sx01R4UPau6KWCVDPWajL7Kc3aZuInD/K?= =?us-ascii?Q?yBIrRewWq3E0LSPEA0kyASt0b/tZxemNTKSXwNgjVcwirFKmYnVV9cWFze9K?= =?us-ascii?Q?rp7JwRf7HEiv3P1dMXcHDYv5OBJaujkSW6r2hjRUf0wIjWqnM159QfG3dNs+?= =?us-ascii?Q?14G+8z7p7/YmZpnvmqKbI6YRh40fqV8g2qsEBtxNVIyI8/UnzB9YoQkyNTHl?= =?us-ascii?Q?1EKx8zyc5relR6nOSYVHwP6mgpnm1XsZbuQfY3sGh7fEpaWJTypkzKkYkSWO?= =?us-ascii?Q?blmnZC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PR0701MB3836;6:Exj55uqB1X+kYzZQ5lj/mVoTgA5b1zE8Q1ejeyAdomnqOnOl4+Agi1sZceDvgraTPxD89oghQM4L1mXXcahT2zpdXs6rewWhTplpIla0qFKExtVrhp3t+q/O9YS31/dIcB0nV89Rlmn/FgOFA7vr7h29fMJlBH5NWUUeSZARYv2xrlomfJcIAxaiDIwYQUGo99izEFycNW8hcmIdguN9j8TleRXvo4ao0f3GnvETiStMrTIt8zf11HeiAFszJszTkDFT4A0R+A5h5enkyt5KIIhVYZxmurABvkpxBe0t+HUEAzEsM1h2HNMlZArTigNjd4lKP3CZ6PSROd3ON3NaQg9Qg0L30ksiwp27qV1IPdY=;5:x8DQ9zSv+bCs4n0nCcz6+I8RvcA+XZkOTceJvHQQ1oDEW9LZFdf6YIgEzEblKCtnxNl/dHB4rwNWBewayAmKNabTQg1gTLsfrvlhsiODFY2biaJA/Q8ZyKqDR7/gmq0AYmEgzHaI01247ZbrB7gcdG9C9yfd2ToQGmILr1kBvnM=;24:AemMKMR+2MUQXWTQObEkGsJlIR6iNv/62y31TLHS/GJYd3lz24GjPtJ3YzV6oBzjLnVcHRvujNy9ReIBuKL73oEZLTsvLRAlgTWz92graxk=;7:jfaLkBTCX1czyvE3neRSbeqarzPFQQfk2Ehz8GUNzaKCNwmR1UozpOcjoMAIIEFE8GMuIvkDHB6mkCupS4uJEJJGLJhFJGIBaNB3cqPN90NnV0Ym1mVVFTUaxWi+sUQzrq0mUIWWx4u9R1ECSVa3cH8dKzplBptkdp9E5phGcSEhk2e9RC2uzYdpC2V/JCokkrkZy/pfMU+o5dGTwsgOznDfYySsMZ0ZQsYF/A67WkgaXPOwWNnQ7pQrG+tZkR8o SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2017 10:48:04.2968 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4cd9816e-69a9-41ad-c09b-08d54216fd99 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR0701MB3836 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 8040 Lines: 254 On Mon, Dec 11, 2017 at 10:33:32AM -0500, Konrad Rzeszutek Wilk wrote: > On Mon, Dec 11, 2017 at 05:16:00PM +0300, 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. > > Would it make sense to also add spinlock contention tests? Meaning make > this framework a bit more generic so you could do IPI and you could > also do spinlock contention? > > Like: > http://xenbits.xen.org/gitweb/?p=xentesttools/bootstrap.git;a=blob;f=root_image/drivers/spinlock_hog/spinlock_hog.c;h=040a154808452576b1aa5720a6282981319a5360;hb=HEAD There's kernel/locking/locktorture.c for spinlock testing. Maybe it worth to add new testcase there? If you find my 'framework' more suitable for you, I'm also OK with it. Is my understanding correct that you want something like broadcast IPI case, but with different payload? Yury > And then also this could be used for an CPU intensive > test to see how well virtualization schedulers work: > > http://xenbits.xen.org/gitweb/?p=xentesttools/bootstrap.git;a=blob;f=root_image/drivers/ipi_hog/ipi_hog.c;h=6dcc4f3382c29c42fec077791cc53bc52e6d8868;hb=HEAD > > (asking as it never occurred to me upstream those test-cases > but if folks are OK with Yury little module, then other things > could be done as well with it). > > > > > 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); > > + > > + ret = bench_ipi(NTIMES, POKE_SELF, &ipi, &total); > > + if (ret) > > + pr_err("Self-IPI FAILED: %d\n", ret); > > + else > > + pr_err("Self-IPI: %18llu, %18llu ns\n", ipi, total); > > + > > + ret = bench_ipi(NTIMES, POKE_ANY, &ipi, &total); > > + if (ret) > > + pr_err("Normal IPI FAILED: %d\n", ret); > > + else > > + pr_err("Normal IPI: %18llu, %18llu ns\n", ipi, total); > > + > > + ret = bench_ipi(NTIMES, POKE_ALL, &ipi, &total); > > + if (ret) > > + pr_err("Broadcast IPI FAILED: %d\n", ret); > > + else > > + pr_err("Broadcast IPI: %18llu, %18llu ns\n", ipi, total); > > + > > + /* Return error to avoid annoying rmmod. */ > > + return -EINVAL; > > +} > > +module_init(init_bench_ipi); > > + > > +MODULE_LICENSE("GPL"); > > -- > > 2.11.0 > >