Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1292705lqh; Mon, 6 May 2024 03:20:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVj2D+feYCLp6g1Scn7WwzPIaC9PJ9Xa8o1qxeboHl1NWf5reuxKr0/e4+841tSJHNHs4yRt+X0fHlwAUmKVfuA6lKxFVKbyql0IH08Nw== X-Google-Smtp-Source: AGHT+IENkzj1KnFyq1nazegprD6GOoW2g7B9nu6khG0Lggvbo7WKDweg5IfDZT9ddkf1YHnletam X-Received: by 2002:a05:6359:458f:b0:191:915d:b8fe with SMTP id no15-20020a056359458f00b00191915db8femr3473756rwb.28.1714990820530; Mon, 06 May 2024 03:20:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714990820; cv=pass; d=google.com; s=arc-20160816; b=FsmXZjWtSaoFeELibT8oMrleck+S/U7rzd+uaAdhkv7IRt7VRjuHz9bdvFuudizwOP NiTJTg6anTyg66XTFu4GnUonsqJZLz2uJdIC0XNYOdHo7Audt8Uw495/vhVgN0Aw+W3p 2yiLLVRAgpF8XtQhny1byJY96TqUefDLbiEUNtQPZ12xQC3LdcXta0VYDkG+YLlT8sP1 jRoojW3pC0DSsvfXB66JlbdwIwJPE3bLIWlIVSYJfehqqgoazzANOA8B2uLjgMneeJAM x9Z4iDl8IZRqRXhIjE5VjbMaHI8XZi7mlhPsO3dU1boL+5VDcx73pVlsxToyP7LcBPXs f0cA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=8kpDmc07j9B+bsWzL0IUg31Cez5Uca1vji9WOl0EX0Q=; fh=YffzB02LOucIpz2GhkKhAxM6uTMW/zI5d7vGIhgu+Lg=; b=TCump2t9oV5gljW3IBM9J3H5OcFrw7JZqdWl+FTd3VrZv3rjiQoMA5t7Afc0R3EnJp +6IZLFBbTepFnQp23XFIHanmiaaLta0rQBEyGdaF8Ku0Hof+yB3ye83goSwtEhJHXkT5 iUK+y7p+IT8mgFNxThaVlEm61XEp2KXe0h0Pxu8nppRmHXcYoJ0AgVwtsMW0TCRZMYAX NWqujsm4mW5KXYWPt2sAVfTyzHhSulOLL2ICmxEmj4igTJmdgNKU5ZGwmhjmKY9ojKoM sbXgs6PRXu4RSOpEE2gQikO6KrZdkqsPfp3aRXMiEkN1DTuwi6k0ZBSu+L8ffA/tQtWO VT0Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=imoW8yWn; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-169651-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169651-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id v1-20020a634641000000b005dc493c9496si8084516pgk.507.2024.05.06.03.20.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 03:20:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169651-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=imoW8yWn; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-169651-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169651-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 414F0B226B2 for ; Mon, 6 May 2024 10:19:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D777D14386C; Mon, 6 May 2024 10:18:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="imoW8yWn" Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B430E143727; Mon, 6 May 2024 10:18:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714990715; cv=none; b=dZ04TGklzP3rx4v/kFHFnyFQlP2wApNMoiJ1Rmx7XZU0Vc9StOSko+i7lhYiSKvikwPrqP8NMCJ2CJKG6vL8KiMLUFivUt/kPON8ZY1VnlQFOWkQR2JLETYGfPnK5GYoxnYEu5dTYeK6YCT5GCq3Z7xJ+wO/guL6i3IHHXzl39c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714990715; c=relaxed/simple; bh=ff+g84K7inAIdzVwporLJbQLKqNwcOlgSp3tPVrcevA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=r2mr7T6UCrVJBtiBiGKGI1xzfwicDGgHfNbP9Pulil6cFjCWsxR90nGK7aJ73Neip/YpeFFCYh0QE9BtCLrP9c9CrokpRse1/y0FHozKjbGLZ6LQoaNKSXqAX3zUPGntmJA6lznX6jBtq4PHpepjVLJgkXm0hPCq9UxCEjpegEM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=imoW8yWn; arc=none smtp.client-ip=209.85.216.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-2b2b42b5126so1596253a91.3; Mon, 06 May 2024 03:18:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714990713; x=1715595513; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8kpDmc07j9B+bsWzL0IUg31Cez5Uca1vji9WOl0EX0Q=; b=imoW8yWnVm3ideL/1IHMFfkVroBSNRUj5IPqzVNugWHoOcLz7SoG9YmPIKwQ4iXbwt /B1RxE8zwBXrU8WuYjIZzkmZX49/wn37D+asdHQ/sHCC142dVMfon+FDKGHZ7Op1s4oO MY129U+42/3qyrHAQgtTqfl91JbEHUVZlaZUXFb1QwvHm99c77rTR96DEsp60EXaLI9o iUXXIMbC+QI5xsMRaWqE8FbmqGpwqGa1rIy2dCU9IB2BFosI8dS+h+c27dl7foOQqxU7 HIh3Jg8QnX86DyGqCwU5Z/rw0Nw/TaRPGzFxV7Qwxacec3Q/bC56IbQKHIrjyoSzlAu2 mmcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714990713; x=1715595513; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8kpDmc07j9B+bsWzL0IUg31Cez5Uca1vji9WOl0EX0Q=; b=PpJNlPyzuEDScLP7bha83IZMfyQDmgClDeK1s7HTXEned1IYstYEGIAT3vHeJPfTE1 EHLUMShn4g5wCW9fKDx+VhA1JoJ/lL//RMbAyUANLCUQ+5W+oFWRtpx2WspliIraDXyY 6UybWG5CL++LuyW5BQ4JMg4rHpTgFGyPtYbKZ+18GaC8CwLIS1f0jkldCXjtiKt0dWhN 7D2N6Lm19ubklM7N/5F4sSCXqmnf39O52OIXeBJDc4a2oyA55aAybbufVze5apdZCv5b eImFKdGmhrGWC+wiWQRTZiKfgBwWRkJAlDZQVV/hHOkEWRERXQD0nXDDp3bByqdOtqaZ EHzg== X-Forwarded-Encrypted: i=1; AJvYcCUKsgEPa93x3rW9o4MKX5tnte9cxPcRh14IcN/RzelsMlQwqxnWmjQFfJ3jNO6pm7oVKEgjAqzIG270jmn988MrQbCo7GrqD9anPmiqkHMErQqEqHIgZvFmdi1uEnMszOC0 X-Gm-Message-State: AOJu0YxP4JV2P7dOGIk6UPjJS0ZsAHXyqMyqntwDASZy87k9GgZyCy4O gefm9GWRjXNbbstsKzjmwAuQ5JgJ73qV6OLVi3OSOz/EihlXSGKW X-Received: by 2002:a17:90a:890d:b0:2b2:3376:b9e with SMTP id u13-20020a17090a890d00b002b233760b9emr8696215pjn.9.1714990713017; Mon, 06 May 2024 03:18:33 -0700 (PDT) Received: from localhost.localdomain ([43.132.141.9]) by smtp.gmail.com with ESMTPSA id co18-20020a17090afe9200b002af8f746f28sm9747820pjb.14.2024.05.06.03.18.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 03:18:32 -0700 (PDT) From: Yi Wang X-Google-Original-From: Yi Wang To: seanjc@google.com, pbonzini@redhat.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, wanpengli@tencent.com, foxywang@tencent.com, oliver.upton@linux.dev, maz@kernel.org, anup@brainfault.org, atishp@atishpatra.org, borntraeger@linux.ibm.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com, weijiang.yang@intel.com Cc: up2wing@gmail.com Subject: [v5 2/3] KVM: x86: don't setup empty irq routing when KVM_CAP_SPLIT_IRQCHIP Date: Mon, 6 May 2024 18:17:50 +0800 Message-Id: <20240506101751.3145407-3-foxywang@tencent.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240506101751.3145407-1-foxywang@tencent.com> References: <20240506101751.3145407-1-foxywang@tencent.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Yi Wang We found that it may cost more than 20 milliseconds very accidentally to enable cap of KVM_CAP_SPLIT_IRQCHIP on a host which has many vms already. The reason is that when vmm(qemu/CloudHypervisor) invokes KVM_CAP_SPLIT_IRQCHIP kvm will call synchronize_srcu_expedited() and might_sleep and kworker of srcu may cost some delay during this period. As we have set up empty irq routing when creating vm, so this is no need now. Signed-off-by: Yi Wang --- arch/x86/kvm/irq.h | 1 - arch/x86/kvm/irq_comm.c | 5 ----- arch/x86/kvm/x86.c | 3 --- 3 files changed, 9 deletions(-) diff --git a/arch/x86/kvm/irq.h b/arch/x86/kvm/irq.h index c2d7cfe82d00..76d46b2f41dd 100644 --- a/arch/x86/kvm/irq.h +++ b/arch/x86/kvm/irq.h @@ -106,7 +106,6 @@ void __kvm_migrate_timers(struct kvm_vcpu *vcpu); int apic_has_pending_timer(struct kvm_vcpu *vcpu); int kvm_setup_default_irq_routing(struct kvm *kvm); -int kvm_setup_empty_irq_routing(struct kvm *kvm); int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src, struct kvm_lapic_irq *irq, struct dest_map *dest_map); diff --git a/arch/x86/kvm/irq_comm.c b/arch/x86/kvm/irq_comm.c index 68f3f6c26046..6ee7ca39466e 100644 --- a/arch/x86/kvm/irq_comm.c +++ b/arch/x86/kvm/irq_comm.c @@ -397,11 +397,6 @@ int kvm_setup_default_irq_routing(struct kvm *kvm) static const struct kvm_irq_routing_entry empty_routing[] = {}; -int kvm_setup_empty_irq_routing(struct kvm *kvm) -{ - return kvm_set_irq_routing(kvm, empty_routing, 0, 0); -} - void kvm_arch_post_irq_routing_update(struct kvm *kvm) { if (!irqchip_split(kvm)) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 91478b769af0..01270182757b 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -6527,9 +6527,6 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm, goto split_irqchip_unlock; if (kvm->created_vcpus) goto split_irqchip_unlock; - r = kvm_setup_empty_irq_routing(kvm); - if (r) - goto split_irqchip_unlock; /* Pairs with irqchip_in_kernel. */ smp_wmb(); kvm->arch.irqchip_mode = KVM_IRQCHIP_SPLIT; -- 2.39.3