Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4622634ybi; Tue, 30 Jul 2019 05:21:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqxFVaRkR0Z0deDmNTwgrR8K2uVY8APN8pfQ9G5fC3xX/P8Lz15jgSv7KQED/TC36MRI2Bmz X-Received: by 2002:a63:61c6:: with SMTP id v189mr101368474pgb.36.1564489294008; Tue, 30 Jul 2019 05:21:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564489293; cv=none; d=google.com; s=arc-20160816; b=zsMb/EgdmvS4nh8MRZOY2kv/69ytxb8RnoUesNV41Vy8/iqvg/LSNdbeRMDqKt/3NG jYB9oCXrBkZqKj8YB3GLf2dN9qa5wcDmMbgQQRMKcY7a8pxkc8RyhajJp6u1hMLXzvfk n0jUOA1WhVtmSGRz025DDGULqo23fXMgTzCdYX3r5qJgoEg0aC2ai53SEtoiEvuLnnyA Y6+pQgZStRrxXYcOXKftDFVNG3dE84Jl9D6R3zAEXm3cofE6LmHX892q0bNYusFC2c3k b2vsX0/fLvweezDWLiht5UhW0q7XxNv/w3rn7R7I1ugcb+DI+H6j4r3hNCwijtkwE59i VDoQ== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=eRpWKW7gLROmOjbwkP88njPjYWqjaFOZOs22bzkiPOs=; b=O4pgaTS2NFhqEjVH3VqJNbA+RS88/JmPSFab973LrbXLxpmYbydzZ0NsVG0PJb2HbF /KARHCleRmw07uiXv1s1OyrJ87cwUIiPoqfqBC8zjjS8lV3YB2JpZyxRFgykaqcUdqwq RkE/5GQf2YAyo5X5AqOiDqgcS3BLhORCN3Xgt2jIo70ye20f4lOYK9LNDKzVIrkOOak0 h6ApRC/pxK9Bc930NzN+uIFEb5bUzUd4DXWkcbT8hdsGQ65utywXtFv6gN2hNvI9jfc8 FWCIxS9uAOpZJdD+Wa6xcxtVoCpzBvkCTaWtJtwkwN8dVpLo1E57yjv34n4RXLSNLM72 TNJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=baF0RKwT; 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 k32si26786385pjb.11.2019.07.30.05.21.19; Tue, 30 Jul 2019 05:21:33 -0700 (PDT) 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=bombadil.20170209 header.b=baF0RKwT; 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 S1729507AbfG3MJo (ORCPT + 99 others); Tue, 30 Jul 2019 08:09:44 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:60076 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726784AbfG3MJo (ORCPT ); Tue, 30 Jul 2019 08:09:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To: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=eRpWKW7gLROmOjbwkP88njPjYWqjaFOZOs22bzkiPOs=; b=baF0RKwT0FNJW3MqdNL4/geCuW qbk6m5ow0a/Mzl/KZm+2LUBCvGd+QFKYCYVjawnLgITwQ28fONgeHjLtRBAa14c53KHP54uc6KHhf AqiwGY8/5QQNvZGYL/5m82pV4Y1BRsMis5Y8IomyiRlf+wd5MoDNEGQcuAr3m2qcWu9Z9GMDxIuFH Slzo+unOJs3ofV5hlodv85oeWjcpiMEsB5cnvU8Zye9UkmcfZHJPHpuVHv2EWmHUAq/lAW9yAyL15 WOSPHW+PULgoW5/WCkhRyc/6Wk2mF4mVDyvVKZbMZX5h+MMhubX5DHQuhlmuAQyE7/ceP/q1T5xEu Jr49+eXw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hsQwn-0002Fj-Ao; Tue, 30 Jul 2019 12:09:41 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 1428D2029FD58; Tue, 30 Jul 2019 14:09:39 +0200 (CEST) Date: Tue, 30 Jul 2019 14:09:39 +0200 From: Peter Zijlstra To: Wanpeng Li Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Thomas Gleixner Subject: Re: [PATCH] KVM: Disable wake-affine vCPU process to mitigate lock holder preemption Message-ID: <20190730120939.GM31381@hirez.programming.kicks-ass.net> References: <1564479235-25074-1-git-send-email-wanpengli@tencent.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1564479235-25074-1-git-send-email-wanpengli@tencent.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 30, 2019 at 05:33:55PM +0800, Wanpeng Li wrote: > From: Wanpeng Li > > Wake-affine is a feature inside scheduler which we attempt to make processes > running closely, it gains benefit mostly from cache-hit. When waker tries > to wakup wakee, it needs to select cpu to run wakee, wake affine heuristic > mays select the cpu which waker is running on currently instead of the prev > cpu which wakee was last time running. > > However, in multiple VMs over-subscribe virtualization scenario, it increases > the probability to incur vCPU stacking which means that the sibling vCPUs from > the same VM will be stacked on one pCPU. I test three 80 vCPUs VMs running on > one 80 pCPUs Skylake server(PLE is supported), the ebizzy score can increase 17% > after disabling wake-affine for vCPU process. > > When qemu/other vCPU inject virtual interrupt to guest through waking up one > sleeping vCPU, it increases the probability to stack vCPUs/qemu by scheduler > wake-affine. vCPU stacking issue can greately inceases the lock synchronization > latency in a virtualized environment. This patch disables wake-affine vCPU > process to mitigtate lock holder preemption. > > Cc: Peter Zijlstra > Cc: Thomas Gleixner > Cc: Paolo Bonzini > Cc: Radim Krčmář > Signed-off-by: Wanpeng Li > --- > include/linux/sched.h | 1 + > kernel/sched/fair.c | 3 +++ > virt/kvm/kvm_main.c | 1 + > 3 files changed, 5 insertions(+) > index 036be95..18eb1fa 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -5428,6 +5428,9 @@ static int wake_wide(struct task_struct *p) > unsigned int slave = p->wakee_flips; > int factor = this_cpu_read(sd_llc_size); > > + if (unlikely(p->flags & PF_NO_WAKE_AFFINE)) > + return 1; > + > if (master < slave) > swap(master, slave); > if (slave < factor || master < slave * factor) I intensely dislike how you misrepresent this patch as a KVM patch. Also the above is very much not the right place, even if this PF_flag were to live.