From patchwork Fri Aug 2 20:01:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13751949 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0A157C3DA4A for ; Fri, 2 Aug 2024 20:02:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Reply-To:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:Cc:To: From:Subject:Message-ID:Mime-Version:Date:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=ykPdpt4afpZ3jpFw7YSK1YDxe3tZo0sfBfoXskTzJEA=; b=QQPXU5Y0ySJ7nwboUjGTqu9jnK YFxPeWS9TV71Jduvuoc6ancwUFxJdUlcDn885oUxuhlMdHSjvDQRGPBQtBv7pPpWhoWZFqBKRkCue vtylg2eHUsZNTe6evtXr20JFreoVhwUqwSMSIbcVWvukpPFuxjxMOfKDYjjb7H1p1sQ4ZxFBfemPm LXXws6R6gdzmYHvxXotQxXZv42nlgUJwNFvKeR8xKw7bWVzi7BTd2VNolW/tC/FpnrF0n9m0cYY/n JSbat9f2mA6hpejpNJBSm6rI7FhNveQTCIGL8+tmTvig3sHWw3Nio9NSGqt1OuPbVdaAQk9nZWuzi FXKcOR0g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZyTe-00000009wBg-0F0q; Fri, 02 Aug 2024 20:02:14 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZyT7-00000009w36-3oVL for linux-arm-kernel@lists.infradead.org; Fri, 02 Aug 2024 20:01:43 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e02a4de4f4eso13548112276.1 for ; Fri, 02 Aug 2024 13:01:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1722628900; x=1723233700; darn=lists.infradead.org; h=cc:to:from:subject:message-id:mime-version:date:reply-to:from:to:cc :subject:date:message-id:reply-to; bh=ykPdpt4afpZ3jpFw7YSK1YDxe3tZo0sfBfoXskTzJEA=; b=pQEbuykdYKQXlJ/0zXw0S1NmI+ksttfltWGyBSgJ9HOFSdSBvkuvuHj9VidktTgsgG GnEZx45GdWJgT6Am/FbJVYJJ9h/fhaosHjPcjw46xLKyu1jg1THuAsYUeVrGqBixBMsQ +vD7rq8qgDhX6+b8zwfUunv3P8NdxoRl7qfbJosi1IQ4ifYavJD2FHpybGGul38utiVz SEaS0QfUB7qOcYs2TfOz5BiBOHfKXEmULJN7Zi3muVNY5pUKZqVwHP7/+HtfbbztA/Pf SapComPCNoGmQCE+XxHnHvYs7PffoVSJ6X9MRTeGNo9t4yxFdD+IARgnBazg3Om53tXm +4NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722628900; x=1723233700; h=cc:to:from:subject:message-id:mime-version:date:reply-to :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ykPdpt4afpZ3jpFw7YSK1YDxe3tZo0sfBfoXskTzJEA=; b=ZEVn6GG2qECQLoms6UgMqqVILAHNjADYXC4Vpl4Cpy5eSiaY2kJVSC11KFZ21IiLXG H0fsMcuOZMv0duo/yhoGJEUygUagnrJZ7OKfrn/nOee+4NK9zUjvzZk+UEPQE/BD1tRP 1sRFQYRoMQ/hULuGA8joA3z6PlXFpMDD2cC5X4WZmlvRP1tE9PX1APm/1JUFmSXTFivy M9uzva0QBB3IiIHoZGNYrjgiJQPY8aQKYE/qUywZ8/Q6ZpVWIFU2d44Ws2t0P0LYcwOI 21gY9Owo+gmt+1+J+6hE+WfmQcXcfFEAUbq4KdT7V2nDT1QRivDoeZ4HbjOe1tbJTPbN X30A== X-Gm-Message-State: AOJu0YyFIjOicwSxXHscYqr83QG5juHe93u9kFkSgsC/ZBCz3VXwcc+C FXUOkXqIcMUwWX6e5NLnvR/0mQaiaLDeypjOPS2c+9ONXz37cK07oDrpdvR7lup/6I6fjfbMPYa miQ== X-Google-Smtp-Source: AGHT+IFmEjE0twSlJTivyvNHNugTEVFQQZk8biWQMQbekPfidDKP6UgVbg8OwPEN3Johcfln+K3aJZ+eKcI= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:8601:0:b0:e05:f1ad:a139 with SMTP id 3f1490d57ef6-e0bde435653mr6717276.11.1722628899703; Fri, 02 Aug 2024 13:01:39 -0700 (PDT) Date: Fri, 2 Aug 2024 13:01:34 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.46.0.rc2.264.g509ed76dc8-goog Message-ID: <20240802200136.329973-1-seanjc@google.com> Subject: [PATCH 0/2] KVM: Protect vCPU's PID with a rwlock From: Sean Christopherson To: Marc Zyngier , Oliver Upton , Paolo Bonzini Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Christopherson , Steve Rutherford X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240802_130141_974000_12BC2DFD X-CRM114-Status: UNSURE ( 9.08 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Protect vcpu->pid with a rwlock instead of RCU, so that running a vCPU with a different task doesn't require a full RCU synchronization, which can introduce a non-trivial amount of jitter, especially on large systems. I've had this mini-series sitting around for ~2 years, pretty much as-is. I could have sworn past me thought there was a flaw in using a rwlock, and so I never posted it, but for the life of me I can't think of any issues. Extra eyeballs would be much appreciated. Sean Christopherson (2): KVM: Return '0' directly when there's no task to yield to KVM: Protect vCPU's "last run PID" with rwlock, not RCU arch/arm64/include/asm/kvm_host.h | 2 +- include/linux/kvm_host.h | 3 ++- virt/kvm/kvm_main.c | 36 +++++++++++++++++-------------- 3 files changed, 23 insertions(+), 18 deletions(-) base-commit: 332d2c1d713e232e163386c35a3ba0c1b90df83f Acked-by: Oliver Upton