Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5016381pxv; Wed, 28 Jul 2021 00:39:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWnj+LlA5Z/alh97QEExERLHfJynrWZDLugZhwKxA3b0C4cKFGedJ+1zxurRBzHdaJSgds X-Received: by 2002:a17:906:6b8a:: with SMTP id l10mr26111629ejr.509.1627457988823; Wed, 28 Jul 2021 00:39:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627457988; cv=none; d=google.com; s=arc-20160816; b=MCuqHXyYuC1m2PBRn26PTrvnQ+NufOe0hnQfpzHAdAtHrCZd1IDdQeNeaebEypxe8y Yr4muZmCQaqMKtOvRPvsPKJBPsVRd2+L9qMs1yzxYj4J4rW81vX6C4WxWvTkq4B+xw6U FBpVTSbmILGSQ5Ny2VaYZxBFcxaO0iaqOTyBYq0IXZuTBZHL1hdYPwTsuw+jsewVZgkQ /jJjOdKSJKRwGEUDY9vgMc5NB1hT+4fQHrAjk/L7Xewt0vjYvoyVrrD7553g9LpQyExf BSWROpA8H4RCT/VRGJCPdEVXW/7m5U7JyhrUdke8C2Z/cNoE7eqg5HFUlDSwV1IoXcuz g05g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=5eg2+Tx3JvGw0D/CoMC3TdXMf/9Gd8U3krkUaz50BE4=; b=vjQgEI2OI5M8oQYYiyq/L2Zc5xsjR38AD84anWs8TU22ZDJNaewK8/HLLKB94z7mdF XfYLzvqu7hCjCoIFLccZy/qXB/788B1EvXNpgnEp48p5m1byXOoYY8gqZOnHN6PO5Gwe REcLOwmRIhGGKaa1j2+OGvjcYlq55s5JJSR11ab6c67Pr6B6QgUAh9Q9zek7/NlifvSA S/1t0fLNOPwFh4q7FEw0gjwzisKN3p4Mgz8Behe3xoswZpYGgsvN2fb43QroHAb+l8BH OgqCicjgeBKzbA76PFSZ42E3vLklvsq737NfIpdOf6NsvElg2sumhCjzwbNxxXMO1gzI 7JDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=YjWoCulC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t15si6079570ejx.247.2021.07.28.00.39.25; Wed, 28 Jul 2021 00:39:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=YjWoCulC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234793AbhG1HiG (ORCPT + 99 others); Wed, 28 Jul 2021 03:38:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234420AbhG1HiF (ORCPT ); Wed, 28 Jul 2021 03:38:05 -0400 Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9CEAC061765 for ; Wed, 28 Jul 2021 00:38:02 -0700 (PDT) Received: by mail-qk1-x74a.google.com with SMTP id bm25-20020a05620a1999b02903a9c3f8b89fso1108125qkb.2 for ; Wed, 28 Jul 2021 00:38:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=5eg2+Tx3JvGw0D/CoMC3TdXMf/9Gd8U3krkUaz50BE4=; b=YjWoCulCWdRiMh559k1gu53KFjE25x7ITIVRM+Gpcau0BRGejZjppdXq5wQaUqptvS 2wS23MNxzuEs81183XFX7azhFf47Vzg7uYsocxqGIbAJdMYRClw3xBDIr/f2Z5vZnxk3 iCfFEIXsxb7L6EWlmPBmgo7NUJI29kr4co+0d1oOX8Mv7LT+SHu85iZ3g956uur+90E8 rWDYm9PSk53uLesp8hrWItMDdG64S/FzO6OfqZSCmPAEkqAdX5a+FI1N8XjBJTVDCjN6 5Ulh84g53ek4VkBLTIrvYGbo5mLQr5jzAaSDAIlptYY15jMBW2bbbtyCAuijI9sPnMCJ zQFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=5eg2+Tx3JvGw0D/CoMC3TdXMf/9Gd8U3krkUaz50BE4=; b=feznMdQLbTtwH8K4O1UHoaBX/8X15+RBY3oHdHMNikjcA5KSE46YvqJOa/mXSoGPoZ CoZlLDiaBTM8FUS4hQ/vzL88VhwnMqR8hiq2UcHkL9W2VUK6nu0w6jTFfDTlIwyMRcUV zpmasEB97mxcCwqGuRZzZI7ek41oQpsDdvFSfgwJHSApbEr/0lCMrpcD8waD0+k0a6VJ jEQCDPu9WkrzSEncLjRv7+CzR1OzPmq6JR3Wi39Q0RH0dA2r4Pwvlj4S6xxTjNg+dMt+ adPKRebIH0jN1gs2r0biQrNfjWR2Ks7iBn/6SFRdUS1BXlekd+ishljikPiw83kr5Mj6 ypJw== X-Gm-Message-State: AOAM533ljB3T+RQB7MgGEWna4qkBHLNySM+ZbJX9AZYYOSRJtI8wmcJm soGvjBUQKHBx0lwiWTeg/IJ5esoRdLmWBA== X-Received: from suleiman1.tok.corp.google.com ([2401:fa00:8f:203:44f4:48a1:aec5:6e5b]) (user=suleiman job=sendgmr) by 2002:a05:6214:10c8:: with SMTP id r8mr27013812qvs.28.1627457882078; Wed, 28 Jul 2021 00:38:02 -0700 (PDT) Date: Wed, 28 Jul 2021 16:36:58 +0900 Message-Id: <20210728073700.120449-1-suleiman@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.32.0.432.gabb21c7263-goog Subject: [RFC PATCH 0/2] KVM: Support Heterogeneous RT VCPU Configurations. From: Suleiman Souhlal To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira Cc: ssouhlal@FreeBSD.org, joelaf@google.com, senozhatsky@chromium.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Suleiman Souhlal Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, This series attempts to solve some issues that arise from having some VCPUs be real-time while others aren't. We are trying to play media inside a VM on a desktop environment (Chromebooks), which requires us to have some tasks in the guest be serviced at real-time priority on the host so that the media can be played smoothly. To achieve this, we give a VCPU real-time priority on the host and use isolcpus= to ensure that only designated tasks are allowed to run on the RT VCPU. In order to avoid priority inversions (for example when the RT VCPU preempts a non-RT that's holding a lock that it wants to acquire), we dedicate a host core to the RT vcpu: Only the RT VCPU is allowed to run on that CPU, while all the other non-RT cores run on all the other host CPUs. This approach works on machines that have a large enough number of CPUs where it's possible to dedicate a whole CPU for this, but we also have machines that only have 2 CPUs and doing this on those is too costly. This patch series makes it possible to have a RT VCPU without having to dedicate a whole host core for it. It does this by making it so that non-RT VCPUs can't be preempted if they are in a critical section, which we approximate as having interrupts disabled or non-zero preempt_count. Once the VCPU is found to not be in a critical section anymore, it will give up the CPU. There measures to ensure that preemption isn't delayed too many times. (I realize that the hooks in the scheduler aren't very tasteful, but I couldn't figure out a better way. SVM support will be added when sending the patch for inclusion.) Feedback or alternatives are appreciated. Thanks, -- Suleiman Suleiman Souhlal (2): kvm,x86: Support heterogeneous RT VCPU configurations. kvm,x86: Report preempt_count to host. arch/x86/Kconfig | 11 +++++ arch/x86/include/asm/kvm_host.h | 7 +++ arch/x86/include/uapi/asm/kvm_para.h | 2 + arch/x86/kernel/kvm.c | 10 ++++ arch/x86/kvm/Kconfig | 13 ++++++ arch/x86/kvm/cpuid.c | 3 ++ arch/x86/kvm/vmx/vmx.c | 15 ++++++ arch/x86/kvm/x86.c | 70 +++++++++++++++++++++++++++- arch/x86/kvm/x86.h | 2 + include/linux/kvm_host.h | 4 ++ include/linux/preempt.h | 7 +++ kernel/sched/core.c | 30 ++++++++++++ virt/kvm/Kconfig | 3 ++ virt/kvm/kvm_main.c | 13 ++++++ 14 files changed, 189 insertions(+), 1 deletion(-) -- 2.32.0.432.gabb21c7263-goog