Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5400648imm; Sun, 22 Jul 2018 21:44:15 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfYCS3pJQDmR9k/PT9vOGgBqfE458B/uywebRnj86JI/VC0QQeKLpQqa3B3mol2E5jIo6Ah X-Received: by 2002:a63:e0b:: with SMTP id d11-v6mr10857924pgl.134.1532321055666; Sun, 22 Jul 2018 21:44:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532321055; cv=none; d=google.com; s=arc-20160816; b=kclj1nxM24XJ0Uy/nYC580iLXtoXQsOaj848DBA7gUJri6VXhjOHSWIQ5SaWywKSu/ UuafwufYenbwXIEON23RW5mT0ZfJ1wn+Nj117R9AuHcui47yUwmAnrCbiEj0meypoKc8 rx/xu+Df+nuOqOCqyL4I/ksQMSPWAqAm8ncPv0otBeMcPUuViGIQXzugYpWG8trFKUh2 qbxt8ZGp0YFVHI+ErjBDmcaTdTH80/uWhvwC5pfNtx9B6LLi39V6F8YtStJTyMhzw4Yz 1dykfszjYq60mXCxPM7ALK1ZKkJndjD5x3TrAxOqT0w9azn3b6mTtW+DpXnWEuPdsRT3 7msw== 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:arc-authentication-results; bh=9R/b4nLI/P/OBS32nrrQRHscumL3PepKeF6yaFXXYb0=; b=wPZnqhpFPctAthGKD+xjeDPvFEdm0uNuwIQ5qepzHTSm2LlKo4THRc+vADshs3bYsS lbF0GL7vDbT2d1HC9APWCw9Y2bOaRiiESAYVYTw4eDBhQP/zuJWVZY7Jd6YxCGwBurR+ YlYV17kBYMm4CkXqw6BnwcAAmaVXvIKByr6EaB3Q4LQPa+PRuoWBvn4J7Vr1QmY3gIVm j2KBFzLBZg4jRqWGXdjwEsUNi5HrsAy7APNziKygOZtAk0aL7aktjlYt9vugFy+rWOeu J6YjYYo9DJeB/X7eRFWqkMvdb5nNtSnktFMrU6rzD5mn/koVS7uBuLmwcdcIShPP+wdB wzaw== ARC-Authentication-Results: i=1; mx.google.com; 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 s10-v6si7091695pgm.501.2018.07.22.21.43.59; Sun, 22 Jul 2018 21:44:15 -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; 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 S1728113AbeGWFmW (ORCPT + 99 others); Mon, 23 Jul 2018 01:42:22 -0400 Received: from mx2.suse.de ([195.135.220.15]:51730 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725976AbeGWFmW (ORCPT ); Mon, 23 Jul 2018 01:42:22 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A527FACF4; Mon, 23 Jul 2018 04:43:03 +0000 (UTC) Date: Sun, 22 Jul 2018 21:42:57 -0700 From: Davidlohr Bueso To: Wanpeng Li Cc: Waiman Long , Paolo Bonzini , Radim Krcmar , Boris Ostrovsky , Juergen Gross , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , the arch/x86 maintainers , xen-devel , LKML , Konrad Rzeszutek Wilk Subject: Re: [PATCH v2] xen/spinlock: Don't use pvqspinlock if only 1 vCPU Message-ID: <20180723044257.m7pjrnp7jjqggqij@linux-r8p5> References: <1532036397-19449-1-git-send-email-longman@redhat.com> <20180719215456.5ho3udhfoqlkh75a@linux-r8p5> <00e98205-606a-a121-36c2-dedaeae1d0bb@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170912 (1.9.0) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 23 Jul 2018, Wanpeng Li wrote: >On Fri, 20 Jul 2018 at 06:03, Waiman Long wrote: >> >> On 07/19/2018 05:54 PM, Davidlohr Bueso wrote: >> > On Thu, 19 Jul 2018, Waiman Long wrote: >> > >> >> On a VM with only 1 vCPU, the locking fast paths will always be >> >> successful. In this case, there is no need to use the the PV qspinlock >> >> code which has higher overhead on the unlock side than the native >> >> qspinlock code. >> >> >> >> The xen_pvspin veriable is also turned off in this 1 vCPU case to s/veriable variable >> >> eliminate unneeded pvqspinlock initialization in xen_init_lock_cpu() >> >> which is run after xen_init_spinlocks(). >> > >> > Wouldn't kvm also want this? >> > >> > diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c >> > index a37bda38d205..95aceb692010 100644 >> > --- a/arch/x86/kernel/kvm.c >> > +++ b/arch/x86/kernel/kvm.c >> > @@ -457,7 +457,8 @@ static void __init sev_map_percpu_data(void) >> > static void __init kvm_smp_prepare_cpus(unsigned int max_cpus) >> > { >> > native_smp_prepare_cpus(max_cpus); >> > - if (kvm_para_has_hint(KVM_HINTS_REALTIME)) >> > + if (num_possible_cpus() == 1 || >> > + kvm_para_has_hint(KVM_HINTS_REALTIME)) >> > static_branch_disable(&virt_spin_lock_key); >> > } >> >> That doesn't really matter as the slowpath will never get executed in >> the 1 vCPU case. How does this differ then from xen, then? I mean, same principle applies. > >So this is not needed in kvm tree? >https://git.kernel.org/pub/scm/virt/kvm/kvm.git/commit/?h=queue&id=3a792199004ec335346cc607d62600a399a7ee02 Hmm I would think that my patch would be more appropiate as it actually does what the comment says. Thanks, Davidlohr