Received: by 2002:ab2:3c46:0:b0:1f5:f2ab:c469 with SMTP id x6csp41955lqf; Thu, 25 Apr 2024 21:17:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVdBimjKeeu5K5UikMS/0gqophDV4XfjHeoBzXG5n6cOgdzt/BF4cNGqeouGp2lPFCPtMq38fodnB+T6m19LYLYzJLuJyjH+PImnRnuEw== X-Google-Smtp-Source: AGHT+IGdYNRJI+C0Q9jOQPCDALJm6TR7NayllVxrGmPHsJAKKJNQNBZOVMz+G9I6C/vziQ76KrIB X-Received: by 2002:a17:902:c947:b0:1e2:7ea0:c1f2 with SMTP id i7-20020a170902c94700b001e27ea0c1f2mr1948153pla.58.1714105032811; Thu, 25 Apr 2024 21:17:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714105032; cv=pass; d=google.com; s=arc-20160816; b=suBVPNUCQdvsHBQh5ktpwOiIxj8ow7SuzFTsksImi12RZHjQKNbYg8puqfYKTuSx+d rq3uGpujLrc+TMWMtNLbh5Ufgk/GlIM7WitkYnPkeO/nkSwdvCVqednS8EohNBe/DjdG VtwQgzmPRvJqceHPTCA4d+bY2yvWh+g7q78DoYOLt35gOs5go2/1895rbWlbM/qELuhk S0wGSbVOXRh28thXlIYTJezhNcE7rcW9gjKCDzVZkw3kM7nDVihyJdMBbZSULtmc/I9P T/HvbyzD1qkme1PK6EDSKT3tw8+kDLiZkub+p/yaWUoEFVrU/Y9LxR/KDWnK8T+BAuSs GmFg== 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=SskCxyqEuJ7jECWh07pSsTRVtNiF867Sf2iN7jCo9tY=; b=SCOJwJ+qG2vE9shEvSe8Pllu4f/tEysKBx5CRREgMtC+M0Wy/NZZfuCDjCbQSzXXrG V1b767PlsK1DjXFzApKZ7Cj3PYUZf46QM0sNZ7jW58MPEWS5Ayr5xbSOppQ6cuD8kAYL j6U81tKnCEAO1FvdqLU2Kd/1SgcRwlshyHOINr2secpjHls9mV5kHWWueyEXacD9zJ7P f456bDrqmPuG5Jct6Cuxij5Dgr0XOHrG6mTlj8saFTTrkGlRQP5kzVRaFzLVaEsd3QgS cJ7xULVWpKkqiqVUO5ur2/vxq5jioLK/yN1DM9B2fAP+dirZ8EiPJKyWMZsWuj1BWaAL 5HEA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=e+VWwqlh; 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-159494-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159494-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id x6-20020a1709028ec600b001e4ad7873a9si13880200plo.162.2024.04.25.21.17.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 21:17:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-159494-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=e+VWwqlh; 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-159494-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159494-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 6AA5528510E for ; Fri, 26 Apr 2024 04:17:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0F112824A6; Fri, 26 Apr 2024 04:16:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="e+VWwqlh" Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (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 DC23A8288A; Fri, 26 Apr 2024 04:16:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714105000; cv=none; b=DWAbTWOzpjdPt4TH9PhADAlL0Jsj5xGX270LQ+nU6MucGtFdlHAi1KTCvDfu9NEQlsMSelPMoX/zGxdLpy2dcJSDKKdk8qvH69hHDNcjvSciP8kyS4sPAt5jFftdK3RaPn68Fgt7Vx04aZumZNpBwHTADpgrGQEVe4+mA+n4iYo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714105000; c=relaxed/simple; bh=ff+g84K7inAIdzVwporLJbQLKqNwcOlgSp3tPVrcevA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YqwiOILneZM9lJCo87yH4f528lRo9H5/vNtRLFQEdM6Wkejn3I1LYqJIGnRP6d+DBPh2DCddy/w5Ezi1ahvRWcfy4BbRFecy0S6XvQbArAn3Adbaq08JgMhePS34I+DucqH9mW6E1ZnziQ++ewdcFc38TMaXC0uaRdtPuKjlrS0= 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=e+VWwqlh; arc=none smtp.client-ip=209.85.214.170 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-pl1-f170.google.com with SMTP id d9443c01a7336-1e86d56b3bcso15836145ad.1; Thu, 25 Apr 2024 21:16:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714104997; x=1714709797; 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=e+VWwqlhZB3sTU+LLFx29DJnuMjs4THTFs3wpFdthmuoTlI48Z6PjLsptd0JU7j55V T0LnhfxRUeU69Ba0plL9vA8F4j7asqt+IkusvJdWfqP8dI9c69RjgAZK07Bzeib3xBri u5Kxcq1wdJBCEnvo5DW4W0oMJyqlPdb38EwIKRYDvXAkjnJ/o0tco8rq+pwDl+kOMFhc JZsRqfrmqHEXcYmx4PJqltO1ECMXDNJHPmevnpui/TIUEG9aYoGyZJ9Ry7n3tLi0XmZC jTRHJKa+0EW/BAs+w/7TYSRfneLHz1q8lu04ptAEg4zuFpmsyyrStzUy5ZVIIN5AyZ5c GFPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714104997; x=1714709797; 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=FmDrkUwxTAtHqc3luC0x4sagK8N3/7d9U6atdj7/f+nV0mig5SkKf3wm+pW/JjzjQU Zr2oLDemVo6fEhID8tsgIBoqiuurUfkxpE/toWl5jKMrzXz7W8PRO+XYFErVXM42IgEV lCQaY06pND2rdSkG3NDoEGbuWG4Vwg7feZjb8cnzJDgsx9RSi92c8Ujg7eBRPMotLcr2 C4sRPnKZT/yNgfomWDNsRfnrSBVkjOOmzXbVVANF5f7AA1wxjElsqUA0uRP34XsFesYB RZMFy3jAlnSfsjkoPM26Cjbw+E93KGjqf/77mSGO6sQnmF32ttMVKB8ph1UXzOY+8BSB 70IQ== X-Forwarded-Encrypted: i=1; AJvYcCUh0HAgzlvmIBzLLI0uqVpf5hqlIZJHg1kkwAE+OGZ8fWhiRxq0SB2SNgcxESOWSWpTAPehOlNHtzrW9JG21ndEjtJwo/Jz7+4UpWH51WinzWBUCWB2QOOa0HcQWGL3aWVE X-Gm-Message-State: AOJu0YxqA09b4hkQ7SxXbWR9ZU6AUJGx3jer+Iief8Bf5O7hKXkOy55c I97CpTn0ix61gphdWLVmZCFwdkRgIfvoEY2+yj0Zooce23rSQSE+ X-Received: by 2002:a17:902:a383:b0:1e8:26e4:d084 with SMTP id x3-20020a170902a38300b001e826e4d084mr1435914pla.60.1714104997033; Thu, 25 Apr 2024 21:16:37 -0700 (PDT) Received: from localhost.localdomain ([43.132.141.8]) by smtp.gmail.com with ESMTPSA id x13-20020a170902ec8d00b001e9684b0e07sm9426780plg.173.2024.04.25.21.16.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 21:16:36 -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: [v4 RESEND 2/3] KVM: x86: don't setup empty irq routing when KVM_CAP_SPLIT_IRQCHIP Date: Fri, 26 Apr 2024 12:15:58 +0800 Message-Id: <20240426041559.3717884-3-foxywang@tencent.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240426041559.3717884-1-foxywang@tencent.com> References: <20240426041559.3717884-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