From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (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 1024F1885B8 for ; Sat, 15 Feb 2025 00:55:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739580903; cv=none; b=Q2ZckEahV3sVrXqJ8JBlqWlT1Weoru78gfCysWiYo+dMEXF7UDLvCfQOAJTSMJA6OXcmE0UDxL/lEFWY1PMrg2HrTFaq0Tldy8tSm4YrBbl931SdlGcOzuB9lvDHOWwIg9w9NUSOE5qSpwjE2eAg7SgKmJYGulvpE1ZTrhi7y6U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739580903; c=relaxed/simple; bh=EOahgPz6fyQhSLBWqHv6GC8sZf/XOeLdOvMNVwUIpnY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Qk9OGGyvjK2lmuZkpjZtlmMhhO1Sd2rPtvYHlSmcTU/tBOpc2Rlf3Z3LeIuADs1Ht1E9V/VX0oGn2+n/Ihdct4IwjQocdKrw/d9EomtF0GRpoaiA+TT16l1D89+hhB/dNBzCTX/wF4w/QHHJiQnqAHo7VWvSxDGMLgeBE5UIFsY= 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=Wtod9iN6; arc=none smtp.client-ip=209.85.214.202 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Wtod9iN6" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-220ff7d7b67so15759215ad.2 for ; Fri, 14 Feb 2025 16:55:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1739580900; x=1740185700; 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=gTgQsorQjh14TutxhLLCxQmV6p+nBtXX/1kn8rG1LNI=; b=Wtod9iN6Ol6G1C2+n1COE1+3IjxIyqlCgOZuiNA91jEzp5cPW2wYUmAPhKrT4v0t7I j+VEZPjvV1cXMDEaNcKxBv36Ai8pgKLYQ98JOjaIQtIyWbpCMTTaxR6Mi21stYMRRssY YBXBfuxQDRUnKzED+ijt7k527hVQAsCZl52W4OSePiplLvj/FPhNgVMbizhRCEouRb+6 yWckVuoUSLT+gRApobHMwWEhfGR+y2lBlXk2JP3eweaJJ1YQlBPhZNDgm2ddryVupYmy jhN9G6DQikxakNfMo/GMoMXZGQoYgg5bwo4Fz4ZRhCUXPk3/k4eWuaHS2cx/wIa8VV5e uBDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739580900; x=1740185700; 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=gTgQsorQjh14TutxhLLCxQmV6p+nBtXX/1kn8rG1LNI=; b=heyCP4sjL696zCPfdLNuohvQnY1gQQhFT8/jXJnCj//eru2vvuCVr5wBhN0wIJ/0IK qA9atDi7/HxDRzISDb233dPHqFfmsEoz5QB2awYWHVQ6USD04FemnXZy6J1oTEWjcHhc JQ+oSftpUXzclq/F7y8xgLDp0lT9bO+QT7qYXsfTaTXTfHGuKe2luEquKMIqKY9wxOt6 FP34KfkWbLxsmoZGVibbR4kTJ6YYNWXcIXewBCbtS4PzQG3DPGA0qgppybzPLAPWsYUQ tR915K+wyA/1KiFLzxWcmlfQQk7nEBrupF5NQiXJKklL4QHX1o501m+GgF7EvJL4aBER ZwrA== X-Forwarded-Encrypted: i=1; AJvYcCXtqnaUJon71zAgt9W4mj4bpzHRVYJdQauGZcf2X8OTa8NakUe4w4uJJQ9Z+8CYZEKdr5f908XY8RekhoA=@vger.kernel.org X-Gm-Message-State: AOJu0YwwZqRkPDZBeHrwgg6vvnkUA6A9rgYs5UxtWPvWq9kZj1fn1aao Kzvz2AGummJJzAPgyhNNCVAz7vJpHxVdXOlslGqJiDfUX0qU7+RZmzRWSKfwvBjWO5DRe/SaMgJ QZw== X-Google-Smtp-Source: AGHT+IFnNgJr4fAST/anqb/OhGfaJPL4qFzSio+iAadkBSAqDbENgFOFYfhtq5SRt2eIpuzxLd/Yc+sQw1s= X-Received: from plblg3.prod.google.com ([2002:a17:902:fb83:b0:21c:5115:8766]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:f787:b0:216:410d:4c53 with SMTP id d9443c01a7336-221040b1916mr20971295ad.41.1739580900440; Fri, 14 Feb 2025 16:55:00 -0800 (PST) Date: Fri, 14 Feb 2025 16:50:18 -0800 In-Reply-To: <20241211013302.1347853-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241211013302.1347853-1-seanjc@google.com> X-Mailer: git-send-email 2.48.1.601.g30ceb7b040-goog Message-ID: <173958033580.1190199.12371307462069862956.b4-ty@google.com> Subject: Re: [PATCH 0/5] KVM: x86: Address xstate_required_size() perf regression From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Jim Mattson Content-Type: text/plain; charset="utf-8" On Tue, 10 Dec 2024 17:32:57 -0800, Sean Christopherson wrote: > Fix a hilarious/revolting performance regression (relative to older CPU > generations) in xstate_required_size() that pops up due to CPUID _in the > host_ taking 3x-4x longer on Emerald Rapids than Skylake. > > The issue rears its head on nested virtualization transitions, as KVM > (unnecessarily) performs runtime CPUID updates, including XSAVE sizes, > multiple times per transition. And calculating XSAVE sizes, especially > for vCPUs with a decent number of supported XSAVE features and compacted > format support, can add up to thousands of cycles. > > [...] Applied 2-5 to kvm-x86 misc, with a changelog that doesn't incorrectly state that CPUID is a mandatory intercept on AMD. [1/5] KVM: x86: Cache CPUID.0xD XSTATE offsets+sizes during module init (no commit info) [2/5] KVM: x86: Use for-loop to iterate over XSTATE size entries https://github.com/kvm-x86/linux/commit/aa93b6f96f64 [3/5] KVM: x86: Apply TSX_CTRL_CPUID_CLEAR if and only if the vCPU has RTM or HLE https://github.com/kvm-x86/linux/commit/7e9f735e7ac4 [4/5] KVM: x86: Query X86_FEATURE_MWAIT iff userspace owns the CPUID feature bit https://github.com/kvm-x86/linux/commit/a487f6797c88 [5/5] KVM: x86: Defer runtime updates of dynamic CPUID bits until CPUID emulation https://github.com/kvm-x86/linux/commit/93da6af3ae56 -- https://github.com/kvm-x86/linux/tree/next