Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2183318imm; Thu, 19 Jul 2018 14:55:55 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcitNckM+xP/Z5PlT3AR05JxIxoHRB7HKaOci1m54AwaK6ZhHD2BUDWqTbQKfE4GrRTzWh6 X-Received: by 2002:a17:902:b604:: with SMTP id b4-v6mr11676273pls.18.1532037355742; Thu, 19 Jul 2018 14:55:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532037355; cv=none; d=google.com; s=arc-20160816; b=NyBeolewDkp3WKTCCM7mFvgYfvmVQIzaPTUD5UoBeGPDewia8SZXhn0Jgj+NmEOiKz fYw+oArcWf9f+KJgGzwuw1xIs2p2kP+JONplFlXYQTGAvhkmnn9VgpvOeLxQe94yVPbH t4zp/k2cIzClEN6ikYS/QP03OLCQ0hgE7fA8mR8fPnFyieQSdcuWqzK9Fk3ZQRwB2kRB KSeZTJHxIkYcWWpdK/sDaRx/8goyKNTr9GGNa0tDb32N1qfynvptuYdn+sAKCylroo4x uZbWOwX7IafmQKWAE6qfTXMEH2xU0cAkowXoOo+xf1GP4vf0Lz3tE452Eom2aPuRRmBN eZxA== 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=ZWrp7WNPOJss3UivEAb5ZqzbKtdZaixv8ilRmYImSiA=; b=myIFOzLDqjoOUCdbTkxKv72ghShdEdx6lCMVawcBUPoIunUrbkJOe8MIV8Pt9NLLoG azzX7woeTvqd4cUYYDlJfGFHMpYsBvLvts9gZSsOKdAkNgF4XaHHxYJy2ZErsbYFk6Ln nP1Ffy3BKJIAfka870d1osbIeiHn19ZvlM/Dr31g7dpew6iYy+ytkG/HPyyhRCniJTL9 nUjJS6wb2blrHOK4rMOPZc0/8Vjjo3dTXa5VS58Idiy4sWGciDWkzVGFz7Xk0lrUB/E9 q7O9N7Xer5ENtdJIkVN8cDAyhVHsVBTNBQ0uqPHlzCNCnl4xEj8vHC+GGfdRIGzwg3kt ROVg== 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 m14-v6si212756pfh.92.2018.07.19.14.55.40; Thu, 19 Jul 2018 14:55:55 -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 S1730885AbeGSWkI (ORCPT + 99 others); Thu, 19 Jul 2018 18:40:08 -0400 Received: from mx2.suse.de ([195.135.220.15]:52834 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727401AbeGSWkI (ORCPT ); Thu, 19 Jul 2018 18:40:08 -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 4B686ACD0; Thu, 19 Jul 2018 21:55:05 +0000 (UTC) Date: Thu, 19 Jul 2018 14:54:56 -0700 From: Davidlohr Bueso To: Waiman Long Cc: Boris Ostrovsky , Juergen Gross , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, Konrad Rzeszutek Wilk Subject: Re: [PATCH v2] xen/spinlock: Don't use pvqspinlock if only 1 vCPU Message-ID: <20180719215456.5ho3udhfoqlkh75a@linux-r8p5> References: <1532036397-19449-1-git-send-email-longman@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <1532036397-19449-1-git-send-email-longman@redhat.com> 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 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 >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); }