Received: by 10.223.176.46 with SMTP id f43csp3998079wra; Tue, 23 Jan 2018 02:35:00 -0800 (PST) X-Google-Smtp-Source: AH8x225/JN4Or4xTnZjYCvZaqfDUCOmlXtPF6/TsvoZDgskWo0Ktx9KP36wIslDa2GCKhMW9sn8O X-Received: by 2002:a17:902:4324:: with SMTP id i33-v6mr5137717pld.39.1516703700708; Tue, 23 Jan 2018 02:35:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516703700; cv=none; d=google.com; s=arc-20160816; b=gJo73EDaqzBATz5fWNTe2z2dp5eqwmAugVZecW6T/nfnmBHyukdEjamxKUGrA1sFx6 vreMuSqMgZDk2v66bGJxIsE5paoZ/ktQOhDuuSq72uhLoF+SNMgP82UB4Lf04F/06IL+ 52pjFuRuNyos+FpEp8oB22H7vDhGFrLI+Q+SDWHamF6+jRmKRdpXwXt283eWXA0TXEzN B0047Y1Ie5a5GT1vTBaiYd6gX6usocpn4wxJawLlj+GPdOk4YSKrbVB56+Jmiiyr5vz7 QTvcJld9dXGbEKppV67dZUBnc+lI7dSTd5XRX5ui6CoAtb7quNRv1q3FHkVipsbdXiu9 033Q== 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=72QnArd7wsNgVIR1kvWMf2lnZTwjO8HahFwpJr+MhGk=; b=cfvb94beO8KbseKWOc1mp/nLvxDGgvr/yQnLB+lFKEm2nuYJYC7BdwOpHzIKGRAVjk z1lQSX79zidYR+0ApLOWMNMGZqkR83Q6+Q1DEo/y8zkjDXjCvzK+nzQNyQIt7Cni7fTS O6DHetNfMHSuNDcn/k03AAvvw5HECKjNTwuZ2iBPdHFZ8dbbLBhUjlxIil+5wRTHqsta vSLS3HAf6GQ2Fdiug3PnNN7ArfoxdmRDE6iBXrm8mc74bL2qKLNc6o5/kOHVQ4S0VC1R TD12fvN1pyTMRx0Dj73+Ok1QjW+/GT9Bl7vEZo/jMaGIf12aTZaEDiRarx+5fIWwPcjm hjEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iN3ExgFP; 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 n3si15006243pgf.60.2018.01.23.02.34.46; Tue, 23 Jan 2018 02:35:00 -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=iN3ExgFP; 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 S1751427AbeAWKdd (ORCPT + 99 others); Tue, 23 Jan 2018 05:33:33 -0500 Received: from mail-ot0-f175.google.com ([74.125.82.175]:43420 "EHLO mail-ot0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751255AbeAWKdc (ORCPT ); Tue, 23 Jan 2018 05:33:32 -0500 Received: by mail-ot0-f175.google.com with SMTP id p36so10237979otd.10; Tue, 23 Jan 2018 02:33:32 -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=72QnArd7wsNgVIR1kvWMf2lnZTwjO8HahFwpJr+MhGk=; b=iN3ExgFPZFo3Tccvm75B20oDT2kttqNo/94SPnb3+GKWZOhIu50C5wyngJ/t5dHtzW YGnfWM6BmEXNnRCk8A6UYfwGt0hCN1sG4AZnt0zSt+o89hPSDuGn6u3LR848V6ovY9L/ OfDp49iCmOlAGiBvTwE/U8I6/IfZz2eYUYrRMet656lH9zsONvU5UqGSNuAO83o2zsly KSdbSHZZVMad6ovd9eTchv7YuIAC7Y0F75E7zhcSlWhrGIXoUkSgwlcBfVzRPRZp6IVl hjLMTZ8a/SCcMJamt0o4xq7lN9A1vz4G9ICBtoySvfhGbM4/EG1Pla8LYFhh6/KUUr2s Mj8A== 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=72QnArd7wsNgVIR1kvWMf2lnZTwjO8HahFwpJr+MhGk=; b=qjkcUcRtZJDWvI0J1GxCvrpubC9mchx2+FmzY0UinfWAh/BHhPWA1a0vGBd3/PHMem Iep8vRsQJjhrABEtlq8+uwf/+CA+iLdbVoBOZmAiEQsYLMGNeyT/5IEz1dYtvenpu82Q neknZGMaks2pyKdjCHK9gMplcMDUQ31SaqMmT7XArHNgUeRAcn0jQ99oUv/IU82n6WfI VUilfx4DeiIwRgXsbjWgCzXGq+9IDfRj4CB5zT7iXL7pMQXiThmMKDeRIJejGRDrePbI dTZt2Z3im/3jaYOf7MjrjNHExpCerdw1hQqP8+ltm+wnNsL320IVFd90uH6BcirEf6q2 gt0g== X-Gm-Message-State: AKwxytd87HxWj2j+p73qBbK0NAzCACu3dE1TyWkgRch0Sf4i19HGUNlv jj2cZnj/k8qw3Lw/AcGMXmohrSLHKt9+dfhXiWA= X-Received: by 10.157.7.164 with SMTP id 33mr5941157oto.276.1516703611602; Tue, 23 Jan 2018 02:33:31 -0800 (PST) MIME-Version: 1.0 Received: by 10.74.108.81 with HTTP; Tue, 23 Jan 2018 02:33:31 -0800 (PST) In-Reply-To: <20180122125337.GE2228@hirez.programming.kicks-ass.net> References: <20180122125337.GE2228@hirez.programming.kicks-ass.net> From: Wanpeng Li Date: Tue, 23 Jan 2018 18:33:31 +0800 Message-ID: Subject: Re: unixbench context switch perfomance & cpu topology To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, kvm , Paolo Bonzini , 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 20:53 GMT+08:00 Peter Zijlstra : > On Mon, Jan 22, 2018 at 07:47:45PM +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? > > I suspect because we load-balance less agressively across nodes than we > do within a cache domain. It is true. after taking a more closer look by kernelshark, the context1 in the guest will be migrated to another logical cpu after several milliseconds for sockets=1, cores=4, threads=2, however, it can keep on one logical cpu around several seconds for sockets=8, cores=1, threads=1 before migrating to another one. > > Fix you benchmark to pin itself to a single CPU, that's the only > sensible way to obtain this number in any case. Yeah, this setup can get a good performance. Actually the two context1 tasks don't stack up on one logical cpu at the most of time which is observed by kernelshark opposed to Mike's reply. In addition, I can observe the sum of RESCHED IPIs in the guest for sockets=1, cores=4, threads=2 is 4.5 times for sockets=8, cores=1, threads=1. Any idea how this can happen? I suspect the TTWU path selects another idle logical cpu which results in a RESCHED IPI is avoidless. However, there is still no benefit for performance after I clear the SD_BALANCE_WAKE for correlative sched_domains. Regards, Wanpeng Li