Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp3290472rdb; Tue, 6 Feb 2024 12:58:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IEe4p/gkXc/wkTiKqLGFLkIC/UCijzshA4Mq4yMJQJhTzR7ty5eKm8dikFu13a6TB7ryttn X-Received: by 2002:a17:907:7746:b0:a38:ab4:4702 with SMTP id kx6-20020a170907774600b00a380ab44702mr2390677ejc.38.1707253139743; Tue, 06 Feb 2024 12:58:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707253139; cv=pass; d=google.com; s=arc-20160816; b=i3FrGM9oD3QBZqsz1h7JDMPi+Ix37RzAKBeJpe4przeYlR7y2v0JPJ1iAyuTL7hS9u yG8O0rG60qavx3FBQy5+UGRqagk8Rme4WwjmMiD4VMZxyMsVYY0jJo463FOIRnpRViDK W+GmsakZZ3vZuz74TMavDR+tjMyHals2Rd2+op+S4Ugt0/uxBqX7MQR5pYn9V2oYuR4H RfJA0vQXsnMpDygIkLiF2bjFlkhjah6cTExYhdyOxivomFP4GgTQzlSsm8w+Mn3n6sde peixHLtxVz/j589ToojenKlCO96LCDSK/LTjfiBgsOMCFDGM5TdaVWHa/6lMhoK3wurw Ekvg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=0enT21I+2oflGQFv4IttPgAIR7OGwbDWfwrCGcb3/A4=; fh=Ojx1TbpGKkU8IqPdkJ6nmOpvaKsJQuzVXg/xGT+dAns=; b=zOKKe2JoZrV8eowLaN06q1tGK0zT8bS0YkSg6TRvPyAX+TOMbgRcjOj3NSmn4Zo5Fa KuPXkDCPdbnSvYu3ocfSrVpn24EpClwC1a/7ZPEEvdkZIGRSx6AqrDkZ3LRBlyo/U6Ue kdEsk1saICZZQxmsUC82sNh5In+SM2UV8e0CB31TnJ1IEpYVLLdu64jbgge09EkqdUOX wFPHETDIAh8iSWFAzo/BqzIhkFbClrg3NoDq0GEiVpcBHONSqpaOpVFh3dHDB6zED+bY VgdUa2/xNZxhY6mPbuiMeuZdAYLuLq+1aM6GUFeTgPU2UcLUnRXu82yErEZExU7Ybzba j1sw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="Bc+M27W/"; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-55615-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55615-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=1; AJvYcCUlImc0oXZ8bb6Bh4e4uj7nF9RAylu878d2xrpzKj9vHBzwuuaBLpSOhePFezRXZ3b5gIxho7PckyHTOMcIdrGdIzs8VF6LPis2l+v8PQ== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id x15-20020a170906134f00b00a3741771f3dsi1445560ejb.418.2024.02.06.12.58.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 12:58:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55615-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="Bc+M27W/"; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-55615-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55615-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 75BB31F22B0C for ; Tue, 6 Feb 2024 20:58:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 32C891B946; Tue, 6 Feb 2024 20:58:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Bc+M27W/" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (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 D38E91B942 for ; Tue, 6 Feb 2024 20:58:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707253130; cv=none; b=rXjv4cVZEwAUCp7z0OVnUK+8Q3CMe30W3m06OmrmpQyh/HG56KIp6cLhWA0pORjBM0W0aFvbqFh93Gpkq/Xfg40F/HtBYep1NQ5tWLDLIi5zfZx5LtiDP1YM+rVGNFcTJxJjydnghhY9MoEbfQTb4ybkHmeCkIEU58TJNXC0Rt0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707253130; c=relaxed/simple; bh=9qRObfvA8ZAb+FX9SBRhdcDcbidM1/tWMt7Ry91tecE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=sg60WjBAb7e5t9x7pL2NqRAvvXIwYC3d/fCZC07q1QpCCYbvsuhSuENYhXsYHcoLdlXAQ3dy9adtUTXIs9Eiq/qEC8aN+ef/tFri1G59v/OyCU1L8B0gbBZFsurJ76/qCDtWg/CNU9gjsJkmEKXqe1k/0ydOzAYjZ0y7a9mD+Q0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Bc+M27W/; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dbf618042daso8606160276.0 for ; Tue, 06 Feb 2024 12:58:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707253128; x=1707857928; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=0enT21I+2oflGQFv4IttPgAIR7OGwbDWfwrCGcb3/A4=; b=Bc+M27W/7pD3mYKxQLPYJB8JbpVgsWB8bGq5QrRg3L/1H/L578u7XnmWcyY0N6IDVG bWLziFYsy/Dkn+oItqWwJo8f80R7snRVublbS3Ph2Nzp+qIpi2WmdwoL8VBtvUW/ChA5 lDS5VV0j3BQokPNjlTiK7OVNWiyJd76WpYDycwclw2cMmkNtGUicNAJLAJaBx9hXYHvo 3kuKTpRwXzj2XOu7WQNTItJd9WYRyB0siQKDrGuSKHfSCKWkvOlkMUeaJAkUuvosQi4v h7+NZ0IjOaZ04RDjQIvhj4rdYv5eGs5rJYrU0/yDsZPP3qdlYkSmCSV6KLZs5dGJO6IU mYpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707253128; x=1707857928; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=0enT21I+2oflGQFv4IttPgAIR7OGwbDWfwrCGcb3/A4=; b=aGjQ1NdPsFtscN3KmahTZTf/m/5g8bBLwnau44bVuk2YMEZfyQuWTCXbkZ4wr/sZ2f LMH5EApSpYlBYliVM3LwmcBPGSKMugSU1Z2KuJ96DPCmSOMDkB/mcgjiBbRjZh1Qbc8E io8mZq8iYpdXjVGi/SDjwYnxHS3pkLtYwjCGoZIzKhMyV5vZJd0W9aSXaxk31YWHgrdB 7YW/RR0JyHQYdBFH0sVmPqie3/dnBsnheJoythkYoDB3syP1i/RrD2TbmwlPTn4gLK75 jLcCB3Ki+A4drtc0g033Aq54hAj78JgXvRcYSyOSovs4meAVpEEAdMLPIEkNFuhEqSW2 h6lg== X-Gm-Message-State: AOJu0YzwkKyadcqbGTjgZY4uq2R9ZUMJWFwzQ7WzawhOzohlGF3j8hMz uX95cH1TCzdn4TiOoqMNrCRUNDkkrPuFrKTICacz6EZt8vYouReVa/JB+3eTdYI0FlReWOZhGjt 9og== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:2604:b0:dc2:57c9:b44d with SMTP id dw4-20020a056902260400b00dc257c9b44dmr127604ybb.8.1707253127933; Tue, 06 Feb 2024 12:58:47 -0800 (PST) Date: Tue, 6 Feb 2024 12:58:46 -0800 In-Reply-To: <8fe554e5-e76e-9a0a-548d-bdac3b6b2b60@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240103075343.549293-1-ppandit@redhat.com> <8fe554e5-e76e-9a0a-548d-bdac3b6b2b60@oracle.com> Message-ID: Subject: Re: [PATCH] KVM: x86: make KVM_REQ_NMI request iff NMI pending for vcpu From: Sean Christopherson To: Dongli Zhang Cc: Prasad Pandit , Prasad Pandit , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" On Tue, Feb 06, 2024, Dongli Zhang wrote: > Hi Prasad, > > On 1/2/24 23:53, Prasad Pandit wrote: > > From: Prasad Pandit > > > > kvm_vcpu_ioctl_x86_set_vcpu_events() routine makes 'KVM_REQ_NMI' > > request for a vcpu even when its 'events->nmi.pending' is zero. > > Ex: > > qemu_thread_start > > kvm_vcpu_thread_fn > > qemu_wait_io_event > > qemu_wait_io_event_common > > process_queued_cpu_work > > do_kvm_cpu_synchronize_post_init/_reset > > kvm_arch_put_registers > > kvm_put_vcpu_events (cpu, level=[2|3]) > > > > This leads vCPU threads in QEMU to constantly acquire & release the > > global mutex lock, delaying the guest boot due to lock contention. > > Would you mind sharing where and how the lock contention is at QEMU space? That > is, how the QEMU mutex lock is impacted by KVM KVM_REQ_NMI? > > Or you meant line 3031 at QEMU side? Yeah, something like that. Details in this thread. https://lore.kernel.org/all/CAE8KmOyffXD4k69vRAFwesaqrBGzFY3i+kefbkHcQf4=jNYzOA@mail.gmail.com > 2858 int kvm_cpu_exec(CPUState *cpu) > 2859 { > 2860 struct kvm_run *run = cpu->kvm_run; > 2861 int ret, run_ret; > ... ... > 3023 default: > 3024 DPRINTF("kvm_arch_handle_exit\n"); > 3025 ret = kvm_arch_handle_exit(cpu, run); > 3026 break; > 3027 } > 3028 } while (ret == 0); > 3029 > 3030 cpu_exec_end(cpu); > 3031 qemu_mutex_lock_iothread(); > 3032 > 3033 if (ret < 0) { > 3034 cpu_dump_state(cpu, stderr, CPU_DUMP_CODE); > 3035 vm_stop(RUN_STATE_INTERNAL_ERROR); > 3036 } > 3037 > 3038 qatomic_set(&cpu->exit_request, 0); > 3039 return ret; > 3040 }