From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.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 F29B850285 for ; Tue, 20 Aug 2024 04:38:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724128691; cv=none; b=a+XpCJWdCvYVHCeF5XL78/8whkZ/z9rzZ2YvG4ePftoISZ2bNVO/DKe0z5qxt2lc2IHLXeIE3J8Izfl69QCxV76EWGWy0e0ACVCq+nolfm99uDn6C6kY3FGex2S48AMFf3oVa3z/oRA8LU/278hjzCS7g39LU5jWhbCrdKopUwQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724128691; c=relaxed/simple; bh=01z90h6lcHICM5qs1RevhXHV0040bxeRjlAcOfBD4m0=; h=Date:Message-Id:Mime-Version:Subject:From:To:Cc:Content-Type; b=f+uYwpY0CrdBDaPfkCASbaDLy2g4JDCxMwTi19poSgocUQ8yiNRBgpR5CIM8FQit0IGDJkc26vb3UjeSh5RmrnZxKVd0ZMlTznTsjaUKAxl71v7RfHRBBpVozrELqyryTYJqBhZ6Q0IUD9vmMSeFRkdJqVwyNXp7S8xN2w5Znko= 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=eDJDZ4mW; arc=none smtp.client-ip=209.85.219.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--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="eDJDZ4mW" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e1173581259so7298960276.2 for ; Mon, 19 Aug 2024 21:38:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1724128689; x=1724733489; darn=vger.kernel.org; h=cc:to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=cYmSZG46+1D9koXZ08YLo6C2rK7AA5OHgMKW91U7KRg=; b=eDJDZ4mWgy/h2sB5132nwvK/5f7DQgEF9qn1wLf2wOb/yqOuSyjImZlpbd1kTwuPKu plOnIj+cL5owkfZo2wNikAUn8cdlCzQjVUC15rumaWrFV90i4kWE1/xvhGKxqCxG3h7m E53pf4LgiZrQgTmKLcp7tDGsvZ5YxYI1ue3CqG18mmIYtj6GoC7arbYMbdTfwB/elhPL cif31WswgnQrtorOqSX1qDzGO3UfI4V1GJFdquASr52yv6+0WH14dokU7lMA6ahR8+0r YJNdeOQlAckkkxqPTRwnIpyt13bDLmLujM/fCGMV5Zj6GrLkbGnpgiN0txMULr8luOWX 6aPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724128689; x=1724733489; h=cc:to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=cYmSZG46+1D9koXZ08YLo6C2rK7AA5OHgMKW91U7KRg=; b=YINU/e/Gi1Si9kLss795ahR4Ejtl+RDNyqAiLFqpxejJV9m8WTlL1b/4Cwf2D9R1bt MVnZu6+cMbeLt4HGlfav2OYHOMoJ9yEAFHMmYHVqai5fW0lNgmivT/joo0XeLntQj0lW DWhRT3cOuc/gPiUd67j9hj3AiOs4AHFNiNSuFnIKrjIzocWwSvf6I++ZkBieIDAmRQUq ksIr65132UeWrPk2tr1+n4CJHklsmxq6rs+T/QMlkYaCnZwMA8HuntVORlNRQG7L3i71 g5MDekciir/nOtUKpbC6zY6HC0YA/7kth0xNaD7Cvf1UonsYT6o5rP+nt/4r/dMfLw/8 a1Yg== X-Forwarded-Encrypted: i=1; AJvYcCXP9wqReOoMAJo5rsbvXLEY5LpDmFSsYUgdVGEKRydq5rjuDnwhf9nOwqSGYur9qaJ1pTo+gH1VwYuTIGE=@vger.kernel.org X-Gm-Message-State: AOJu0YzOssbnl/DZySqynJRP56jji0hZJ9szEVHM9D5dMQiiadZMan9o tFdzrvPJ5s5Q+M7rORF2oBSmbnnfjkL7LaCVQtzzopDNc1cXbCclAyYyFF2QL8TB+15cPF/voWr te2DTbOBmgg== X-Google-Smtp-Source: AGHT+IF4K1sQIMUkgyn2WKrZd5ulBrkbmjtdrJM4/Bb4XKeEBxffWJCKylJoJKRrv1CwuZjZw0RkEEIpLOyyKg== X-Received: from suleiman1.tok.corp.google.com ([2401:fa00:8f:203:7c18:89e3:3db:64bf]) (user=suleiman job=sendgmr) by 2002:a25:aad0:0:b0:e0b:ab63:b9c8 with SMTP id 3f1490d57ef6-e1180fa06d5mr17946276.11.1724128688995; Mon, 19 Aug 2024 21:38:08 -0700 (PDT) Date: Tue, 20 Aug 2024 13:35:40 +0900 Message-Id: <20240820043543.837914-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.46.0.184.g6999bdac58-goog Subject: [PATCH v2 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 , 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. (v1 was at https://lore.kernel.org/kvm/20240710074410.770409-1-suleiman@google.com/) v1 -> v2: - Accumulate suspend time at machine-independent kvm layer and track per-VCPU instead of per-VM. - Document changes. 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 | 13 +++++++++++++ 5 files changed, 30 insertions(+), 3 deletions(-) -- 2.46.0.184.g6999bdac58-goog