Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6784354pxv; Fri, 30 Jul 2021 02:12:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeIZZ+6Dn60TfQBbK+dCv4WceEO+YuZWoy8iMGVKkGr0PNDW/uTAtM3lsQD8Rt0z+oQKJn X-Received: by 2002:a92:cb4d:: with SMTP id f13mr1269751ilq.57.1627636357772; Fri, 30 Jul 2021 02:12:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627636357; cv=none; d=google.com; s=arc-20160816; b=VuaAqghhMqmMiQQs4t5M3SjJHyOCgCqB6Y0pl3sjLiLBi2E+7TfQKRsTj746Cmrrdu qTv3kFgcPNwsxBvPZxdHkA/9PzNY+bpSSyu5T2kdzKVQsNA7arKBt8OUqk44pA889E/1 pwstQsBHTg63Y1o/1ygyMOBlVJTHHl0Ylzvdi27AZE6G8FfyL0NIUYybmHXo3zfzVz8g EYsa39DXNu4+NtdPBss5V6Kl00bhWuv06M5KtmgvNDXptpdFxhliNnLro1qzoqBPerSh ZZbqOi2t24HXFYilCEK0JlARvpbPo+GjDL7qdmQQQmhaK+RiaIBNpt/rs476f5VOdv24 dqpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=C1//LZ4o9bUA4dg1AgHjS+mwziRpkBn+ySaK4ZjppZk=; b=hucKiqxKwUZ0cFXeGsuAxScA7SRYDaYg5sSNRfihOrlBNy6/44yOCSjgdnXx/lj92G tYCsr0fV4k0u/xGbFnvmzwkAfOlBOYRu8clyM7yMWl8rzpJxxNW0bvna0sesPOSfoysj E7/qYEtvA/TgyvC9wgBRa5oUvYnFQEiXVMRKgwsD7C1vSAysZgArvAU5JqWIto1Ab4RK oNgyd8Xtg/HAH4PaXihRcv7t1PvoUSYeKx1dY5+56tBjHrmgfi6cCUB79Do9diwcdEWR 08f9/xRz8Scf6NNN0Pmxg4yuOwYxl7WWw2y2qBQ+YHb8c4eBh62zHP4SQvf6LKJ6Kct8 5hPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=v7hqIbZo; 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 r6si1267712iov.48.2021.07.30.02.12.26; Fri, 30 Jul 2021 02:12:37 -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=v7hqIbZo; 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 S238136AbhG3JJc (ORCPT + 99 others); Fri, 30 Jul 2021 05:09:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230335AbhG3JJa (ORCPT ); Fri, 30 Jul 2021 05:09:30 -0400 Received: from mail-vs1-xe2d.google.com (mail-vs1-xe2d.google.com [IPv6:2607:f8b0:4864:20::e2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0B87C061765 for ; Fri, 30 Jul 2021 02:09:25 -0700 (PDT) Received: by mail-vs1-xe2d.google.com with SMTP id t2so5045935vsa.11 for ; Fri, 30 Jul 2021 02:09:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=C1//LZ4o9bUA4dg1AgHjS+mwziRpkBn+ySaK4ZjppZk=; b=v7hqIbZovsisJFkgQACA9jFXmxfez6Xk+l0364CqR0UjELBQwlRHq2IEaDqoYxtfL3 LMAZ2C3S+SM5SxEB0kpUbHukDcy3VHbrUnh7IddL0awWnEnacbIRt5Yf07BH/dug8l7x w4bRtipS5U0WBXkrub2kolienm5dFJIuzXMK8pyvRlkrcJOi69DdpDNhB0UKVEXc7e11 fJXKDkZCYCL2QEm++mb1mZOjYYAcbAyfBK6bu6uiyUJrMuCCMlC789uF468XzfOV1xyU UXnU6kB1JIoE1r6LcsSxgo5u614RM+0Pg6NYcWLKyuxAJbP0HRIZafg2Sh5E9hHcNyrJ ivRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=C1//LZ4o9bUA4dg1AgHjS+mwziRpkBn+ySaK4ZjppZk=; b=i4Gt5/RzTTQjewn4aRQERnkXQJVOYTKHcWq/0YjZ4VT5zEe2zWE7iUPy6eO73C1Jk+ TYJk8+481OJE95CS6ZlSFZd8jWLoiRtAn0at/6s5JJC0Urv8ByfSuUnzieo+JGchgOs1 5RAqUMNFqNUVbFr4xiDqb4sxExsG9cM6P+hPiLtvDHg7BcA4Ax+i/lgY5dtGsxkq/AOJ KNTnxCB/NL5va4kRnvNgBmaR4W5CAxM++gvBiRwBHsNVoI6luTri38J33AlMSiLoTfEt Uy7CYNn24V/e9+vX7dXS0xaIUYvdGu+LifAVC7rUkJxLebXL6g1cZp2YxMVSObPXLR0K e1Dg== X-Gm-Message-State: AOAM53131rSvRYtUUKpaWaYu2+b9E6xm5cvuG54hqVMTAl3wiSLqUlKB 85O0T7rbbT3SR1eRTw7a+ifPcR8yjdsfljJVT96G1w== X-Received: by 2002:a67:fe57:: with SMTP id m23mr676372vsr.42.1627636163744; Fri, 30 Jul 2021 02:09:23 -0700 (PDT) MIME-Version: 1.0 References: <20210728073700.120449-1-suleiman@google.com> In-Reply-To: From: Suleiman Souhlal Date: Fri, 30 Jul 2021 18:09:12 +0900 Message-ID: Subject: Re: [RFC PATCH 0/2] KVM: Support Heterogeneous RT VCPU Configurations. To: Peter Zijlstra Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Suleiman Souhlal , Joel Fernandes , Sergey Senozhatsky , Linux Kernel , kvm@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Peter, On Wed, Jul 28, 2021 at 5:11 PM Peter Zijlstra wrote: > > On Wed, Jul 28, 2021 at 04:36:58PM +0900, Suleiman Souhlal wrote: > > 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. > > WTH do you need isolcpus for that? What's wrong with cpusets? I regret mentioning isolcpus here. The patchset doesn't dictate how the guest is supposed to use RT. cpusets also work. > > 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. > > This is disguisting and completely wrecks the host scheduling. You're > placing guest over host, that's fundamentally wrong. I understand the sentiment. For what it's worth, the patchset doesn't completely rely on a well-behaved guest: It only delays preemption a bounded number of times, after which it yields back no matter what. > NAK! > > If you want co-ordinated RT scheduling, look at paravirtualized deadline > scheduling. Thanks for the suggestion, I will look into it. -- Suleiman