Received: by 10.223.176.46 with SMTP id f43csp4000181wra; Tue, 23 Jan 2018 02:37:22 -0800 (PST) X-Google-Smtp-Source: AH8x225+PSIaL1rRUrcV3RzWh4GIsfCiVc9du1SprIGgWr0C0jPqq4nyYhoRQ03/Cq73TdrcYr9V X-Received: by 2002:a17:902:4383:: with SMTP id j3-v6mr5099940pld.320.1516703842462; Tue, 23 Jan 2018 02:37:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516703842; cv=none; d=google.com; s=arc-20160816; b=jO2/Hb81yqeGUoPbvjCfoJQBZOis9fr4ouQujN5PYQX1LsfEcP5shupCgaltM/0/+B RRcEpYJ3pkfL3QiqXDJFBEQba2AiNuIT/Gu/P7CB67tGL8kzRcPmw2nsJmwlmppEEoVz fGXLWS9zuawgPU9wFUGQ702s25MZGlZIo/5FjMaBzipnPKUiT7knF+w8THVCoVz4sB8K bVwuXRbzhABXDRfKojRHi0wXS29zhmARKqneETQTvP59gm9xAVTpqNEabNjv9jcSrCzL A1ONdbgO/PQOvvjg2LtRL+bT/Pf+OxwqXmigXL82CO8BWnShxcO0Qt5sKEfE9yZY6w0u cHNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=6lIyRZ8oT+aP13HnqvGsXXnRa9MggRErjk784Hq7fRE=; b=hK5ZXniWe4zLLcpMH7k3BXqHx9nG7iUqT6axFG0LCpSomxWhHdj6M3+ai0vJT2glOw QM8pPNeAfZ7kJvdMITt+UsLK2fLIepdEW+vqWImNkWpAs9cMn1jq3dgrA88M5oPY8rlt rilaISAF07XO0iYNmcM/VC40dSgHiFqKI+jaUVxVkX+quHydzggxKIqkBpBiNxhZEcD0 1wUVNispYGPxuNSzhEqovnEERUUj8yu0y4ooRztNX1RjFfvARv3yyjNMKBKqh+lZv2om sMHiERxCFwAsvM3S2k5/0L07MKPvPtN+VM5AJEXKkxHeZ1XGQFxmi1b3rbKjITduJX2Y DXjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DRn2lypq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w13si4521887pgq.199.2018.01.23.02.37.08; Tue, 23 Jan 2018 02:37:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DRn2lypq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751420AbeAWKgm (ORCPT + 99 others); Tue, 23 Jan 2018 05:36:42 -0500 Received: from mail-oi0-f52.google.com ([209.85.218.52]:36534 "EHLO mail-oi0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751154AbeAWKgk (ORCPT ); Tue, 23 Jan 2018 05:36:40 -0500 Received: by mail-oi0-f52.google.com with SMTP id w135so7110oie.3; Tue, 23 Jan 2018 02:36:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=6lIyRZ8oT+aP13HnqvGsXXnRa9MggRErjk784Hq7fRE=; b=DRn2lypqOpJyhkezuZXMZwLdljE+LpvO6gB1d2pfITpCF7zFykYtny2/HtGxTv8fFF wlftpTZUve2/WJ/UhgpZK4VhiVO0L5s5UfvHIiWnmwupVpCkxYtz42EjGasGhUE5e4/v 6dQolvY6JasmFiqJHv2TuMn2bqvNoAddkjs3Gc5tDZygoxRMBMDOCWY3EslyVUuDOMDB 8xTFaGTAarPxhwtyY5T1WTZpZvCklhWJ55kjRxZ6bUn8kGXGgyBvPjqDNbsDIF1AywpA eYDLBON47FSxL/e1lZpZ7kF6WiV2lW2wvR9/ih/d0YURQKT4T0MmCiKkTl8gubrB83d0 X04A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=6lIyRZ8oT+aP13HnqvGsXXnRa9MggRErjk784Hq7fRE=; b=YE0E29uJ+rk3bqyRKN6IPETOl82nNreJNRosWserpCQb85J2BFFJ4aZWrC411+YCJD H4R8nJVjjnZMMrxPQ4BAomQaIXXrUN5eN75HsBvU1nZjTCOyT3dayelVgpoW1n7+02Vi w0SIbBxzU1QT8ckwi8YSvcHWMI2Eyk3HwRbQ6VKudhx2HBQxnsy5wom73bcuqVzcI4xI 8+Ww0qYb626oDQnrUnxEJ4RrUwOIw0jJTLmG6yXkP1f4/uaMW8DrmgU/TmLCw4Mh1gvR BO0CWAqUQdtoUy2FNplfCJ9+BcNXJZEucEZqPDMr5eQVEln/sWQY8vbxyO9bur+8Hu+u tu4A== X-Gm-Message-State: AKwxytdaCTsaYhaVnlVCDk03uSKGqUIcArooIVs8C8nDbQpEf4/pblz6 PqQFR7qZc4LqK7GOAQSs0N/7mLfDuvzssGngizA= X-Received: by 10.202.181.87 with SMTP id e84mr6053224oif.112.1516703799822; Tue, 23 Jan 2018 02:36:39 -0800 (PST) MIME-Version: 1.0 Received: by 10.74.108.81 with HTTP; Tue, 23 Jan 2018 02:36:39 -0800 (PST) In-Reply-To: <1516628254.7500.19.camel@gmx.de> References: <1516622939.24679.5.camel@gmx.de> <1516628254.7500.19.camel@gmx.de> From: Wanpeng Li Date: Tue, 23 Jan 2018 18:36:39 +0800 Message-ID: Subject: Re: unixbench context switch perfomance & cpu topology To: Mike Galbraith Cc: linux-kernel@vger.kernel.org, kvm , Paolo Bonzini , Peter Zijlstra , Radim Krcmar , Frederic Weisbecker , Thomas Gleixner , Ingo Molnar Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2018-01-22 21:37 GMT+08:00 Mike Galbraith : > On Mon, 2018-01-22 at 20:27 +0800, Wanpeng Li wrote: >> 2018-01-22 20:08 GMT+08:00 Mike Galbraith : >> > On Mon, 2018-01-22 at 19:47 +0800, Wanpeng Li wrote: >> >> Hi all, >> >> >> >> We can observe unixbench context switch performance is heavily >> >> influenced by cpu topology which is exposed to the guest. the score is >> >> posted below, bigger is better, both the guest and the host kernel are >> >> 3.15-rc3(we can also reproduce against centos 7.4 693 guest/host), LLC >> >> is exposed to the guest, kvm adaptive halt-polling is default enabled, >> >> then start a guest w/ 8 logical cpus. >> >> >> >> >> >> >> >> unixbench context switch >> >> -smp 8, sockets=8, cores=1, threads=1 382036 >> >> -smp 8, sockets=4, cores=2, threads=1 132480 >> >> -smp 8, sockets=2, cores=4, threads=1 128032 >> >> -smp 8, sockets=2, cores=2, threads=2 131767 >> >> -smp 8, sockets=1, cores=4, threads=2 132742 >> >> -smp 8, sockets=1, cores=4, threads=2 (guest w/ nohz=off idle=poll) 331471 >> >> >> >> I can observe there are a lot of reschedule IPIs sent from one vCPU to >> >> another vCPU, the context switch workload switches between running and >> >> idle frequently which results in HLT instruction in the idle path, I >> >> use idle=poll to avoid vmexit due to HLT and to avoid reschedule IPIs >> >> since idle task checks TIF_NEED_RESCHED flags in a loop, nohz=off can >> >> stop to program lapic timer/other nohz stuffs. Any idea why sockets=8 >> >> can get best performance? >> > >> > Probably because with that topology, there is no shared llc, thus no >> > cross-core scheduling, micro-benchmark waker/wakee are stacked. If >> > your benchmark does nothing but schedule, stacking makes beautiful (but >> > utterly meaningless) numbers. >> >> The waker and wakee are just sporadic on the same logical cpu in the >> guest(-smp 8, sockets=8, cores=1, threads=1) during the testing, in >> addition, binding the waker/wakee to one logical cpu in the guest(-smp >> 8, sockets=1, cores=4, threads=2) also can get the performance as >> better as 8 sockets setup. > > Here, with tip.today and that topology, context1 does stack up on one core. > > PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ P COMMAND > 4218 root 20 0 4048 808 732 R 52.16 0.022 0:12.77 4 context1 > 4219 root 20 0 4048 80 0 S 47.18 0.002 0:11.96 4 context1 > > There's a bit of bouncing, but the two stack right back up. But > whatever, what Peter said, the benchmark should pin itself to do this. Thanks for having a try, Mike. :) Actually the two context1 tasks don't stack up on one logical cpu at the most of time which is observed by kernelshark. Do you have any idea why there is 4.5 times RESCHED IPIs which is mentioned in another reply for this thread? Regards, Wanpeng Li