Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp276762rwr; Thu, 27 Apr 2023 00:48:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5FD+0UzYy920Qd6YDNls3cXEFRe9DtmWCcg4TRUCKrOmY+Q8ru9/LU91KOmJ9wUaYYDzHB X-Received: by 2002:a17:902:e552:b0:19e:94ff:6780 with SMTP id n18-20020a170902e55200b0019e94ff6780mr760779plf.6.1682581722208; Thu, 27 Apr 2023 00:48:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682581722; cv=none; d=google.com; s=arc-20160816; b=IzjYcSqb2yYpym49/R11x8PfT5rSVhPz4MSYYd/fls0GNpL8vceB326GH9W5KeBnA9 4SNJP9DjcrS3vWtU+iGY5uWZVKKIbLKA1TtRDaPcA+8zHdrR8QD/VMKSM8kgj2EkEaAM LkFVNaqW5Nc5by20CETmOK0RKdDn1OHDysjQsTdP8tdK9tRq9tDCZwArjAApK9MDqiU6 VkenBhBKGkA5tBEy1xvavYhZDnUlmqq/nPbajM4pGNGZxveavUr5wuBtR+6df9bXoYBq 4JbATzVnMyGZGk0uYz+oP8ydsBRNdulSeRIdHE1eV+Ui3Qv9FFisWaq0Q457U1+gmwXm rJ/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=c6tPZL64LtsIrYoFQTFyNm93j7JzIUswZJcU2RAwcdw=; b=aZEiS2vdY1CHnJb+BMz3vmxGZB8SpEt8UId3KUjgfpcEZUaj7oCJ6DDqhZUGvYvqYK 1LLO47jIPlntsaBIRbNh83iXlmvDaxwIwKJ4RFrVHZ4IFpH9SKqzliICn9d7rU5miNpJ /sMFRxPwuRrUJlSef+pYK8ovbRU3KyiyVTCiU0GxGcr2qeISQShrHohDm8hHCw/b6Wxe pgZhFDMf2oq+Wvz7li2N29eWy7YpxGPlfAd9vTlWXC6In5lFFs4acyzRByvjx02kHWOV 9kXhKmzNqYn0WC2WJwZGImNO7SP4Mj6gG1IYa8sYodkBxIo878BF5A6KtJfhjytiiZug aiww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=dBBj6bmp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k18-20020a170902c41200b001a66a0f12b7si6278684plk.236.2023.04.27.00.48.30; Thu, 27 Apr 2023 00:48:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=dBBj6bmp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243145AbjD0HrL (ORCPT + 99 others); Thu, 27 Apr 2023 03:47:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242985AbjD0HrB (ORCPT ); Thu, 27 Apr 2023 03:47:01 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE2962698; Thu, 27 Apr 2023 00:46:59 -0700 (PDT) Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33R6H0w8027812; Thu, 27 Apr 2023 07:46:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=qcppdkim1; bh=c6tPZL64LtsIrYoFQTFyNm93j7JzIUswZJcU2RAwcdw=; b=dBBj6bmpHubQlTesT9WoZyS0Aq5xgYypa3uQjq1N5DbkhuP1nc0kTfV/Ym1jAdzxd0tq 88fKEFj3UNam8MAHS1xq8vPgOJUTwjwrU6nOpNq5OeC8xeoOCCeZH5FM+BtmORy/hd/h UDScvuo5tUY5xoltgaL+/BbCq4dHHD87dFNNAc3hDu+BIkE+U+baDssjnMPi7GhUKAzz 5HSq/d5O2x78g+a/haNFHQscBsgqXReAat689ajWGFtxBR+g+7j1FLJZ3dhYOIZPzA4c pbaQMumMMTbHr/Cj4ayNUPLPxo60+eshrPg2xoy48RX+KFfYeb4LKUCQZ07B/+OnaDgX Ew== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3q79am19xa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Apr 2023 07:46:25 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 33R7kNgl011691 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Apr 2023 07:46:23 GMT Received: from hu-pkondeti-hyd.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Thu, 27 Apr 2023 00:46:06 -0700 Date: Thu, 27 Apr 2023 13:16:02 +0530 From: Pavan Kondeti To: David Dai , Saravana Kannan CC: "Rafael J. Wysocki" , Viresh Kumar , Rob Herring , Krzysztof Kozlowski , Paolo Bonzini , Jonathan Corbet , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , Mark Rutland , Lorenzo Pieralisi , Sudeep Holla , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , , , , , , , , Subject: Re: [RFC PATCH 0/6] Improve VM DVFS and task placement behavior Message-ID: <20230427074602.GA325349@hu-pkondeti-hyd.qualcomm.com> References: <20230330224348.1006691-1-davidai@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20230330224348.1006691-1-davidai@google.com> X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: k3Ws6u2M1vI32yF-_7r5Yc0Vq1RVGLo4 X-Proofpoint-ORIG-GUID: k3Ws6u2M1vI32yF-_7r5Yc0Vq1RVGLo4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-27_05,2023-04-26_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 priorityscore=1501 malwarescore=0 lowpriorityscore=0 bulkscore=0 mlxscore=0 suspectscore=0 impostorscore=0 spamscore=0 adultscore=0 clxscore=1011 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304270066 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 30, 2023 at 03:43:35PM -0700, David Dai wrote: > Hi, > > This patch series is a continuation of the talk Saravana gave at LPC 2022 > titled "CPUfreq/sched and VM guest workload problems" [1][2][3]. The gist > of the talk is that workloads running in a guest VM get terrible task > placement and DVFS behavior when compared to running the same workload in > the host. Effectively, no EAS for threads inside VMs. This would make power > and performance terrible just by running the workload in a VM even if we > assume there is zero virtualization overhead. > > We have been iterating over different options for communicating between > guest and host, ways of applying the information coming from the > guest/host, etc to figure out the best performance and power improvements > we could get. > > The patch series in its current state is NOT meant for landing in the > upstream kernel. We are sending this patch series to share the current > progress and data we have so far. The patch series is meant to be easy to > cherry-pick and test on various devices to see what performance and power > benefits this might give for others. > > With this series, a workload running in a VM gets the same task placement > and DVFS treatment as it would when running in the host. > > As expected, we see significant performance improvement and better > performance/power ratio. If anyone else wants to try this out for your VM > workloads and report findings, that'd be very much appreciated. > > The idea is to improve VM CPUfreq/sched behavior by: > - Having guest kernel to do accurate load tracking by taking host CPU > arch/type and frequency into account. > - Sharing vCPU run queue utilization information with the host so that the > host can do proper frequency scaling and task placement on the host side. > [...] > > Next steps: > =========== > We are continuing to look into communication mechanisms other than > hypercalls that are just as/more efficient and avoid switching into the VMM > userspace. Any inputs in this regard are greatly appreciated. > I am trying to understand why virtio based cpufrq does not work here? The VMM on host can process requests from guest VM like freq table, current frequency and setting the min_freq. I believe Virtio backend has mechanisms for acceleration (vhost) so that user space is not involved for every frequency request from the guest. It has advantages of (1) Hypervisor agnostic (virtio basically) (2) scheduler does not need additional input, the aggregated min_freq requests from all guest should be sufficient. > > [1] - https://lpc.events/event/16/contributions/1195/ > [2] - https://lpc.events/event/16/contributions/1195/attachments/970/1893/LPC%202022%20-%20VM%20DVFS.pdf > [3] - https://www.youtube.com/watch?v=hIg_5bg6opU > [4] - https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4208668 > [5] - https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4288027 > > David Dai (6): > sched/fair: Add util_guest for tasks > kvm: arm64: Add support for get_cur_cpufreq service > kvm: arm64: Add support for util_hint service > kvm: arm64: Add support for get_freqtbl service > dt-bindings: cpufreq: add bindings for virtual kvm cpufreq > cpufreq: add kvm-cpufreq driver > > .../bindings/cpufreq/cpufreq-virtual-kvm.yaml | 39 +++ > Documentation/virt/kvm/api.rst | 28 ++ > .../virt/kvm/arm/get_cur_cpufreq.rst | 21 ++ > Documentation/virt/kvm/arm/get_freqtbl.rst | 23 ++ > Documentation/virt/kvm/arm/index.rst | 3 + > Documentation/virt/kvm/arm/util_hint.rst | 22 ++ > arch/arm64/include/uapi/asm/kvm.h | 3 + > arch/arm64/kvm/arm.c | 3 + > arch/arm64/kvm/hypercalls.c | 60 +++++ > drivers/cpufreq/Kconfig | 13 + > drivers/cpufreq/Makefile | 1 + > drivers/cpufreq/kvm-cpufreq.c | 245 ++++++++++++++++++ > include/linux/arm-smccc.h | 21 ++ > include/linux/sched.h | 12 + > include/uapi/linux/kvm.h | 3 + > kernel/sched/core.c | 24 +- > kernel/sched/fair.c | 15 +- > tools/arch/arm64/include/uapi/asm/kvm.h | 3 + > 18 files changed, 536 insertions(+), 3 deletions(-) > create mode 100644 Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml > create mode 100644 Documentation/virt/kvm/arm/get_cur_cpufreq.rst > create mode 100644 Documentation/virt/kvm/arm/get_freqtbl.rst > create mode 100644 Documentation/virt/kvm/arm/util_hint.rst > create mode 100644 drivers/cpufreq/kvm-cpufreq.c Thanks, Pavan