From mboxrd@z Thu Jan 1 00:00:00 1970 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 215D912D758 for ; Tue, 7 Jan 2025 04:25:59 +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=1736223961; cv=none; b=pXJDHAC895x5300r30CRx6NpPx4EyG0zHgHlg55WdlWnpL2Y757M6rSCeqUlH8gZxfY4J5MJAquy9QEJEW0n4nlmY/xKzAWfIhYarOCfI/BeJukO1dY7wYvRey6nn3AxzrMz8J8NG+VKWpkUmGLoXZm8s+i6okNyiwdBZT6r+R8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736223961; c=relaxed/simple; bh=q4XP1mcxyRTV8ljYZwLz2rFCo2d8/NzhcyRQyfQ6co4=; h=Date:Message-Id:Mime-Version:Subject:From:To:Cc:Content-Type; b=Miushoqnb9ta4JkTapcO5F/x/qkZexQc/ZXbzG1uCEwgydOoWO1zGf/5feJHjia3ZtHCURTGSafcCvBubcp3cNu4Ue7CeotZct5fMf9P7fIyNS3q3Y2wmpJMbZoICuMVYzQXRxzYk+E+MDNUni7Re5BVAq2x/uhI+LIyOEhzc40= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--suleiman.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=qkqbYOCY; 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--suleiman.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="qkqbYOCY" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e38d8aaeb4aso13757532276.1 for ; Mon, 06 Jan 2025 20:25:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736223959; x=1736828759; darn=vger.kernel.org; h=cc:to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=Xvyt7ISlXjtwBUhHlRKzb+2WR3hUAcYjIzDNfnfVyL8=; b=qkqbYOCYIoSJZgxe0bXidpQSsx0SsX6oo40tVgTHa2TGJOKjxQ8UmidPBrXBbvT/xf xn/jb5YEG6J3AxrIF2COqjzpjZ8cIR1v1pWAQTbYhlsnau0FDO013YBgqgDmHLRxLzrO gNX/P9PEI5nPDkbx/rySiCy64oPCso5/La8gA3bMzzgg4OLycy1gEJOThP93OyysoyDX pX6+ePRLjGJrqpAqNVafgpJEedu+D0XXxmPTqcXVqNj2HHCEe3qyfLZxjFdarjyDVDV/ A1jeXKRDfwCaKEQxdKI8KFUlsFEq+hgAhsUYyxozyVg0+mwtUQpyFBxbFIwuKMslw6TD NNtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736223959; x=1736828759; h=cc:to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Xvyt7ISlXjtwBUhHlRKzb+2WR3hUAcYjIzDNfnfVyL8=; b=wbnoDFaW0Of2VUbWmiUdQQm/TkATzbq56IMEHCzBXd3thXOtcuWWIAmeVGwb6fO2rF ZxSq4RCRQqMl40+ooSetZIAaf4xNGANX2zJwOep4lo7CjtM0WQIUoZatnoQ72YMwEAyZ dh9up5ms7/cMMWedcKW8yFhPUZ2k8ECuNZgLjwrnUtid4C0bbtFNexq9Y/jYRtXzgT0w OOkQiRfNTDeCaNU7ZP0W92N62Dd0YcLPe6kpeWDkXBOUMf1ElktL2x+M44avJrlMsDaf INAKsQVGG4d2oH0aslYWtzAXpdJPGtxb7ZlP5xAn45hRL0nSHCUd0rnPSmm3bxSOGMHi 88xA== X-Forwarded-Encrypted: i=1; AJvYcCU5xIz4xCGTUNAk1EgxZJjiIqdC7EM0mNmHieRZO9dfiZ8h9Q/9U7rHXeT/4BYi1IVKg1tu/geqPT167cY=@vger.kernel.org X-Gm-Message-State: AOJu0YybZ6zL6F4EgnJlNpbxMV1KXVh2cndEyaBqaQZPa1ugKcQedJVB gmVTUbUQuqNO2JhGdYhKHYGBnvSx+RiEprLmzXB7JUwLvNDTEH3wUhcnprCHLqZ8ofTvjCNBO57 6QXxgJrB+hQ== X-Google-Smtp-Source: AGHT+IHqgvq01vvZI5gZw7/Qm7CxyJFta1CnaqIdyfdylw/V2kEeU4WaPTKKeWUqcuPrJ0Rb3xrNKJ26nJ7+2g== X-Received: from suleiman1.tok.corp.google.com ([2401:fa00:8f:203:66b9:6412:4213:e30a]) (user=suleiman job=sendgmr) by 2002:a05:690c:288f:b0:6f0:22ad:43f8 with SMTP id 00721157ae682-6f3f8246a83mr1672567b3.7.1736223959088; Mon, 06 Jan 2025 20:25:59 -0800 (PST) Date: Tue, 7 Jan 2025 13:21:58 +0900 Message-Id: <20250107042202.2554063-1-suleiman@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Subject: [PATCH v3 0/3] KVM: x86: Include host suspended time in steal time. From: Suleiman Souhlal To: Paolo Bonzini , Sean Christopherson Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Chao Gao , David Woodhouse , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, ssouhlal@freebsd.org, Suleiman Souhlal Content-Type: text/plain; charset="UTF-8" This series makes it so that the time that the host is suspended is included in guests' steal time. When the host resumes from a suspend, the guest thinks any task that was running during the suspend ran for a long time, even though the effective run time was much shorter, which can end up having negative effects with scheduling. This can be particularly noticeable if the guest task was RT, as it can end up getting throttled for a long time. To mitigate this issue, we include the time that the host was suspended in steal time, which lets the guest can subtract the duration from the tasks' runtime. v3: - Use PM notifier instead of syscore ops (kvm_suspend()/kvm_resume()), because the latter doesn't get called on shallow suspend. - Don't call function under UACCESS. - Whitespace. v2: https://lore.kernel.org/lkml/20241118043745.1857272-1-suleiman@google.com/ - Accumulate suspend time at machine-independent kvm layer and track per-VCPU instead of per-VM. - Document changes. v1: https://lore.kernel.org/kvm/20240710074410.770409-1-suleiman@google.com/ Suleiman Souhlal (3): kvm: Introduce kvm_total_suspend_ns(). KVM: x86: Include host suspended time in steal time. KVM: x86: Document host suspend being included in steal time. Documentation/virt/kvm/x86/msr.rst | 6 ++++-- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/x86.c | 11 ++++++++++- include/linux/kvm_host.h | 2 ++ virt/kvm/kvm_main.c | 26 ++++++++++++++++++++++++++ 5 files changed, 43 insertions(+), 3 deletions(-) -- 2.47.1.613.gc27f4b7a9f-goog