Received: by 10.223.176.46 with SMTP id f43csp2868816wra; Mon, 22 Jan 2018 04:54:59 -0800 (PST) X-Google-Smtp-Source: AH8x22524qTRD54Ccatjg2QcKnakfS5YpbVZe9AdIQzMbqXN5YyyBjNsPRH7UMykHXuTM/kYj9Zp X-Received: by 10.99.126.75 with SMTP id o11mr7157718pgn.97.1516625699885; Mon, 22 Jan 2018 04:54:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516625699; cv=none; d=google.com; s=arc-20160816; b=NZ22S3YgRh0EEtWvD1krbOzn8PRTMtlE9WuXZSJeiPnniO0bbom1G4fOZ3JM0HCEpf 3x1oBz7QjdcSLcbvKpWBNUMHMjOImytqiLBTYyExEIE4Uw67cT1dsSwgkcF/f6I9wx0z p4fsDYoN5CTdkpK5VTxhOWZggEVQIahqaYWRaBMmVrlY1LA8EwyEPLxlWiMaoGDXO+Ln QLeyxyftrDAwh6V+R5IisFLrZwXS/ClaT6odg3d46ckO0a8mih+aO9NADP6EiQEW8Fnl Lhccico6puabsJXb4Hvv5Y+eSSVb/tXqCb2MLhZUk1BjgoIvWhuN53EM7qkCOv6q2CYW f5xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=y55Q/aSKx0EY/FUyJAd7E0jBFtgigbTIKm2XA+7M9eg=; b=OrboN6cqTVe5CZLkIwph0GF6B4akFaB0XOdABnbi3yrk0ylvND468xy9GgXYM7j3bm cVJ2coziBbgIEOE0eOauIRch7e4poPPRSdZMjG4jvC/ff+fYbVzEswulxuJAO2Pxb0Zv v7n9QhtGrWz0l4xaoF1ygw0QMF9U5W+C6t5CPSDVeP6YD3tYhwyT5mhZi59LP4XguQbs 2ndk8o/Cfo0Zx6XveAY6iqTWHZ1rVGp92PkfwzLq4o3CSlEL76h6bptnWsmJJwr/ACPE 8jq8q7DCtLZv8qQrpKWYl8iHlhtFuoWirQrKzzuOECRDhfuMj/ADf7yNGJOGPU+gjpoE IvLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=ZH8nLPId; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m25si13661346pgv.483.2018.01.22.04.54.45; Mon, 22 Jan 2018 04:54:59 -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=fail header.i=@infradead.org header.s=merlin.20170209 header.b=ZH8nLPId; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751224AbeAVMxu (ORCPT + 99 others); Mon, 22 Jan 2018 07:53:50 -0500 Received: from merlin.infradead.org ([205.233.59.134]:36020 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751041AbeAVMxt (ORCPT ); Mon, 22 Jan 2018 07:53:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=y55Q/aSKx0EY/FUyJAd7E0jBFtgigbTIKm2XA+7M9eg=; b=ZH8nLPId8IYhGRTrqKqkufosd U3TAEoQJT/ZrTPqC6QMgvEJYXdTQ/KVzWUldoVNFJ9MU7VAl17wn/bkN2ib4UL1BobTQ61bYoz5ly ksI6pEvGgZ7koEae75S2hKAhBWJ9ancE8WXiS+LHgn7QBGJzxrJ5UIleK0YwTn10qEpl3obcom5WB T07i3IKmGfBBq5xTHiL2fEbBsh93FkcH943skH+R/Xg3Bm62G9NGFnYqOm2VAfBP5a2xGnLzCWxx8 Qdz05nnf+gFHsi9hbdiP4InEVhY/lWDHZDPO4FBSFRJwPGHLzeZAQao4vUgSk70O3pUjdHCRSTvuY j6DArmcZQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.89 #1 (Red Hat Linux)) id 1edbbZ-0003hl-09; Mon, 22 Jan 2018 12:53:41 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 2D1FA2029FA04; Mon, 22 Jan 2018 13:53:37 +0100 (CET) Date: Mon, 22 Jan 2018 13:53:37 +0100 From: Peter Zijlstra To: Wanpeng Li Cc: linux-kernel@vger.kernel.org, kvm , Paolo Bonzini , Radim Krcmar , Frederic Weisbecker , Thomas Gleixner , Ingo Molnar Subject: Re: unixbench context switch perfomance & cpu topology Message-ID: <20180122125337.GE2228@hirez.programming.kicks-ass.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Fix you benchmark to pin itself to a single CPU, that's the only sensible way to obtain this number in any case.