From patchwork Sun Nov 14 14:57:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shivam Kumar X-Patchwork-Id: 12617905 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86455C433EF for ; Sun, 14 Nov 2021 14:57:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 618F861027 for ; Sun, 14 Nov 2021 14:57:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231831AbhKNPAj (ORCPT ); Sun, 14 Nov 2021 10:00:39 -0500 Received: from mx0a-002c1b01.pphosted.com ([148.163.151.68]:38484 "EHLO mx0a-002c1b01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229910AbhKNPAd (ORCPT ); Sun, 14 Nov 2021 10:00:33 -0500 Received: from pps.filterd (m0127837.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1AE6wp5X019791; Sun, 14 Nov 2021 06:57:37 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=proofpoint20171006; bh=XzH01JkvTnUv7vhjzETS65wF2D66bqxYgomLb0AN0ZI=; b=g5m+oCJVq0yF5UDShf5QpLVom2a+/PL6+auGhyHWIX9oE2QtLatpYLPrBthbWU5sSuaB rvQhfuQHn8vZjcTSx4jH4twdcuazBmWoIEfzCuFeQ7tBmipG+JkLe4YVypAwNXw1GDZ0 NExHzSCwRAAC3JAM3YZIYXILxv2U2EdlU0w1RxQPwtofE/DxXivc8TrGRfnb4ywNcc3Y 9U+pHWAstngOgCWUSbZQbkwqIgFTfN+xlqsGghinQusSzN1CD4+57GOR9FL4ZJdHGE3g vXp2u1xq1/dkBDODTIxs4NeKk6ruvFZSdPRud0PLJuYfEL1EgLZigA/qcCYXw6PATqM6 Gg== Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1anam02lp2043.outbound.protection.outlook.com [104.47.57.43]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 3caa5d1u41-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 14 Nov 2021 06:57:36 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=etULVI8wWjLeTQOs1YTeXbjIjyZtsqHJLdPQfQUpcNJo3tPSk4KCXu2KmkasSsiQUZvxKOk/dzyXiMs5Mi7XxJb/VBSJpAr7MKR2H8BE1KduAsDkqvjL6uZClGJTFMiTa8MxRbrDgCtQR7ghB9TQ4QpN5GJJ2ZCxzBlCyANUGP9mpSXsuIuT7oh4V2n9Pzg2++ntu1UAcPJPYtT1pkfasAOsuPineyphX7yw2UJSSoWKXPhUW6sKDqGNJAwfi5aZQ7dE81478aR2dlW0O/jBH6qWXl2FcRXQBbXHlpAcbEi5FBHMoBcXqbcFB16vjGxD3RTQFfts5J5ZuHsLJZXXrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XzH01JkvTnUv7vhjzETS65wF2D66bqxYgomLb0AN0ZI=; b=TwJxw1sM9Nz0XTJeGzhAXGHD/s1zpv9ZtU7aTJCjy2sybDgZ3GjoSHZP03nevKkhlnUDimJ01uV2Hbc+u9uj9vgoEbaO44NjcH/N9PxpP1ovEf+f71Iko2hC5qn7GChmeTZZoLGRqzbyQVl1Mtnd0H4r9JDivwidvp9i1l92IM5eqC5NE+f8jIlqKh1arQpqbDRbdxZcK9aVXlMO7M2sxcFOLT6eSamFuqPOrqlk29/TvJ485bCznH9LG/6IVPNx10CrYbVgSDqSU5cUc0nWQ7YMTLtg7jx1wvL3/wCpj3Nh+5ZtpVgWWI4oGDdD19kNoIXb8lHZ3dGnmoIWOQh2PA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none Received: from CO6PR02MB7555.namprd02.prod.outlook.com (2603:10b6:303:b3::20) by CO1PR02MB8618.namprd02.prod.outlook.com (2603:10b6:303:15d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.16; Sun, 14 Nov 2021 14:57:35 +0000 Received: from CO6PR02MB7555.namprd02.prod.outlook.com ([fe80::8d99:ba07:279:25c3]) by CO6PR02MB7555.namprd02.prod.outlook.com ([fe80::8d99:ba07:279:25c3%9]) with mapi id 15.20.4690.027; Sun, 14 Nov 2021 14:57:35 +0000 From: Shivam Kumar To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, Shivam Kumar , Anurag Madnawat , Shaju Abraham , Manish Mishra Subject: [PATCH 1/6] Define data structures for dirty quota migration. Date: Sun, 14 Nov 2021 14:57:16 +0000 Message-Id: <20211114145721.209219-2-shivam.kumar1@nutanix.com> X-Mailer: git-send-email 2.22.3 In-Reply-To: <20211114145721.209219-1-shivam.kumar1@nutanix.com> References: <20211114145721.209219-1-shivam.kumar1@nutanix.com> X-ClientProxiedBy: BYAPR08CA0001.namprd08.prod.outlook.com (2603:10b6:a03:100::14) To CO6PR02MB7555.namprd02.prod.outlook.com (2603:10b6:303:b3::20) MIME-Version: 1.0 Received: from shivam-kumar1.ubvm.nutanix.com (192.146.154.240) by BYAPR08CA0001.namprd08.prod.outlook.com (2603:10b6:a03:100::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.15 via Frontend Transport; Sun, 14 Nov 2021 14:57:35 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cefec033-22b5-4604-90b7-08d9a77f17f5 X-MS-TrafficTypeDiagnostic: CO1PR02MB8618: X-Microsoft-Antispam-PRVS: x-proofpoint-crosstenant: true X-MS-Oob-TLC-OOBClassifiers: OLM:2582; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jc3Rr+O0kATwgyKofnr90An4PUHd38FnZq5k94RSycJ2qeLtl6E63uDGZvZVz2i4ArvzK4KniPaNK4HGCBnKPYP/qI+yrl7JGn08i6z151w6Twz4Qvq9OYPHn0CVM4VZVYdxG0easJJlt3tqeP+BjL6SdkxXItL3IMSee8n85+lm4+eaNqtmJufYsnB1eib5JkMPWXMVE6UEVIAbv9/a4QI9Qbt/qJBgOIZbOHY6eFiV+h0c+HcfECVnQVyvMwnuq1s3GffCuMICKvR4gIRAqjhth2IkUEepeAxTt+IKf44mUUYEL7xTKdMOKZsKoOcIsyhQXKRQ4M95A9qVpV6+6gLVh2ZqG3zxiHhdCYsnZvhZ9Kz5K/K5e7cCcX1ZN3w3uthvkgbf4yUwPleriOg01wuZoY7BC9eDfxBQaSa/m1zgYVKT25Cp81HxdCN8enFz+wzjHIH9UFhw3Km0dinCXFixogIEs4MsE94OwK7JlA+rLD8BkMlHGl4U6S+83G91i9Jw0fq+cnMwyldfF+HeBdZviLdkXDJ+2rt8CybaBn/gFMfmrMxDH4rkBQoehCEA1SBl1dtrMp8WM7bCACQwLZAUd4414nJ7eXqpGzkvdtLKtSc+0cFhyttWU3tz89eJRgoInu5eqTViqTcjSjuCHKsCx3P2t8cDNNarmaStsYN5o3LAg0IgpP5+ceg+cgNk4A3PESyrgNZV1iHy0ECyVWGRTFmJcJwaRB7fhrLFgz8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO6PR02MB7555.namprd02.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(8676002)(38100700002)(38350700002)(7696005)(26005)(36756003)(15650500001)(66556008)(1076003)(6486002)(52116002)(5660300002)(186003)(2616005)(6916009)(2906002)(508600001)(8936002)(86362001)(66476007)(4326008)(66946007)(316002)(83380400001)(6666004)(54906003)(107886003)(956004)(14143004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ePm5Bpc7LAtB+VTzP6XdmH+8FR/kax9uuaVy2s0h2ZuV1oRrTY+dlGcPOKm3O+/KlAMrf1T64v1zpw+33yxWr4fcGjcqBE8jGcIjLW91dU+M4DOEFSpFDsI2exYsEjfn0sw7XPaWHc+Tg30JaQcmxbVxjxix9w1Uld1j1EZ9s7w7G8KdunE687EtaRB6vw3NcWfJcc8d03aI4WW96tSs1x1dyeAbXZZyD1xokivPSGb0AwM2aEIK/5mk/0+1ud+A7/nmhzwBvRSLWJP2a/dp8IXqPrsUna5R0ahVkruhVCYm/Sus7int3DF+P24saYcWQD+Z1cbPP7pb83bFnotbthr94UJ3smd9mPh4J3xn6OVL7G1OrG8SPsCjNccEgT4Rac6VLqpfeqnsKm+/fdjmnOkHi4e9HEQgqKTNmfB/gXNIWUoWBl8vAqkIMgJIQMbul9oAMpu+FtdPtHgeVJdwrdIduz0eXQwjM7qqZmi8n6W8y+M9RxB0z/I+Drk+Rzk6ZmbPFPBlmpH6KyO5OsX+DUizsNF+GwV+8kDnZSs+TQHlF2uhPa3JZ/eV6q+wNYf/xzt5XxODDmsv+DNA54AyJaI2Yxul/JWDXTvJJR2VM7AyFMjKKMeqKMmZfeiwnaIDXkbcIb7AEqLCkyPDsir8fmxAGXEm60sTYt7AxazredN03sZJ2j51AMZckD4D1W6lQ7agoYgefRUx49fL/S7exVPenDLOyGaUXvVWKEqoeamBUEaVjbLbUMYabTR+r10QnKXTDwq6zBE1uNm1BxzOis7otBNVB9gM1QKF+GajUbA4v1Smm2dkzn1gf+0Gcc/fcqKuWzlqr5uuBJlvHYeH2tRYRzWTf2NMNwYsn5JO5IYxCqUUNiPbL8v1NhKe5L+UTUGb+GDd4PfokdPGx1q6PgQMMoKDHWOLOd6BG33+UUoXrOtt+cODRETn+qI9/VYwcR9AjyEPAaXE8aIU6MvwW0XyMbJYhlfSLEy9OpfZiAk++BrKHqAzMmznIr3o0eCTcZsp/CtSX2OKaNYZPAPqT3B10CymBCy9jXx880+BlS8Ddohlo2HEOGvUNIHTJKqwEigN6zEAC+6PlXDEwT4xJhSRTVlypbldB2C1rkOF07ihzpMg00p+03t46RFKLW/pJsknqqZdChwcDQhPaBQzFlJBJcU79glprc2DFnFYykB6dFjbTtiLhBdiMGVPCDPsDXmAN5XwFJhLyV/NBuNNqRiOWuPdwiDibOui1d1A1wBdmQMyq7CUnZQkZIXdzlQkaWIXRpcOz7MXvqhvej5PcJ9EN+1MehPMIOuHskildXAwTdl2LiQNbPRo8OwRnebUeosxzHxolkkxfsNWO3D5reubC4BeTh7yShRu24iw0VXk41ATPqMiD38gLzwhnDG4MTP38o6xUNkrsIWLIbWEqzGX+vHp3ReFQ3To02NU3x8xUK+Ud+sgBxgJ2cgYlcsrxn/yR62KewqWwgP4G6P2inhUUYvaiL8DWdTb7WowdF+ySRR+LDetdLrPddvVc7CSRaG3IZtilpz8KQ/ynilZOiqZ9H7EV96gmeFdoqDft+PNG8RqykuNfIkiFTRLNm7CWPmK3UZN6M5PPrh+xFxPMA+b/Qv45ICmu2kG6tPJkcckhxhAsikTxB4pmRi2dH6FpuAk+nTRp6/M85GCPcexenzA4AXjID88sm2651kRpEs= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: cefec033-22b5-4604-90b7-08d9a77f17f5 X-MS-Exchange-CrossTenant-AuthSource: CO6PR02MB7555.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2021 14:57:35.6102 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Gp+sZtLy5nPpsMF6k06eW0wgApXc5Q88b0U5oStEdIRvPXZ2CCFBfEbbElYjiLFcq4jg4Jq+xM0gDZICvc+4RRSXBuFMjs2Hi5m81WzB6/8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR02MB8618 X-Proofpoint-ORIG-GUID: iucjZTQQ4Qm3KpZ_MfHIXblfO2Bt8yPN X-Proofpoint-GUID: iucjZTQQ4Qm3KpZ_MfHIXblfO2Bt8yPN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-11-14_02,2021-11-12_01,2020-04-07_01 X-Proofpoint-Spam-Reason: safe Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Define the data structures to be used on the KVM side: vCPUDirtyQuotaContext: stores the dirty quota context for individual vCPUs (shared between QEMU and KVM). dirty_counter: number of pages dirtied by the vCPU dirty_quota: limit on the number of pages the vCPU can dirty dirty_quota_migration_enabled: flag to see if migration is on or off. Co-developed-by: Anurag Madnawat Signed-off-by: Anurag Madnawat Signed-off-by: Shivam Kumar Signed-off-by: Shaju Abraham Signed-off-by: Manish Mishra --- include/linux/dirty_quota_migration.h | 17 +++++++++++++++++ include/linux/kvm_host.h | 3 +++ 2 files changed, 20 insertions(+) create mode 100644 include/linux/dirty_quota_migration.h diff --git a/include/linux/dirty_quota_migration.h b/include/linux/dirty_quota_migration.h new file mode 100644 index 000000000000..4f4e0d80a04d --- /dev/null +++ b/include/linux/dirty_quota_migration.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef DIRTY_QUOTA_MIGRATION_H +#define DIRTY_QUOTA_MIGRATION_H +#include + +/** + * vCPUDirtyQuotaContext: dirty quota context of a vCPU + * + * @dirty_counter: number of pages dirtied by the vCPU + * @dirty_quota: limit on the number of pages the vCPU can dirty + */ +struct vCPUDirtyQuotaContext { + u64 dirty_counter; + u64 dirty_quota; +}; + +#endif /* DIRTY_QUOTA_MIGRATION_H */ diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 9e0667e3723e..3cb6a43da01c 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -38,6 +38,7 @@ #include #include +#include #ifndef KVM_MAX_VCPU_IDS #define KVM_MAX_VCPU_IDS KVM_MAX_VCPUS @@ -360,6 +361,7 @@ struct kvm_vcpu { * it is a valid slot. */ int last_used_slot; + struct vCPUDirtyQuotaContext *vCPUdqctx; }; /* must be called with irqs disabled */ @@ -618,6 +620,7 @@ struct kvm { u32 dirty_ring_size; bool vm_bugged; bool vm_dead; + bool dirty_quota_migration_enabled; #ifdef CONFIG_HAVE_KVM_PM_NOTIFIER struct notifier_block pm_notifier; From patchwork Sun Nov 14 14:57:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shivam Kumar X-Patchwork-Id: 12617907 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DD5AC433FE for ; Sun, 14 Nov 2021 14:57:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6EDBB61073 for ; Sun, 14 Nov 2021 14:57:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233073AbhKNPAm (ORCPT ); Sun, 14 Nov 2021 10:00:42 -0500 Received: from mx0a-002c1b01.pphosted.com ([148.163.151.68]:20634 "EHLO mx0a-002c1b01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231264AbhKNPAj (ORCPT ); Sun, 14 Nov 2021 10:00:39 -0500 Received: from pps.filterd (m0127837.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1AE6wp5Y019791; Sun, 14 Nov 2021 06:57:43 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=proofpoint20171006; bh=Oam9lbGvRweP0t9ni5u8rbi7KrYiJhOkDfDEsdPNXGA=; b=MHkNG975cnou8pn6fAsuWdYL3fX7PaPSn7hyOnbAMVmcAXu1roRZU0dNL8sK3cehVXGT wtzYZCrZbHKekB6JNagTChbrcDO/4gssGabp+m7mqIrGOkbb/5qI7mxPUd7Gf8yFNch2 /nsFefnC6BOYDuCZKnSkwEyuLJAGLKCd+bcB3DBsQPGbd2mbWN45jRpH2QNrrnQSwhT7 JxfAQnJKeQXBJNwoUcyafNPd8LX7B6p1s7voNQB63xrD30oH8adKC0Fti4TUd700ezyZ Y+LxW+FE9+HvaCWP5DIgm8NxpMVaWwft+TVIpoESEfD5JdLeBiPiNUAf+jDAjdInu9hG 4Q== Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1anam02lp2049.outbound.protection.outlook.com [104.47.57.49]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 3caa5d1u42-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 14 Nov 2021 06:57:43 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KajH24Qfr1f75C0GZ5US7Hlc7zP6Sg7Buw2IcVYAXqY7E8Wd+L3xMBEzz3iY6RanTsKLxQvCdAPt3S02QPMH0/+Q8+lrcnrnumhEGDUCx92hGs5zNozmP/6PpeRKBy/GoOOJsbQ1lK0uo1AMKxVqn5VupUlHtJPqSXNIRrMlLnzuv/NoPyubuExfpjWzhFth8O8ChN3am48TJixszUmYkVwEMzvfoylhTciFs18aQh2wgl8fVBM2FzfzNZn4rll9fe28y1LwwpSlDxREKzUcZWroyIyDmr5hKliF5i6u7T8+GM6SYQKBN4r++TYpcQBrZmrN8s6ch26ecydok9Py5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Oam9lbGvRweP0t9ni5u8rbi7KrYiJhOkDfDEsdPNXGA=; b=K5k2dUT/tCggulpdA84HNToeQQWqgEpXs4gRXB7T6L/k7uxb7llOvfoL97ECQ/NzXfuMtqUJsTI0Q9i53sSI4as/D548qjXb6s+aL5Cies15KpsTJt1RlTYU1q9ff/2U02D6EFNiSI3prQGqt2IIfhdPk8hF5+RhxDoFFhQ7iLff5ouvcgSGaR2IZY3vQU8+VpYEoVdOf7jqaay1fa2ayqAwvOnidqrayJqSZf9y/1M4mKbSjuvzs5h99hdSbwy5udbY6DihMEhMnmmPtF8K3fXFxTG/VEp9TEzakCJ/gvwNHMCDadNowxhxtxVSNr9izmqKYm2/kNsIOJKKQ1TK6g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none Received: from CO6PR02MB7555.namprd02.prod.outlook.com (2603:10b6:303:b3::20) by CO1PR02MB8618.namprd02.prod.outlook.com (2603:10b6:303:15d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.16; Sun, 14 Nov 2021 14:57:42 +0000 Received: from CO6PR02MB7555.namprd02.prod.outlook.com ([fe80::8d99:ba07:279:25c3]) by CO6PR02MB7555.namprd02.prod.outlook.com ([fe80::8d99:ba07:279:25c3%9]) with mapi id 15.20.4690.027; Sun, 14 Nov 2021 14:57:42 +0000 From: Shivam Kumar To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, Shivam Kumar , Anurag Madnawat , Shaju Abraham , Manish Mishra Subject: [PATCH 2/6] Init dirty quota flag and allocate memory for vCPUdqctx. Date: Sun, 14 Nov 2021 14:57:17 +0000 Message-Id: <20211114145721.209219-3-shivam.kumar1@nutanix.com> X-Mailer: git-send-email 2.22.3 In-Reply-To: <20211114145721.209219-1-shivam.kumar1@nutanix.com> References: <20211114145721.209219-1-shivam.kumar1@nutanix.com> X-ClientProxiedBy: BYAPR08CA0001.namprd08.prod.outlook.com (2603:10b6:a03:100::14) To CO6PR02MB7555.namprd02.prod.outlook.com (2603:10b6:303:b3::20) MIME-Version: 1.0 Received: from shivam-kumar1.ubvm.nutanix.com (192.146.154.240) by BYAPR08CA0001.namprd08.prod.outlook.com (2603:10b6:a03:100::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.15 via Frontend Transport; Sun, 14 Nov 2021 14:57:41 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b4d2603a-cad9-44ac-f3b0-08d9a77f1be9 X-MS-TrafficTypeDiagnostic: CO1PR02MB8618: X-Microsoft-Antispam-PRVS: x-proofpoint-crosstenant: true X-MS-Oob-TLC-OOBClassifiers: OLM:326; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AIkETJu3OrmY3IlSCpoqSV6Rz5TMY4ko4UwYVPjeAN6g5ui/UChIA4PCSUaEqoiKdOHQzUif7ZPaTySBIswjHg4q8E1rma65fDJ7LoUb46sMdu2lHfe5Vj/3rtabj9T6s8ptxekkxaUDWcAZCoJlOqPeT727FbgX3P5nervgG8EkqY+ijwLkulh7vr1TSVuL/L1VqvLDmVFXvIrZJnKhgXTgOn2NyqU2/XNRLtHx+5gi8UPnd7bmdcdpR0G79AATx22Bj/aOc64ufNnfZmxGgmaTk+eECKSuYV+o5V74NI9tvAiyFnXLwE7QwtmwdAnwA9u+ZGkocODPBoNLNbxY9ArQuPbFOkOehlMP9sBf6nxYglmfqYQJsGgYIshcVRIRyJz/D754Jwi3Ov3N6Bb0YfDmLGc0TUKSl6nDVuAQaaK3UZL7S49TJE7Mdl/Y8LT+4FgrLo4w8iqqHnwhKyisWuyS91HtDPbipuV32FJhIQzHiUXoYInwASZIgvYVIWKV6VU0dfiWLuecu92tr1lXIN9tzdXBBs2rWrgC/RJXx6LCATBeEPM7cQetZ1ciYJEyOvHxvOO+QyIaHJ37tcbpb4XTaTjQ9fSTrtOKsnP8zHAiE+InO1UMMyilKE8kf9XvGpeUpNkfEQjygKcC1SRiIhQ8wDT9HFdBgXzIaQljtUeAIVDt+55F3SCfydJLsprnBPuYkTgP6DqfB25xFsxWGx7eWdv+SNCwDsHbXuaLNAA= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO6PR02MB7555.namprd02.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(8676002)(38100700002)(38350700002)(7696005)(26005)(36756003)(15650500001)(66556008)(1076003)(6486002)(52116002)(5660300002)(186003)(2616005)(6916009)(2906002)(508600001)(8936002)(86362001)(66476007)(4326008)(66946007)(316002)(83380400001)(6666004)(54906003)(107886003)(956004)(14143004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jb3PxGbH/lWOa94KavnwjkxW8bQMKbXBRvrms3vqNTr2s3fXaitV1CthNOd66UoWNk4oigjE4YOQqlI0F73jddn9RWxWb/3SWrJIEHNXVL7GDZX8zKEy+qg5CVsy70GFCbhQO67nUpThxFwXM/EXEjLCqLZ82DqhJEhrCtSpl24yr7O5RI0OdBttCAiC2X2YVGyR1k9GYhPyjK2m2v2W3s0zF1FIB8hIRPxhRV0iwZB6RUlf2X62NXGk2VaZbakYulgazn6cFBhgVQSc9ZHpQ/5JSrCoDXa541YHDsly+WxannThxmlSkdGiKVc1mOCebasl9j3oc43yK7EB0prKentozwdPgyAhF6Tnw/Y1gERZUkC6x/sjPPX7e+ua78XF87Txp+M/GFC3iDh+d5um5t8b6UEefF/XNgmchIsHmSCCVdIi+D+utZf14sOghPVk23ZOz0cKdrhANevsWK7PdSAEhFurfyKJjgkMO22i2bOY4xI5byThjTP6ciT8uby1QfwwdB9UDUNUF/lHGKB3GyeaTT7+okVRIIUwXle9hm/TC/frASzjcpXc+W15SW5cHw/WXBu3QvatIF8tqXWSKImnDrucWPobP7M2j+LXTLaJBDyuynxJ77D+MVpRK7/RLTyO6aboGLErH9hcgPKzszbEX5VQL4rekbUfxexTzhRe7mOgoSYVPvRLXAcJgpyFx8AkbcACqWSafV3iIBMxSsHg+EFLBLGtcz1r8q0JFMVeILh6lmxwl0flqifU7CTz/GlD4La6SMQIP1J71/nIjS4QDDkxYxwUk6RH52NCdiV0+kD+6uktTCGSDAtW+o6lICk0Ouv8FoAaxBLzclenrGkHtwAMcfB1UMOtez3YI9PY40rtQMnDGx8nZO6AufB0a366lqxtrnMh5U/OIohmXsBaDQ4sL6Z08w/3Y+UHqW/R7dOn62TbDqrPgDjt3DoRwDCXSOVzR0ocRK80oXdKbQb3vGU9vdzfZs7CsK4LM2upv6/FsOzgZMZPzJmPob7udQXKssv+I5IR5pKiIJ0NR1wz53RSErJMfMmlQq5njfj62/bJA0194DHdYx2iziw2Hr96Va1OB/Tx7WDonYE3eoMMk5Yu6jEskIgmurVrXDGJIKQ1BCbQ9uH08yTh8TDfVX1fZLHcvAQW7G7c1O3/nRC3nDNBF+qDLuQhGM/pThvzKnfzibAG9g5liNSF/obstYipU0IFPVNVA35L8zyb9HKVQ8qFTrBPVjdkubjEnE3meLpsBQwR15WVBfX8Gt02fvmRpgeh1TMDS3cTI22+VgqZR0/H4Bz1Gdb4qPcFzsQBCSm54N45HX6MfTJneLE//zLUAOrLU+TTHDkWg9fL4scYijRtqNdAociOSoMuvHA2JBH+Y0AHGDO1m2Yn8WwLZq7v4KpyGRVCkL/6fwCrVPDs2XCGsBG6dxVSLN1ttKuRp0PxDuoWj99Lpc1nG2ncaCs+EcNaiIUsHUL6oTgMRxFd8NkZeeREHBSyGTNUBEvUwCdyI2qTeA/dp0//ndQYC3oTK1wdfQFds2XgvjPGQaXefmc0NksYdFxaPqJG+fMs4eo4q3YY3icaGEMU/XpLVwK6skc0KbLv2IBoDyc8yzSDJST5OTh1XltKjVbDk3JxuUtVQj4ffEfB7Gtuj9qEfQDNwCXAxwCQLwNU2n/PSHQV4sY+ncbUP0PPy7+jOMU= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: b4d2603a-cad9-44ac-f3b0-08d9a77f1be9 X-MS-Exchange-CrossTenant-AuthSource: CO6PR02MB7555.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2021 14:57:42.2181 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: r1GOnYbtXPhWD4JOWSU5xkMNk16el/grYaeJXxm5g4q92zKARbgvaiByDEovXIiR1XsuX3wCW7NEnHx69Ra0LOzgZ3mSOsZ+f0PRixSUzD4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR02MB8618 X-Proofpoint-ORIG-GUID: w69JDDy4_9mkGHzWR1v0C5LgCL0k2xBN X-Proofpoint-GUID: w69JDDy4_9mkGHzWR1v0C5LgCL0k2xBN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-11-14_02,2021-11-12_01,2020-04-07_01 X-Proofpoint-Spam-Reason: safe Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org When the VM is created, we initialize the flag to track the start of a dirty quota migration as false. It is set to true when the dirty quota migration starts. When a vCPU is created, we allocate memory for the dirty quota context of the vCPU. This dirty quota context is mmaped to the userspace when a dirty quota migration starts. Co-developed-by: Anurag Madnawat Signed-off-by: Anurag Madnawat Signed-off-by: Shivam Kumar Signed-off-by: Shaju Abraham Signed-off-by: Manish Mishra --- arch/x86/include/uapi/asm/kvm.h | 1 + arch/x86/kvm/Makefile | 3 ++- include/linux/dirty_quota_migration.h | 16 ++++++++++++++++ include/uapi/linux/kvm.h | 9 +++++++++ virt/kvm/dirty_quota_migration.c | 14 ++++++++++++++ virt/kvm/kvm_main.c | 8 ++++++++ 6 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 virt/kvm/dirty_quota_migration.c diff --git a/arch/x86/include/uapi/asm/kvm.h b/arch/x86/include/uapi/asm/kvm.h index 5a776a08f78c..c4270dd9219b 100644 --- a/arch/x86/include/uapi/asm/kvm.h +++ b/arch/x86/include/uapi/asm/kvm.h @@ -13,6 +13,7 @@ #define KVM_PIO_PAGE_OFFSET 1 #define KVM_COALESCED_MMIO_PAGE_OFFSET 2 #define KVM_DIRTY_LOG_PAGE_OFFSET 64 +#define KVM_DIRTY_QUOTA_PAGE_OFFSET 64 #define DE_VECTOR 0 #define DB_VECTOR 1 diff --git a/arch/x86/kvm/Makefile b/arch/x86/kvm/Makefile index 75dfd27b6e8a..a26fc0c94a83 100644 --- a/arch/x86/kvm/Makefile +++ b/arch/x86/kvm/Makefile @@ -11,7 +11,8 @@ KVM := ../../../virt/kvm kvm-y += $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o \ $(KVM)/eventfd.o $(KVM)/irqchip.o $(KVM)/vfio.o \ - $(KVM)/dirty_ring.o $(KVM)/binary_stats.o + $(KVM)/dirty_ring.o $(KVM)/binary_stats.o \ + $(KVM)/dirty_quota_migration.o kvm-$(CONFIG_KVM_ASYNC_PF) += $(KVM)/async_pf.o kvm-y += x86.o emulate.o i8259.o irq.o lapic.o \ diff --git a/include/linux/dirty_quota_migration.h b/include/linux/dirty_quota_migration.h index 4f4e0d80a04d..8c12fa428436 100644 --- a/include/linux/dirty_quota_migration.h +++ b/include/linux/dirty_quota_migration.h @@ -14,4 +14,20 @@ struct vCPUDirtyQuotaContext { u64 dirty_quota; }; +#if (KVM_DIRTY_QUOTA_PAGE_OFFSET == 0) +/* + * If KVM_DIRTY_QUOTA_PAGE_OFFSET is not defined by the arch, exclude + * dirty_quota_migration.o by defining these nop functions for the arch. + */ +static inline int kvm_vcpu_dirty_quota_alloc(struct vCPUDirtyQuotaContext **vCPUdqctx) +{ + return 0; +} + +#else /* KVM_DIRTY_QUOTA_PAGE_OFFSET == 0 */ + +int kvm_vcpu_dirty_quota_alloc(struct vCPUDirtyQuotaContext **vCPUdqctx); + +#endif /* KVM_DIRTY_QUOTA_PAGE_OFFSET == 0 */ + #endif /* DIRTY_QUOTA_MIGRATION_H */ diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index 1daa45268de2..647f7e1a04dc 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -1905,6 +1905,15 @@ struct kvm_hyperv_eventfd { #define KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE (1 << 0) #define KVM_DIRTY_LOG_INITIALLY_SET (1 << 1) +/* + * KVM_DIRTY_QUOTA_PAGE_OFFSET will be defined, and set to the + * starting page offset of dirty quota context structure, by the + * arch implementing dirty quota migration. + */ +#ifndef KVM_DIRTY_QUOTA_PAGE_OFFSET +#define KVM_DIRTY_QUOTA_PAGE_OFFSET 0 +#endif + /* * Arch needs to define the macro after implementing the dirty ring * feature. KVM_DIRTY_LOG_PAGE_OFFSET should be defined as the diff --git a/virt/kvm/dirty_quota_migration.c b/virt/kvm/dirty_quota_migration.c new file mode 100644 index 000000000000..262f071aac0c --- /dev/null +++ b/virt/kvm/dirty_quota_migration.c @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include +#include +#include + +int kvm_vcpu_dirty_quota_alloc(struct vCPUDirtyQuotaContext **vCPUdqctx) +{ + u64 size = sizeof(struct vCPUDirtyQuotaContext); + *vCPUdqctx = vmalloc(size); + if (!(*vCPUdqctx)) + return -ENOMEM; + memset((*vCPUdqctx), 0, size); + return 0; +} diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index d31724500501..5626ae1b92ce 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -66,6 +66,7 @@ #include #include +#include /* Worst case buffer size needed for holding an integer. */ #define ITOA_MAX_LEN 12 @@ -1079,6 +1080,7 @@ static struct kvm *kvm_create_vm(unsigned long type) } kvm->max_halt_poll_ns = halt_poll_ns; + kvm->dirty_quota_migration_enabled = false; r = kvm_arch_init_vm(kvm, type); if (r) @@ -3638,6 +3640,12 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id) goto arch_vcpu_destroy; } + if (KVM_DIRTY_QUOTA_PAGE_OFFSET) { + r = kvm_vcpu_dirty_quota_alloc(&vcpu->vCPUdqctx); + if (r) + goto arch_vcpu_destroy; + } + mutex_lock(&kvm->lock); if (kvm_get_vcpu_by_id(kvm, id)) { r = -EEXIST; From patchwork Sun Nov 14 14:57:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shivam Kumar X-Patchwork-Id: 12617909 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 802B1C433F5 for ; Sun, 14 Nov 2021 14:57:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 629A161073 for ; Sun, 14 Nov 2021 14:57:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234703AbhKNPAr (ORCPT ); Sun, 14 Nov 2021 10:00:47 -0500 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]:2544 "EHLO mx0b-002c1b01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231264AbhKNPAo (ORCPT ); Sun, 14 Nov 2021 10:00:44 -0500 Received: from pps.filterd (m0127844.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1AECuxJV022116; Sun, 14 Nov 2021 06:57:49 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=proofpoint20171006; bh=dXyByt2g8ErNM06zgs4JxmFUlLxtf//NQ8921p5QPq8=; b=UcapppDEHr+eLqx1HOflYEOdeeFeTbv92QNgq8LcVg0SOoHzaK2yTWL7uEwRyppGdWgl LtjySMMKGSPIwGckAvbv8tVdJGeziLfr5TUVgc6jdAjJJVyw3OG9Cyj5sp4ohgip8pBE m8wG2LopFIjn+CrV+zRaPl2WTjAYqIohOe3Z6G6BT3GpZlmsFxQeN55syjCayhdx8OJB lA7sWMqgBYmJvqWEMsySHQ+kOqJP9F6r9zF0Tffc40EBeDY/eRZGCg5/sT5Nis+5790X Kj3nAP83J36JYH0FDXNNo9Qa565hB8+j3m88bok7PpAut6b+50jqtgbx/MPuk4hqNLgB ig== Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2105.outbound.protection.outlook.com [104.47.58.105]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 3cads5hkdu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 14 Nov 2021 06:57:49 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mIuRxA2l0JrWNQwGRjqHW0nS8+ZT7G8b7s8WPCFokmTCz/gmqlk08zSU3/eM3lPDF/PXy4ujILNFY/c7yEtHees+GUZ8Ru7Vs+hiHSDO/yiozWKnAgBM2tFtrHrttN4+P42FkufWoriWgmO3aAXUYjyLy8eO5vuWSPfJROjc6koBxMtsr7YpnY9NHFdTABmFWcZTkPwAKGlMif9vZ0rBx3jAyU1lnYU6NrnIG1Y+zh3LZAYLGhl4KY76wLfaYeE0kO1yoJATo1R1ICA/G3vsAX+mv+LyLt6FrFDfYKo1girJZ3C8IqSOOsjPzMk9fY+E1gUysCvOeJth8+a1Zncl7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dXyByt2g8ErNM06zgs4JxmFUlLxtf//NQ8921p5QPq8=; b=jsUPUEDhJ3hx34J9dx9yAmt4dm9G29ktVis3UcT7Z/vWl2s3QftCqM54QE9Y/hPMFm+dhLTrlF+R/aFqAtlDrfJw1Z/qX70uetyGV9Yj36p1uU2154KMkbQKhEJr+kMLzZYwxkh/Kdx0JHJx+6tqbgNRPjiqmi/jcDOfH/1NmsffqnRj0YHQG5W2CONn8iYpONbH47cxJCLWTlgaIqVHk4oPZMSs74MOInqU7W58Xvos5aTB0WqMM/SQktH69wJjLRoOirnvyJpYDVUk5jyROkTvwOzwW9PsoRaskKCJHQ6SB4UtHqCZDDQLNx5Ugoh7ftE1jwArTDtBrB0EkJzaIQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=nutanix.com; Received: from CO6PR02MB7555.namprd02.prod.outlook.com (2603:10b6:303:b3::20) by MWHPR02MB2528.namprd02.prod.outlook.com (2603:10b6:300:40::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.13; Sun, 14 Nov 2021 14:57:47 +0000 Received: from CO6PR02MB7555.namprd02.prod.outlook.com ([fe80::8d99:ba07:279:25c3]) by CO6PR02MB7555.namprd02.prod.outlook.com ([fe80::8d99:ba07:279:25c3%9]) with mapi id 15.20.4690.027; Sun, 14 Nov 2021 14:57:47 +0000 From: Shivam Kumar To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, Shivam Kumar , Anurag Madnawat , Shaju Abraham , Manish Mishra Subject: [PATCH 3/6] Add KVM_CAP_DIRTY_QUOTA_MIGRATION and handle vCPU page faults. Date: Sun, 14 Nov 2021 14:57:18 +0000 Message-Id: <20211114145721.209219-4-shivam.kumar1@nutanix.com> X-Mailer: git-send-email 2.22.3 In-Reply-To: <20211114145721.209219-1-shivam.kumar1@nutanix.com> References: <20211114145721.209219-1-shivam.kumar1@nutanix.com> X-ClientProxiedBy: BYAPR08CA0001.namprd08.prod.outlook.com (2603:10b6:a03:100::14) To CO6PR02MB7555.namprd02.prod.outlook.com (2603:10b6:303:b3::20) MIME-Version: 1.0 Received: from shivam-kumar1.ubvm.nutanix.com (192.146.154.240) by BYAPR08CA0001.namprd08.prod.outlook.com (2603:10b6:a03:100::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.15 via Frontend Transport; Sun, 14 Nov 2021 14:57:46 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 58861d44-7bab-4fa6-adfb-08d9a77f1eb8 X-MS-TrafficTypeDiagnostic: MWHPR02MB2528: X-Microsoft-Antispam-PRVS: x-proofpoint-crosstenant: true X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6tLTpBEjH5vihOlyAShCPrb3wXfukAAH7ejXuA3mVzR1v3B1CfuwQD+X33uOng6t8s8kYhjEFt6C5VBDct+jHOUtMCWUYRzrT3xgcpA378MSfwnMumJ+nvGf39fJxu6C5d7mRrlWK0uJ1UH2ZYQxc5GOaXKFrM3/aplUmgEv/6eddCRa3+WEFXsnWj8MXX7C7cBHYVCKh1PA7fH02R8nO/LHwrQJAx5f4dEX7ODJvpvTVInEYPTmmgS7ewGZWpQnT99OyzexT6rNuwyTXy4L1BVbQtrEFuIs09W2AI4ErFx2WPG07Q6vdOM6+QZQUxO8TT7QIlQlw1h3MNsoZS+kUqAX8cOKxl9G9YAyBnzvV7D52xWh5h3rFok3bZbmZ0E/phchzA9z0ElvSipw6mRseU+nQFjwVP5rq+0Y25z3v5buKT05l7ADUOwtaOErx3UqUphRoXjAl3SXWHN0Wi2p8mqeubumDZiracGCMVe02H2/rZ5dRXdMhrg3WINYBdmVBo0RsZtdaUnEeSkPjW89JkiqlEon1hFwIYMWaPaGxQjaILC0xmW2bjFHFg/2ctgW8A6WFhFrIuxP6PuW/cyTBq2A99IXgDnYSqiGV+pValq/cejnzHK657GinOUd+mFFk4+8vyUsv7edpLxyyUplcNaQtmzu5W3Li/5XSUONxkcMTV4fGrIjardxuNVbTO7tcDNIhbS4GOKs4Pri6pWgh24ym4H3CaK1Qf+yBq9vSAw= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO6PR02MB7555.namprd02.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(2906002)(66946007)(6666004)(6486002)(316002)(26005)(38100700002)(107886003)(1076003)(186003)(6916009)(83380400001)(956004)(36756003)(66476007)(38350700002)(508600001)(86362001)(2616005)(8676002)(8936002)(5660300002)(7696005)(52116002)(66556008)(54906003)(4326008)(14143004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /MVlLWXLNPDwX0aibVPORORBXsRK4JSez4G9w2daHfYOSwD+31NhL+2foy8S7QU2IjYs4JIFJqifJRZtFKyg4+ocRQKOFQ07H/hcgTHSP1RImIR+M3v26lK6zbemnt9SDKCwxz4Fs2f/pC+3YqTD2LI2vV/MetXgmNRyN1Gd0MJAVdOo6ShPkyO2KB2+EanVVcqRNp92hVjdquhaES2fcEBe6ppw4XlxYEaVZJd1KdEkyeQgLz0wq7PTzxSwNaSgRsOXu6zXE1oPw2pp566vPQgDSPIzs0FrvNEhHBkKOY78+Ddt9CG8LntSRjWdY5cpZaYcsr4JOIrG2e0hStHO6LFQKIECSKWzXsbf5c/neKwvmMIvep0L1ghRF7Pwl5KzU9P1mwMqVL8XlOrymtDHGMruj3rhaPFjsmSvHqMpkBViULaJU83lRmCmW+69leLcVjSeuMI7nW7MLPT2AMaf6IQR+oadb7V/2u/ezroN0BoVRcuv38gUZdvMFLdNJFeiWNQ8WpXZ6FrJD2HjRs0O6V3y+mKfTQN4gOTAqwok2VLH/C8MuUMzpeO/Jx+HvYPTqYb8zhhKSWIShQhcSdkQ72wl9vUfGkFbLWZ83QnOq2BP4sgACvso2sOWJvn4OIlO0hZXZNhhnw0SCBzIw/gu1yYp7hhiVUSLgNvNQoiHWDJwlr048t2XrUJGjx2d07WIE30U2TYnX5OnGD2FTij9quxZgG5dUphgI4esLn9JChVg2PYfiNxCkA36ifasm0rq4TJ/8JksXdrdIpuxsSGIngi2vly8iWA1TCnagNEaPeVItXxGw1sQ3e63lnbvGu5fb/T5xS5JOgSXppWzi0SwYRgcsm/8kVvGPROduAqBUubTh3MNgcnWQrKChX2m4vHtkS10fTcLP9YiSjqPyJxEz7DESWNqr8mS7l5fQX6zcaWrrAf7/8jrxkd78cGXoJRdpuuL9Y1wF3U0EQwFuNClLwwtj3cTMUIWffOv9Xtu5iXzsVuc+58gSwIXtGZbQrWWuY2pG1zO+lPIcVP8vxI6iPPoMddhXSr8kOeCC3jHK96ttNq90XxHzzJVn3nbGxbEfR0c/1y6Vr7/Q38iONDlu3M74Kbs4ukkuROgZ5dl/yk9/36pjmlbYNv4qilg8IJuf900TPOx5DaMkggdkdlm9ieUgrOEoLYMjMNTys9hXHuwPaCBqOU5BLn3AnVIG2UdwSNaYIK6t+mDyESE70uDV5Xg94q3lvk6ynRGZM55u4qmfUQpEVq9QXSlqXJfKapJF582TRZMAJt/KARt2Hqu5EPgH1y1rL58yoJ6ABLb9M3pfiTJVJ4nKhyNLZTLB33GWRUiiYNKsh8SXOYcNs1nXJ+8eidIWU8GvQK+yztAhFGvZieIuywAvzqw2T4KhSj0FxUOXeXm4eZelWMztuVOh8eXzn90eUWnRyYpGYXOELHMtpYkTHyY3EE0SZcIE/gbShC0JdjG1RsM/+SEFLiDnt4FXOtCoVdvn5THMtUoQ3wE14T0evMw3idqjctvNRTJIkeg7S34Veczjhhu7xBa+ayuIUrXRVqmeUr4nxgzuWjiysbTENk2l8De/vaQVe4BdE8ElxWZlmYDg42mokMWZ1l8290KotN79OUJqfpnofMYntf4PiUhZwu3HGdzq5mwprErCfqufzEw1K7BEIuMye2HMR+QdXc+RHYYOvRjfHI= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 58861d44-7bab-4fa6-adfb-08d9a77f1eb8 X-MS-Exchange-CrossTenant-AuthSource: CO6PR02MB7555.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2021 14:57:46.9970 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3NZQ6m0uC6wCRGym3TSjbtZ6fyyKm55g0q9ly1gqt8aYT4A2RapwEOCTkV5LX8IIFqfYHwmJ2o3KRZEC5Fg0s4C0OpTucR3lBVRoEygw4p0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR02MB2528 X-Proofpoint-GUID: ZKskdNqOXyVLuFzjMU0E-WHk7WZHHak8 X-Proofpoint-ORIG-GUID: ZKskdNqOXyVLuFzjMU0E-WHk7WZHHak8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-11-14_02,2021-11-12_01,2020-04-07_01 X-Proofpoint-Spam-Reason: safe Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org When a dirty quota migration is initiated from QEMU side, the following things happen: 1. An mmap ioctl is called for each vCPU to mmap the dirty quota context. This results into vCPU page fault which needs to be handled. 2. An ioctl to start dirty quota migration is called from QEMU and must be handled. This happens once QEMU is ready to start the migration. Co-developed-by: Anurag Madnawat Signed-off-by: Anurag Madnawat Signed-off-by: Shivam Kumar Signed-off-by: Shaju Abraham Signed-off-by: Manish Mishra --- Documentation/virt/kvm/api.rst | 39 +++++++++++++++++++++++++++ include/linux/dirty_quota_migration.h | 8 ++++++ include/uapi/linux/kvm.h | 1 + virt/kvm/dirty_quota_migration.c | 6 +++++ virt/kvm/kvm_main.c | 37 +++++++++++++++++++++++++ 5 files changed, 91 insertions(+) diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst index aeeb071c7688..6679bceee649 100644 --- a/Documentation/virt/kvm/api.rst +++ b/Documentation/virt/kvm/api.rst @@ -277,6 +277,10 @@ the VCPU file descriptor can be mmap-ed, including: KVM_DIRTY_LOG_PAGE_OFFSET * PAGE_SIZE. For more information on KVM_CAP_DIRTY_LOG_RING, see section 8.3. +- if KVM_CAP_DIRTY_QUOTA_MIGRATION is available, a number of pages at + KVM_DIRTY_QUOTA_PAGE_OFFSET * PAGE_SIZE. For more information on + KVM_CAP_DIRTY_QUOTA_MIGRATION, see section 8.35. + 4.6 KVM_SET_MEMORY_REGION ------------------------- @@ -7484,3 +7488,38 @@ The argument to KVM_ENABLE_CAP is also a bitmask, and must be a subset of the result of KVM_CHECK_EXTENSION. KVM will forward to userspace the hypercalls whose corresponding bit is in the argument, and return ENOSYS for the others. + +8.35 KVM_CAP_DIRTY_QUOTA_MIGRATION +--------------------------- + +:Architectures: x86 +:Parameters: args[0] - boolean value specifying whether to enable or +disable dirty quota migration (true and false respectively) + +With dirty quota migration, memory dirtying is throttled by setting a +limit on the number of pages a vCPU can dirty in given fixed microscopic +size time intervals. This limit depends on the network throughput +calculated over the last few intervals so as to throttle the vCPUs based +on available network bandwidth. We are referring to this limit as the +"dirty quota" of a vCPU and the fixed size intervals as the "dirty quota +intervals". + +vCPUDirtyQuotaContext keeps the dirty quota context for each vCPU. It +keeps the number of pages the vCPU has dirtied (dirty_counter) in the +ongoing dirty quota interval and the maximum number of dirties allowed for +the vCPU (dirty_quota) in the ongoing dirty quota interval. + + struct vCPUDirtyQuotaContext { + u64 dirty_counter; + u64 dirty_quota; + }; + +The flag dirty_quota_migration_enabled determines whether dirty quota- +based throttling is enabled for an ongoing migration or not. + +When the guest tries to dirty a page, it leads to a vmexit as each page +is write-protected. In the vmexit path, we increment the dirty_counter +for the corresponding vCPU. Then, we check if the vCPU has exceeded its +quota. If yes, we exit to userspace with a new exit reason +KVM_EXIT_DIRTY_QUOTA_FULL. This "quota full" event is further handled on +the userspace side. diff --git a/include/linux/dirty_quota_migration.h b/include/linux/dirty_quota_migration.h index 8c12fa428436..b6c6f5f896dd 100644 --- a/include/linux/dirty_quota_migration.h +++ b/include/linux/dirty_quota_migration.h @@ -24,9 +24,17 @@ static inline int kvm_vcpu_dirty_quota_alloc(struct vCPUDirtyQuotaContext **vCPU return 0; } +static inline struct page *kvm_dirty_quota_context_get_page( + struct vCPUDirtyQuotaContext *vCPUdqctx, u32 offset) +{ + return NULL; +} + #else /* KVM_DIRTY_QUOTA_PAGE_OFFSET == 0 */ int kvm_vcpu_dirty_quota_alloc(struct vCPUDirtyQuotaContext **vCPUdqctx); +struct page *kvm_dirty_quota_context_get_page( + struct vCPUDirtyQuotaContext *vCPUdqctx, u32 offset); #endif /* KVM_DIRTY_QUOTA_PAGE_OFFSET == 0 */ diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index 647f7e1a04dc..a6785644bf47 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -1131,6 +1131,7 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_EXIT_ON_EMULATION_FAILURE 204 #define KVM_CAP_ARM_MTE 205 #define KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM 206 +#define KVM_CAP_DIRTY_QUOTA_MIGRATION 207 #ifdef KVM_CAP_IRQ_ROUTING diff --git a/virt/kvm/dirty_quota_migration.c b/virt/kvm/dirty_quota_migration.c index 262f071aac0c..7e9ace760939 100644 --- a/virt/kvm/dirty_quota_migration.c +++ b/virt/kvm/dirty_quota_migration.c @@ -12,3 +12,9 @@ int kvm_vcpu_dirty_quota_alloc(struct vCPUDirtyQuotaContext **vCPUdqctx) memset((*vCPUdqctx), 0, size); return 0; } + +struct page *kvm_dirty_quota_context_get_page( + struct vCPUDirtyQuotaContext *vCPUdqctx, u32 offset) +{ + return vmalloc_to_page((void *)vCPUdqctx + offset * PAGE_SIZE); +} diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 5626ae1b92ce..1564d3a3f608 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -3519,6 +3519,9 @@ static vm_fault_t kvm_vcpu_fault(struct vm_fault *vmf) page = kvm_dirty_ring_get_page( &vcpu->dirty_ring, vmf->pgoff - KVM_DIRTY_LOG_PAGE_OFFSET); + else if (vmf->pgoff == KVM_DIRTY_QUOTA_PAGE_OFFSET) + page = kvm_dirty_quota_context_get_page(vcpu->vCPUdqctx, + vmf->pgoff - KVM_DIRTY_QUOTA_PAGE_OFFSET); else return kvm_arch_vcpu_fault(vcpu, vmf); get_page(page); @@ -4207,6 +4210,12 @@ static long kvm_vm_ioctl_check_extension_generic(struct kvm *kvm, long arg) #endif case KVM_CAP_BINARY_STATS_FD: return 1; + case KVM_CAP_DIRTY_QUOTA_MIGRATION: +#if KVM_DIRTY_QUOTA_PAGE_OFFSET > 0 + return 1; +#else + return 0; +#endif default: break; } @@ -4273,6 +4282,31 @@ static int kvm_vm_ioctl_reset_dirty_pages(struct kvm *kvm) return cleared; } +static int kvm_vm_ioctl_enable_dirty_quota_migration(struct kvm *kvm, + bool enabled) +{ + if (!KVM_DIRTY_LOG_PAGE_OFFSET) + return -EINVAL; + + /* + * For now, dirty quota migration works with dirty bitmap so don't + * enable it if dirty ring interface is enabled. In future, dirty + * quota migration may work with dirty ring interface was well. + */ + if (kvm->dirty_ring_size) + return -EINVAL; + + /* Return if no change */ + if (kvm->dirty_quota_migration_enabled == enabled) + return -EINVAL; + + mutex_lock(&kvm->lock); + kvm->dirty_quota_migration_enabled = enabled; + mutex_unlock(&kvm->lock); + + return 0; +} + int __attribute__((weak)) kvm_vm_ioctl_enable_cap(struct kvm *kvm, struct kvm_enable_cap *cap) { @@ -4305,6 +4339,9 @@ static int kvm_vm_ioctl_enable_cap_generic(struct kvm *kvm, } case KVM_CAP_DIRTY_LOG_RING: return kvm_vm_ioctl_enable_dirty_log_ring(kvm, cap->args[0]); + case KVM_CAP_DIRTY_QUOTA_MIGRATION: + return kvm_vm_ioctl_enable_dirty_quota_migration(kvm, + cap->args[0]); default: return kvm_vm_ioctl_enable_cap(kvm, cap); } From patchwork Sun Nov 14 14:57:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shivam Kumar X-Patchwork-Id: 12617911 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80E2AC433EF for ; Sun, 14 Nov 2021 14:58:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 619F661027 for ; Sun, 14 Nov 2021 14:58:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233498AbhKNPA6 (ORCPT ); Sun, 14 Nov 2021 10:00:58 -0500 Received: from mx0a-002c1b01.pphosted.com ([148.163.151.68]:21030 "EHLO mx0a-002c1b01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235295AbhKNPAz (ORCPT ); Sun, 14 Nov 2021 10:00:55 -0500 Received: from pps.filterd (m0127837.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1AE61cgs001895; Sun, 14 Nov 2021 06:58:00 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=proofpoint20171006; bh=h8f+j5oRz8nfBotukn+5wnJGEBjr2k7JGxLsTV5X4W4=; b=G2CfsB6E4W1eI6un9fezf895AASyc+UufsDEY48tK/6EjEABObw6B6Jfq8uK+74uSVH9 1on7qokXtxVAPVn4EDVk0MvdrM9JIpb24Tp58zGQd+28Txk/O17CAdh+5W238S+Kl8dt aaslAwbhyzkEWB4FfKBvlmk5039mZMNdAawjvGYE71TsnOLFV2a2YPUju8Naqc37jxls 8mQj/hKhTpKaK8wEKwDlt749UN9Enhc6bnEsJkSkIpz2HhTdHuyFrAVJAmBQ5WW6RDRu 0xXsn/Jr9WA5BztDUObsV0UvGWliR6SaT2us0Thk0vPzOk6/vldbTZy+hSXde2dpisID Qg== Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam08lp2171.outbound.protection.outlook.com [104.47.73.171]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 3caa5d1u4e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 14 Nov 2021 06:57:59 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I3wgUbuLWXhLsNQTS/jq/eGY8bM6OXnmzPZXzoK97BFnF0putuSm2ko3Hqhi7g533zljAkIaje/4hktR7Cx1VJQ3mNe3SaCE//tgbMBMSWO05IvC6BxHjLu9nNuvr+g8UjKiNA5nXzbyJyU6l4MxDcB0iZC6uVPpIcxNitCtKhL0CCb5JNOsEE6R1w8VfaaGFjkrAhGSLFRuVSgSXHrBhNFY419168oqMQFhdFD6kLzLWc8s/jL5q5Ilka25Y5LErINeKtGnqXYKrcm26rAGpxjR/1C74Kf/Px5yniWcuFsI1jOkSy70/8e3amkJIVGJ9WZ6sXY8JPt0Knw9tllkJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=h8f+j5oRz8nfBotukn+5wnJGEBjr2k7JGxLsTV5X4W4=; b=fFDyzgIM5juGe/tfCVahdvZMRSfKsVjlyp9PXUfVq2O5w56ah1C0DQwAHRkj7+tEwq9d5IO6pbrOeo19FOTrR9QFqoTdBK8oRrR4p9oie++1cwC9WNdykk1SsNM/KFO6EeN2ub7p00Mt2iFg7P2tvDNBwsFuBhN45hJCbO+IpyV31gHQ8VBf5m8cHrKZqnWC3Z6qaM8WFp1pEJWf5CYjJp2bvtNkcryD4XEa55eXH5GhzWjX5m0M7Z6ftgQ0iYPX8UXan57mdZV8t3vmv4bS2t8cshdzphAB1DVNkBEW9YzXOD0WdMbhZ2omYuODSSQKGUXeBEcOqHWKDOjuXNOpMw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=nutanix.com; Received: from CO6PR02MB7555.namprd02.prod.outlook.com (2603:10b6:303:b3::20) by MWHPR02MB2528.namprd02.prod.outlook.com (2603:10b6:300:40::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.13; Sun, 14 Nov 2021 14:57:58 +0000 Received: from CO6PR02MB7555.namprd02.prod.outlook.com ([fe80::8d99:ba07:279:25c3]) by CO6PR02MB7555.namprd02.prod.outlook.com ([fe80::8d99:ba07:279:25c3%9]) with mapi id 15.20.4690.027; Sun, 14 Nov 2021 14:57:58 +0000 From: Shivam Kumar To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, Shivam Kumar , Anurag Madnawat , Shaju Abraham , Manish Mishra Subject: [PATCH 4/6] Increment dirty counter for vmexit due to page write fault. Date: Sun, 14 Nov 2021 14:57:19 +0000 Message-Id: <20211114145721.209219-5-shivam.kumar1@nutanix.com> X-Mailer: git-send-email 2.22.3 In-Reply-To: <20211114145721.209219-1-shivam.kumar1@nutanix.com> References: <20211114145721.209219-1-shivam.kumar1@nutanix.com> X-ClientProxiedBy: BYAPR08CA0001.namprd08.prod.outlook.com (2603:10b6:a03:100::14) To CO6PR02MB7555.namprd02.prod.outlook.com (2603:10b6:303:b3::20) MIME-Version: 1.0 Received: from shivam-kumar1.ubvm.nutanix.com (192.146.154.240) by BYAPR08CA0001.namprd08.prod.outlook.com (2603:10b6:a03:100::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.15 via Frontend Transport; Sun, 14 Nov 2021 14:57:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fd6b9078-d749-423a-d0af-08d9a77f25bc X-MS-TrafficTypeDiagnostic: MWHPR02MB2528: X-Microsoft-Antispam-PRVS: x-proofpoint-crosstenant: true X-MS-Oob-TLC-OOBClassifiers: OLM:1728; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bNPtjPP5OYbBp2/c+Wi34oJrtKlgfaCFtpCLvLyNSYr9c2kMRM/VP86biwraWg3z/ochki7rFwDVHg01DawqU185AoPxfOeoaQTV92iNiNybUAThiypRp4My2QgNB7ro8utD3/OtAyFKu5Q/UekFvk8Dp5LZ+Mk1CH4hsmZdJ6NPWXP8tWLRSgQXb6dleGbwHFpnk8JdbZUDw1413p9iSrSWuYpi78C21D5Qrp5D65F5lHJ7udSMgvFZvpSaJuw3De7zqTj6GJLOYRWfuNp1R4fxPmJkaB37+16lw94235Fp52c2J++MjzW2eqTROuohnhDdEsC5Y6UhtXAcSUKJDFDzBPosTivDdn5D8f9qrnSYas6YwwaN0iSN9tWQyF/1McAPSRU8ADsC9/uzlZUNCegsJFLf0OEG4/akce5gZF+ji4P6KmWoZb9MIuuYh2tnmPPCBbDuqPNG8Avr7I54kaosJ9fBr4oH8w90k7cAgLhkXhP2tPUlZmk7MlWQBbOQ5hbHMTWs+rsTeonlRgiPyskaTM6sOZortkaLU9RvH+KhF+AmrQZY1H2/n/XR4m3IcED0EcBsLmUpw9P6a37b5yU53Fb+vKB6n2O6D+/iJhQVQ/WAxEovZLObLbPTo5sra0W6kiMqh5NzWVHMTqa678TBLdQmQdZArz7stIRy9eKHpeEUWS4M6fkgYC2KTrreoS1hJptFUyqZMqccqpUpCN1iBI/U/kG48qKvg4DLFTg= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO6PR02MB7555.namprd02.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(2906002)(66946007)(6666004)(6486002)(316002)(26005)(38100700002)(107886003)(1076003)(186003)(6916009)(83380400001)(956004)(36756003)(66476007)(38350700002)(508600001)(86362001)(2616005)(8676002)(8936002)(5660300002)(7696005)(52116002)(66556008)(54906003)(4326008)(14143004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: t1di9qPmc0HLwjYijK/8fADyKz3K4hoKBFVfcqDuZvrOnQ6AnMQcKKVJpndQAlZgXKt5+uQ1BcZD+ktB/OP/5z++ppuHRZsQLjM6PadlWMIMs9aXfvpXlpmrbTjwVh7UEjFx7G/EFtyjD2VlEdr2MJo5BJr7/tAmZSV2y6ZTR/p1khaElP6DDqOykJKEfSZ7yw3y6lVz2HCBRAqG+mD+6unIHFxC/6H3al5MNpxTlWhmYEZ+vnJlLKRjtGVINIr1U/q/CXmogIXahRGO+5DVXAHaR/Z0kVlLmnf1piZM1vUo3/5/9jwfIJTP+v/2LpVLHTwFEr6ZDjKkLmA7rZJPlQToasoTaa40NwIJ/AaJqaAyf1FLvIKsUFGdnsvjXC9glOn8lyOwkR3vREVi1oRrfmOkjXNmZygjwg0xVXN+NWZFsdnvMMGJLrNniiDoDsifsN7h+dEpTM49/LEdieX/FIMcggAHSkW4uXGJH6SOZEY4cPvHykjF+GBVeqo5rmiJvt9do/2GCDGguXjRrEnZw9x0mpSqmrYGwSXcYV4vc2Ge/ns1PPy7NqsM1vBa/lSK5qvfshd9AqDij45/9yrA63pnXRdxS6PSU//xadIODC9k+AtkfnzUt7s4AUPIJIoHof3CLlEn2Q1yT8LrevxEHHpEo23b2vXFJCPNIqIGUUmpYXUXs/bXxYL7u7giI3oPtW1nIQEcSvJqLn0AclLiZw+DRhmNerd0Ilqxv5AIBHKNkg9ZA+CkDfyutLi87TAklPIlOYG/fsoz3OLToxDdOdp0KTD3aZ91Vx+tiuuomUzBGaP6rEUneDVsIyZedgicxexNpyc/WQ9l+jBKFaAZ/jMicprLCSL/6NdhExonrET3MvKHbZcRNkNBhQpL9ghT8zeOVheiPHhRvmeRvQt1bFhIy6a7VMsGBja9qLkXgETlM5CFzQn5BKBtP7bn8DsNpZhZ7Bt9TXL+7mUYAAPcnKwJ8gLdaGGOfa82SYDp53n0iTMgMZ0v6FEbg3CKUcnDiwl4YoI6N9hnuOImGSBN0Y6Q2mVaiFIo8xGD75Hzxl5SMwfuzEX726lsQa/Y8I26sLswVYPd/p9ZEuVFGVamjIMyplyYU8mJYIKhQJdK+mpU9ucd7RFzOgirJpUo2if9sJZ+ZcARBfcO3mitIJ4/gW257Uh89rYjw0sPEoo/ggsV/a4nCdFbYWxcTjBmjJuQk4zdagsuFqm8J0xKR6RZtKxy20Mu5Gn8nnV1rxOB4ZgcYE3XouoPLBUPU+VKl1+VTc0FumkOsGQbCjJahPo5o6gUC1KTyfZbu0NfGwQLRduNjc7nWooDowIl/N4mZg4SlDGgCo/6RAae18A5D+pMkLB4T4V0mTCSTJ2RX762F2s0xCQg2zAAlmIGIQG/Xxt5ED+dbyQdYcK6rPgDU0SedheBVOvcMCviGBMzVfluEhFfwy3CavMuPjTdP5pFrIbL9+mhpA5Tx4oURvQkr4kh47OfOcex0vgiiwN5nIUIiqnJwzvu22KrA3T7hQEkkvQs//vc7YFjlidCCh0epD15s0pEnskMIRvYSB0x9L94+IgD3UH3TBu6gQiKIOfkYe539pf/87gOfVaxqm3XO3lW3neWBKDqf9nczLKihzXDNMxuM8aoRtoiv+fsG4/sodAAVH5kGDLkHdokBwvPS5Kf7ZnJ+ZXOHq4XQZDwSUeUrRA= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: fd6b9078-d749-423a-d0af-08d9a77f25bc X-MS-Exchange-CrossTenant-AuthSource: CO6PR02MB7555.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2021 14:57:58.7672 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 94YPlNvQHeXqJcmzrdnOO28zFQjFMZI0U4b3DPPOAznB+mSRjDf1bnyKWEk0XWLAvuvwDeFa23lhAmsS9kMOLjJxHzGsvfwPci4+rCQACO4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR02MB2528 X-Proofpoint-ORIG-GUID: QbmF9swSIyn62_aSgf7NrQbZpzyn4Pw0 X-Proofpoint-GUID: QbmF9swSIyn62_aSgf7NrQbZpzyn4Pw0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-11-14_02,2021-11-12_01,2020-04-07_01 X-Proofpoint-Spam-Reason: safe Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org For a page write fault or "page dirty", the dirty counter of the corresponding vCPU is incremented. Co-developed-by: Anurag Madnawat Signed-off-by: Anurag Madnawat Signed-off-by: Shivam Kumar Signed-off-by: Shaju Abraham Signed-off-by: Manish Mishra --- virt/kvm/kvm_main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 1564d3a3f608..55bf92cf9f4f 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -3091,8 +3091,15 @@ void mark_page_dirty_in_slot(struct kvm *kvm, if (kvm->dirty_ring_size) kvm_dirty_ring_push(kvm_dirty_ring_get(kvm), slot, rel_gfn); - else + else { + struct kvm_vcpu *vcpu = kvm_get_running_vcpu(); + + if (vcpu && vcpu->kvm->dirty_quota_migration_enabled && + vcpu->vCPUdqctx) + vcpu->vCPUdqctx->dirty_counter++; + set_bit_le(rel_gfn, memslot->dirty_bitmap); + } } } EXPORT_SYMBOL_GPL(mark_page_dirty_in_slot); From patchwork Sun Nov 14 14:57:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shivam Kumar X-Patchwork-Id: 12617915 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B20FC433F5 for ; Sun, 14 Nov 2021 14:58:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5D5EE61073 for ; Sun, 14 Nov 2021 14:58:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234584AbhKNPBM (ORCPT ); Sun, 14 Nov 2021 10:01:12 -0500 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]:31650 "EHLO mx0b-002c1b01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234572AbhKNPBE (ORCPT ); Sun, 14 Nov 2021 10:01:04 -0500 Received: from pps.filterd (m0127843.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1AED098c003466; Sun, 14 Nov 2021 06:58:09 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=proofpoint20171006; bh=4f/32J1fksnl8kA3s/LNoacgQ6HubFL5/MQAs0zjPeI=; b=wE6/Ul26KVdYbkooKJI5rADrooQuUun9JRbY798TMLgwMv6tmIdyGUKNouVVEFgE8NrM ex9lSvbVHnvg0QH9jZqSycUc6OdvJ3qdqK10hgZKt08FfckaydUKxiVUCeOCAnPj2g9/ WkmzAtebCIEpA2OygwlEvnBavwvUh3SgLvj0PfbjLAjkSSX/ru22ueq0N9uVCVDejEht ejgt3v5rgOd1LwQrjKYuGI9S6HSeyS1RbaGYqDH3nA/AV+VE0DVqSBQwt2d+7keLcp+b 3+drpYDxNeGZqaORFxGuMM/hCxjOaeeUXJud/dulJ775W4PjvgGEZftSRr9VMbzJ2ihp 4w== Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2109.outbound.protection.outlook.com [104.47.58.109]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 3cacbpsp4f-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 14 Nov 2021 06:58:08 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=erFSY0ycseONy6s4Cs8012dbY7rpN1eWnmhamtfogMuFR3eBwXBgiF5wsAWl2tsebQvc6jvUAAjy7vD9H3pqxZ6q+euTAbiHzJMMfDMts2CU48/Rf2Lfg27gINY1s3qfPRmWBnhhnv5/+D3Vk+hKFKrjPlHMbVUBidxKlfhFX+5ZhF5YZPv3EAZnav5XuaKYAmr5/UZc17i42VX8vBdttBMIWhwrvsEbKVvRYW4mqqjdTPHzGm6JuONSH31CPT3lK3sjtvYw8FBo4keJycNob8KMWYJFqsHv8gD9CEszKSnNR/vf73bABy34IvzvRJUtntcNYQuyNN42eXlhRCMXig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4f/32J1fksnl8kA3s/LNoacgQ6HubFL5/MQAs0zjPeI=; b=NaI8o2WVFSocsODsq4GMpfqCsyG8lPXu+/NDqL1k2fIx+Vuq0vYCaVzts0FUBTRlK6hJ5l0gikhbGQWmQYB2UWiPI5TIGeDeh8Ggscr6KFCTPLRyl0ntjhh08a0p0eTuoQmQwPJ/w9EiXgjaZUAXdqV4a20Rgqbjpxz6SFAhTM56IpVPOutOd7S07Z+8J4b/khN8KbOJ+QGaebkwzr2An2p1UJaTQzQxalv7kX1CFVy2j3iE3R2wttPjOX8uudfd1Sfu201CTTYEvf24ldkyY71RHoRoDkcL/qTcE+uFIPGYwMcWc5vs6D+zeAN3+uYT4Qq04r1rIyZwvDi1j6Cz1w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=nutanix.com; Received: from CO6PR02MB7555.namprd02.prod.outlook.com (2603:10b6:303:b3::20) by MWHPR02MB2528.namprd02.prod.outlook.com (2603:10b6:300:40::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.13; Sun, 14 Nov 2021 14:58:03 +0000 Received: from CO6PR02MB7555.namprd02.prod.outlook.com ([fe80::8d99:ba07:279:25c3]) by CO6PR02MB7555.namprd02.prod.outlook.com ([fe80::8d99:ba07:279:25c3%9]) with mapi id 15.20.4690.027; Sun, 14 Nov 2021 14:58:03 +0000 From: Shivam Kumar To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, Shivam Kumar , Anurag Madnawat , Shaju Abraham , Manish Mishra Subject: [PATCH 5/6] Exit to userspace when dirty quota is full. Date: Sun, 14 Nov 2021 14:57:20 +0000 Message-Id: <20211114145721.209219-6-shivam.kumar1@nutanix.com> X-Mailer: git-send-email 2.22.3 In-Reply-To: <20211114145721.209219-1-shivam.kumar1@nutanix.com> References: <20211114145721.209219-1-shivam.kumar1@nutanix.com> X-ClientProxiedBy: BYAPR08CA0001.namprd08.prod.outlook.com (2603:10b6:a03:100::14) To CO6PR02MB7555.namprd02.prod.outlook.com (2603:10b6:303:b3::20) MIME-Version: 1.0 Received: from shivam-kumar1.ubvm.nutanix.com (192.146.154.240) by BYAPR08CA0001.namprd08.prod.outlook.com (2603:10b6:a03:100::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.15 via Frontend Transport; Sun, 14 Nov 2021 14:58:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 088ea714-d081-479a-a73a-08d9a77f2870 X-MS-TrafficTypeDiagnostic: MWHPR02MB2528: X-Microsoft-Antispam-PRVS: x-proofpoint-crosstenant: true X-MS-Oob-TLC-OOBClassifiers: OLM:392; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hXJp//fvXanGwIqn8+0Dy9TkttjR8w3I/5w8okTdGc0mKVGKZ4NbzXx3XKz/YHYu9I/0cA5FS0jmo0yOMl/gg+kcXGX8V8MiYXwXoBG+5YMg8+CvCggiPXie4QQ2bSOFjaLv324gCi66EK0uWLcLnc+w6l/Qz4KaXBIEEsyBStL6T/38OIV5/CkiqBWILvL8UU9vDgjxMgi8okJFhGef21s9l7wXo6W2mfWCqTCEX5rdzvBwJmrufgxyi8MW7lBR+eqxRWCbIXl1oVQHeZ6Ze0dOeYKwZkCXk5Za+fRRsjCqqKqiwuBSUBsAEOR5sQh7ZjNbVPoEzSjdVC4nKMtsm7l+gRCFxCyxY2VT4yGj6ZnvLqZscSvynHvwwsWx3VTEkpNLKAiOAnaEBUorKUixQ/4tfy3Omkfy6zuEyLBeAj12x2BxH4fB4QqWcOhggpWnlE+IT5gEppXBss844oI74qL1hBODlvi7CdfBdyqhw7UCrMtb92J+QXrIEwoGrBOcRzsSmSA1g2mxPvtmu4+G7LBPlNxm1BVM3KugqB5y7DcE7iiVn9zLMMiJpFDWWCjykKhi52wXXc2VjxhqoWZ+ExIcEQfCu7kFSaXeThFPQwhNNiROwhwbIUZSf6PZScg2/yPOiUAmP3S4rFBi+FI+fdC/t816+EzlTWQyERySvV2SYRDnlEIblJ7igiRADeIaDxGgrie0IwXiacquJRZJDktQfS79kDngBJPhF+Apj8p9d9HVZzOmf6B5+Zn70bFY X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO6PR02MB7555.namprd02.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(2906002)(66946007)(6666004)(6486002)(316002)(26005)(38100700002)(107886003)(1076003)(186003)(6916009)(83380400001)(956004)(36756003)(66476007)(38350700002)(508600001)(86362001)(2616005)(8676002)(8936002)(5660300002)(7696005)(15650500001)(52116002)(66556008)(54906003)(4326008)(590914001)(14143004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PoZ5tTUYZfAfeADRwVpDltS2J0dc22Or1HaFF5Fw+d2kBeaOEbEogm3HC7CeSIVjag7RNz+F6F1x8TQS9EfPKVSxjA4I/8alHXA+CaHuKcik27SCFfU7s8g66vQoJ7mX6rFLPmRrMw+fGAT4hGvoKjHdxVfrneNkycahwR72r1lNiebqKfDNgHrrd88ZW0vwnhGVaWPuvYc8Lq+K1apMecXCybwEWOMKWFlhZMReTHyrdpmeSBNgn6JlQRRd+pH+zpRnpnqHH222JuXDdpq2zvgdNTqd3V5xHF5mFPYh7TBSdE34Et2C5Cs3EhJPB18052eioNsyb3NAkCW6Cjx/E1IRQ5/QJIPFaeZv9iDwPARXLwky+s7/wAy/nHCK9PG5LQ+JwWBP0dr3Bvj7bau876S5JErglp3L1rqVfjGVQhheHkXvB3DIYixa/3OaYqTJKvfYAezGSxxudMsLvVuElQJLfTQvqBQ4qVlyuyUnxPSHz4iuAWg+LYnsWoDvUIlSrzn3jxeEELYnNPUr8+J1NXJ8RmO8KsLdEf0DLEXyfeksq9zNBZsOIjTYgpWkt/qRXTMGPH1yZIJn40RbPywRIy9mY3sCYW3h14XJOev7oa4G39u9eqaqLgLHGhCFP12EoxZG2fUAQmyLxchdDu5DsrHf2sea40C1ZMBORyuAvaps8ThcDNX3nWy5z3bbArpvwjlYojx9Xxj0pAo5GpsRnS/AKBy9pVUIbl4jKt8NaV8rJfIIamJaEiYo72pFw91DdLqN0JDLsb48tGiF10sWwg4nxBLX4ZFk63SsgYBfslINgSguJi7ghumPMrhgO6qDAaSOAnWwS4q8LI3LiHwcjjgIx5l9CuVY9NrW0jHQERL64gLwXGeMX7IcGgxaijbgfgBwm0+w0CqQF+sht6Zwn7WPLtctlL6vPDvB4pUTXWmr1kU+xCksWFF2iBtj0iQeQwE+4mBDwjCXWule8djXM2y+OyjogZrHHEcbbAqZ/bUIvp83EwDqTpXhVQRL0/5cAIQ7eGjsoeV/a3nK5hS/oFiNZM2iw6qGmgOCkqMHQDrFLoEa35Xc98Wyha0dDyOFP1LxnH+E8SoOIAYTSUwmBMq0DEfcmglwfpMerwEFBJv2xkIF3Iv/jrPb0NgP14O4BZeKDmPwBlIeiXQhOWcibyBDYdnSCEhNs3cQ7rIgXRZTmQj/JKvMYT6W4Yzm7gQ55ecRHGsGfhB4FB8IiYmD1F+VFyYnFWQrwTfjEyuwVgjgPvc6BK1ORHM0FZCY7QbDpLOqIgArRyNRdKkwabA1T+YxdtHlV+kfbxV6YeAbZwDE6i5Ofj30mbj5rkbBlR82HonGsSUQ69Id9Cho7m5g/ski9dYrhIHxOBb3+1v6P3o1LVVl/niHvT+UUSi4DdnPL4oBkEMN81/aoshgWReWoKUKYHQ+13kJXOyWh360P1R/suElYUTVWlghlJ/r1E1MaxMm1ZZbwvPntfJpMqJNQxiORXDQA1+EyDx8UHK8uqxJDhOEawr/Ezvvy4RaSR2vjquAIvWB/n7DH/0yjwv16ESYQtKk0einmjWoJ9r0OdIN9d3yjcyL4EIKqS/O5GTmEOfLW5GSLCBpjluE8UgpCphDf0/eCqAbi0icmYzFwH5sjk/M/dxEVCxwf277Y8Anit8vZ/g+gbDtZFdmYrT11Z8kD3GJLW5Cg6wHZk2jpEk= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 088ea714-d081-479a-a73a-08d9a77f2870 X-MS-Exchange-CrossTenant-AuthSource: CO6PR02MB7555.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2021 14:58:03.2295 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: CTu8CrzdguwB/W7GqQUWyLLzGeIfu/2Z+0AGVxYJPeiOhtE5BR8KtjSZkRUXN5L9ur8j16Nzycm2I/l0tDreUSePWcRAEAs3QmDYgiUCoPg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR02MB2528 X-Proofpoint-ORIG-GUID: BbkvQ49lCnB737-UkV2YBNFJL5ufzWQ2 X-Proofpoint-GUID: BbkvQ49lCnB737-UkV2YBNFJL5ufzWQ2 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-11-14_02,2021-11-12_01,2020-04-07_01 X-Proofpoint-Spam-Reason: safe Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Whenever dirty quota is full (i.e. dirty counter equals dirty quota), control is passed to the QEMU side, through a KVM exit with the custom exit reason KVM_EXIT_DIRTY_QUOTA_FULL, to handle the dirty quota full event. Co-developed-by: Anurag Madnawat Signed-off-by: Anurag Madnawat Signed-off-by: Shivam Kumar Signed-off-by: Shaju Abraham Signed-off-by: Manish Mishra --- arch/x86/kvm/x86.c | 9 +++++++++ include/linux/dirty_quota_migration.h | 6 ++++++ include/uapi/linux/kvm.h | 1 + virt/kvm/dirty_quota_migration.c | 5 +++++ 4 files changed, 21 insertions(+) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index dc7eb5fddfd3..32fc7a6f8b86 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -59,6 +59,7 @@ #include #include #include +#include #include @@ -10028,6 +10029,14 @@ static int vcpu_run(struct kvm_vcpu *vcpu) return r; vcpu->srcu_idx = srcu_read_lock(&kvm->srcu); } + + /* check for dirty quota migration exit condition if it is enabled */ + if (vcpu->kvm->dirty_quota_migration_enabled && + is_dirty_quota_full(vcpu->vCPUdqctx)) { + vcpu->run->exit_reason = KVM_EXIT_DIRTY_QUOTA_FULL; + r = 0; + break; + } } srcu_read_unlock(&kvm->srcu, vcpu->srcu_idx); diff --git a/include/linux/dirty_quota_migration.h b/include/linux/dirty_quota_migration.h index b6c6f5f896dd..b9b3bedd9682 100644 --- a/include/linux/dirty_quota_migration.h +++ b/include/linux/dirty_quota_migration.h @@ -30,11 +30,17 @@ static inline struct page *kvm_dirty_quota_context_get_page( return NULL; } +static inline bool is_dirty_quota_full(struct vCPUDirtyQuotaContext *vCPUdqctx) +{ + return true; +} + #else /* KVM_DIRTY_QUOTA_PAGE_OFFSET == 0 */ int kvm_vcpu_dirty_quota_alloc(struct vCPUDirtyQuotaContext **vCPUdqctx); struct page *kvm_dirty_quota_context_get_page( struct vCPUDirtyQuotaContext *vCPUdqctx, u32 offset); +bool is_dirty_quota_full(struct vCPUDirtyQuotaContext *vCPUdqctx); #endif /* KVM_DIRTY_QUOTA_PAGE_OFFSET == 0 */ diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index a6785644bf47..6ba39a6015b0 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -270,6 +270,7 @@ struct kvm_xen_exit { #define KVM_EXIT_X86_BUS_LOCK 33 #define KVM_EXIT_XEN 34 #define KVM_EXIT_RISCV_SBI 35 +#define KVM_EXIT_DIRTY_QUOTA_FULL 36 /* For KVM_EXIT_INTERNAL_ERROR */ /* Emulate instruction failed. */ diff --git a/virt/kvm/dirty_quota_migration.c b/virt/kvm/dirty_quota_migration.c index 7e9ace760939..eeef19347af4 100644 --- a/virt/kvm/dirty_quota_migration.c +++ b/virt/kvm/dirty_quota_migration.c @@ -18,3 +18,8 @@ struct page *kvm_dirty_quota_context_get_page( { return vmalloc_to_page((void *)vCPUdqctx + offset * PAGE_SIZE); } + +bool is_dirty_quota_full(struct vCPUDirtyQuotaContext *vCPUdqctx) +{ + return (vCPUdqctx->dirty_counter >= vCPUdqctx->dirty_quota); +} From patchwork Sun Nov 14 14:57:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shivam Kumar X-Patchwork-Id: 12617913 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E6EBC433F5 for ; Sun, 14 Nov 2021 14:58:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5EFDB61075 for ; Sun, 14 Nov 2021 14:58:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235248AbhKNPBJ (ORCPT ); Sun, 14 Nov 2021 10:01:09 -0500 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]:9808 "EHLO mx0b-002c1b01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231264AbhKNPBD (ORCPT ); Sun, 14 Nov 2021 10:01:03 -0500 Received: from pps.filterd (m0127843.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1AED098b003466; Sun, 14 Nov 2021 06:58:08 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=proofpoint20171006; bh=sqxGsmfS8LmYdZhfO7AUXiDADVJ++CBE09c44YgkT+w=; b=jYevNvs2+6l/FhvMVsNNClrjbtQwMrxi/d2ehLMpAmym5yCxQXvKWMySi87SjmiVkuwz A8G6Lh9O4E4sx3py8PnpdlBgG1iws9VYTfcejPPP4QgNXv0ua99eDXA3si0pi/sFeoM9 J6mCcO8k6ivEhpt7zK1uXc+3XjEyeU0l0IpSch2LqG1ZOmDT0xhyybcAvTvqrMb5jeXS c9H0lKZgt9yfynOqV/GNwnSjGrkmx9ga55JffmAoe53lWD99gJX4s/6kXz6xAO6UF+AA hvpcWYs7NqMQZUY9P1w1N1HkHZyi+JbsDNP9+rntiaDY97CbrkeDkHo3rzH5j1wL3K20 cw== Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2109.outbound.protection.outlook.com [104.47.58.109]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 3cacbpsp4f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 14 Nov 2021 06:58:08 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SF/1Su90rLv8HPayHXdmcp0vnjY69htwvtEuGo+u2UweKDdttiMKNQ+39JSmIztelFt3FktrASJGUZe32Q3rZk6vWxQObuDFqsEkbDdKzZP8v8/c27mOsiRdzUi58tfmr0MwrKibQX0F4RVruSpXPaPGTbel9TBU1bO3WigB8rv5wtnRKhY+gaRpfKy7Z4trbyl3cg+z4DCkuQIKT67KdtbtkOw+8HdYDf2losK+XWPJpUubAZxLffeTC8v3ZdV231ZEBq9MdPua2tuZGrVqolPC0Y9woIphyuCFJN9hSIDP9pPWlTkw6olQSTihKLxr0OPry9CC4rD2W4OQ3sisQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sqxGsmfS8LmYdZhfO7AUXiDADVJ++CBE09c44YgkT+w=; b=X0y2LWkeLT/ZFz8TnU/PjfXrHG2BFwb4YA/D9zaSLuY+6lCUZtyS+jcEpPYq/yp+0H4QaIgRBJxy9LZ6+zVAXiNeT2sQpv+b/JQHv0ID18owrKlDTKBcmdweFZ0kavmgR0U4Fc+Nqf6vmeGFnmjnZnuGGDV+i2ST91zOw45q5coUFCTGBWyYszgGH+FLQUPNSKo9YR/lCyQj2KqQG5CFJPf5ZTU0CQCRf7f0R7P+RyWBV5Bizxx1HxAMyhzLUm/h38Rm6d3S9XRTtdYCKw30b0OmOKbve5oaB6zOUdZWhGqakNlHFL6C28Cm3aoRD/yshTjgY5cSjLZgMZKhz6Jl9w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=nutanix.com; Received: from CO6PR02MB7555.namprd02.prod.outlook.com (2603:10b6:303:b3::20) by MWHPR02MB2528.namprd02.prod.outlook.com (2603:10b6:300:40::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.13; Sun, 14 Nov 2021 14:58:06 +0000 Received: from CO6PR02MB7555.namprd02.prod.outlook.com ([fe80::8d99:ba07:279:25c3]) by CO6PR02MB7555.namprd02.prod.outlook.com ([fe80::8d99:ba07:279:25c3%9]) with mapi id 15.20.4690.027; Sun, 14 Nov 2021 14:58:06 +0000 From: Shivam Kumar To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, Shivam Kumar , Anurag Madnawat , Shaju Abraham , Manish Mishra Subject: [PATCH 6/6] Free vCPUdqctx memory on vCPU destroy. Date: Sun, 14 Nov 2021 14:57:21 +0000 Message-Id: <20211114145721.209219-7-shivam.kumar1@nutanix.com> X-Mailer: git-send-email 2.22.3 In-Reply-To: <20211114145721.209219-1-shivam.kumar1@nutanix.com> References: <20211114145721.209219-1-shivam.kumar1@nutanix.com> X-ClientProxiedBy: BYAPR08CA0001.namprd08.prod.outlook.com (2603:10b6:a03:100::14) To CO6PR02MB7555.namprd02.prod.outlook.com (2603:10b6:303:b3::20) MIME-Version: 1.0 Received: from shivam-kumar1.ubvm.nutanix.com (192.146.154.240) by BYAPR08CA0001.namprd08.prod.outlook.com (2603:10b6:a03:100::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.15 via Frontend Transport; Sun, 14 Nov 2021 14:58:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 96422351-0a3a-4d91-1573-08d9a77f2a52 X-MS-TrafficTypeDiagnostic: MWHPR02MB2528: X-Microsoft-Antispam-PRVS: x-proofpoint-crosstenant: true X-MS-Oob-TLC-OOBClassifiers: OLM:161; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jmXWCdxMIHC5WcfGt41sBdCzzjUexerHLcQbvBo/Wl8Q0wgqGy93VrTl4MFygvbjJ6YMQPznIKF8RwlmJFyxqsHWHudNC1SM94/Zs9H32My3nYgE4rs9jw4u5y3jwcacgKjkKW2ngQzzx10gnbO0vnPnY/mdKym2iLGeH1l3qiM6aCf1pKqfVQfpKu8/JxUvj6lQCCNTBazPW3UZU8tSCefL7hTCE4KT06r5iSv+q4ie134TV+JJq0LDk5UxbbInzmRHmOxhQUwBfIcBci4lrsC50O5kVShqExqzt9fmqsMsN44jO+gxJ0ox5aHfvtftUgOSP0QDzRpj4sWwPqw7IjyK2m9UcNPTWzLE/SmwO7yJ+pYE3jrgSUOVqg49BBzzPu6oAzIaC85N0HdrcUe5XlBdNquvBs4VPCq+R9SPhOj9mU4S1eSxFzwPf+TcSWes22wbtVCdCEiYptPZmNwCXm97xrgUf+R1VDPzsStivIgd4YDSJmMjW4EqIjFHuWFY1YkszXTT60Cyh9q0Woi57lcIRYbNadt5Lx5CTa3PcKO7gAQKitXjhxwp3ze+1oVBDWP+LYbKMxn8A2pLzJNIrEbaIIYtVfHeG5bwHaOP1jbQwQt7bfkPC4pjCqpOlbs6fiRa7kZkGAbMkbyvPsj0oHdiNrGlORtmK0eYzsxn7DPtQD0Zmn1X+/658yXjiH+MctVz9TK0GPJCcvpdM8p/jw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO6PR02MB7555.namprd02.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(2906002)(66946007)(6666004)(6486002)(316002)(26005)(38100700002)(107886003)(1076003)(186003)(6916009)(83380400001)(956004)(36756003)(66476007)(38350700002)(508600001)(86362001)(2616005)(8676002)(8936002)(5660300002)(7696005)(52116002)(66556008)(54906003)(4326008);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Hpsy1quWwxcO547P1Fkliv6oPQsrE4v3sA7zO4l22Jk6tQVi/WR0/6RH7QYtGklmRBdRRP5Ie5dek6P56oYVbUxPA/mG49l7cwn3PLXi7LFgmVfhAbD9UbyX0xOFpIRGNg25ys4M6pd8/hgHKyutpQ9d5jA2+fx4KBXLW490zUmv0MRsqUlpD9yDx0libP2SdRokyyST/AYuAJAm9TS2O3WuUfwjr6OdmpTq3YUJMMt/6XzTZ1DRliquJrDofifG5NdUaGpFrgyIflZbjw3rZhcMQnE862khJTdJT/KElKVsdig7osM306x9+UqV63FgzAIgoyFhcDlcncPSAsFFd3PxzqFRUHb8k7WFobxk94e8sQSd0ZGhQw/N+g94KApnKXOxCt1QQfLKisBW+ZhJ21zNwP5Qk3+75miTHnD1+U0p8Mje+YY7g7jea5SjzsRxvvU9+5gaFR7G8J+AILCRZ+epkC/M5+Sy2y3ezUJzes4gK1jKMbvqnYtVrKRX+Pvw0qOki4F0VkJ0G/MdHYYTgTWI3Q3pFNZoCXs6GqTy/d2xvOQwKiI5aEL60imtG+nh0Kpw/N6neJe8AGKU4eM1XTf90Eq3h5p2CSd53bXFhKxO7jYx8KnzxM0V065qcBL4q98kgVcyba3iME7HgNDokHOMFSaUUqRZjVeSbCYNMzh2zYkCIi8V+RIsDJ/gssdm44YURnFVAGOIcrFNHK6FsyKnqdRV9CH0/H2cD6sfmScTkqjXZCKafqmgeh0UlKJfZS4hnCzuglPZGrIy0bWKEkHBO2fIyB2o5ornKMXWsZZ7Jj37FB70wRBJueOhiOJS9+WlmkCpvEvPWiCtF9tbu73Iy8aNGK6yYpIWpXrq6uTBRxWW0FpASKShfUcOga2kJuw06Opnri0ZSUgauojTh0hubChJLdN38Xu3jm9bSLVvX9mpTGxBF5YRVU8QZ9WfdOBnAhoPjtIeN87VacNWzeP9xWWscBr925SZHO9m+DBjbDkZeKZwlh7kiEx4+6YCl8bGymQNGr6gY9n4mLHA1fbYh9fDhgytPq4htR/b9B/Aou3hXd1gSkUoR0rD93HQEbaAYKB1fVAo+L14GqYuw2xL82Xdp44LOUVdpx6HiVzExRo9U7pjsEsPgL1AvQPL7R6DW58BDsq5hhjQzpZvhUyp9vCirhEgwUb5WKjtVSHeNBzIGRK7oLaRPB44W8tDBD+Xpzj8FXbLNhMFVhHFPPPVaNBFt4RXg2keRyGlgR8x/Beg45SYv07FMNcxjdWv6oGQIzBdy3+lu0/UbhkXLMGT44C0ud/4ImGw3tCB+ormrWeI2+rNHHt81OVXgqtL3XWMfzmewZy0l7j920yTIIiXSPI6DFa0GVogcG9kHxR8/JiIWh0dxe/JWMkQCXEZB+3OPPiiAw4jC/woELuQoGw+mxRWSnM2qsDhtHKuKFfbWUszM2F2HxImxCnSFF9pLp9GWWY8z1L8sUc7OnNPlW0mJBCHTeMsoMwHlGg4SiEWCuRqQ4neSO3sb21qvJgtBOPEAfpzdKQG9Q9GYj4HoTsySRLbt0r6RnemiG1oqO4NqR5F5+W8mHMwFc91+yMRiRNWe3/i3I80Hw62VfqOsmfzgu2B4MQN5j4JkCE1JgCkIrzsSMpisqIIuPI1Ft2792gTQcHqmNLvTFYKX8OxQKEAhT8wry5Kt34sNpYM4+8= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 96422351-0a3a-4d91-1573-08d9a77f2a52 X-MS-Exchange-CrossTenant-AuthSource: CO6PR02MB7555.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2021 14:58:06.4294 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jrlj9Sn6CzQ/lXsKsm2ZQpvD6rrYU5yhD2mTzxxAtmx8+GQxlpWAYjaUQOImHtx7CkCVESgCpOguZTCsWglRLGVXfMwA2Bta58ZbchMn1Hk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR02MB2528 X-Proofpoint-ORIG-GUID: w_2AKNX-FR0m9i6N8kk7n__HZp8zPGlr X-Proofpoint-GUID: w_2AKNX-FR0m9i6N8kk7n__HZp8zPGlr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-11-14_02,2021-11-12_01,2020-04-07_01 X-Proofpoint-Spam-Reason: safe Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org When the vCPU is destroyed, we must free the space allocated to the dirty quota context for the vCPU. Co-developed-by: Anurag Madnawat Signed-off-by: Anurag Madnawat Signed-off-by: Shivam Kumar Signed-off-by: Shaju Abraham Signed-off-by: Manish Mishra --- include/linux/dirty_quota_migration.h | 5 +++++ virt/kvm/dirty_quota_migration.c | 6 ++++++ virt/kvm/kvm_main.c | 2 ++ 3 files changed, 13 insertions(+) diff --git a/include/linux/dirty_quota_migration.h b/include/linux/dirty_quota_migration.h index b9b3bedd9682..a31f333a37bc 100644 --- a/include/linux/dirty_quota_migration.h +++ b/include/linux/dirty_quota_migration.h @@ -35,12 +35,17 @@ static inline bool is_dirty_quota_full(struct vCPUDirtyQuotaContext *vCPUdqctx) return true; } +static inline void kvm_vcpu_dirty_quota_free(struct vCPUDirtyQuotaContext **vCPUdqctx) +{ +} + #else /* KVM_DIRTY_QUOTA_PAGE_OFFSET == 0 */ int kvm_vcpu_dirty_quota_alloc(struct vCPUDirtyQuotaContext **vCPUdqctx); struct page *kvm_dirty_quota_context_get_page( struct vCPUDirtyQuotaContext *vCPUdqctx, u32 offset); bool is_dirty_quota_full(struct vCPUDirtyQuotaContext *vCPUdqctx); +void kvm_vcpu_dirty_quota_free(struct vCPUDirtyQuotaContext **vCPUdqctx); #endif /* KVM_DIRTY_QUOTA_PAGE_OFFSET == 0 */ diff --git a/virt/kvm/dirty_quota_migration.c b/virt/kvm/dirty_quota_migration.c index eeef19347af4..3f74af2ccab9 100644 --- a/virt/kvm/dirty_quota_migration.c +++ b/virt/kvm/dirty_quota_migration.c @@ -23,3 +23,9 @@ bool is_dirty_quota_full(struct vCPUDirtyQuotaContext *vCPUdqctx) { return (vCPUdqctx->dirty_counter >= vCPUdqctx->dirty_quota); } + +void kvm_vcpu_dirty_quota_free(struct vCPUDirtyQuotaContext **vCPUdqctx) +{ + vfree(*vCPUdqctx); + *vCPUdqctx = NULL; +} diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 55bf92cf9f4f..9bf0c728f926 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -438,6 +438,7 @@ static void kvm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm *kvm, unsigned id) void kvm_vcpu_destroy(struct kvm_vcpu *vcpu) { + kvm_vcpu_dirty_quota_free(&vcpu->vCPUdqctx); kvm_dirty_ring_free(&vcpu->dirty_ring); kvm_arch_vcpu_destroy(vcpu); @@ -3693,6 +3694,7 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id) unlock_vcpu_destroy: mutex_unlock(&kvm->lock); + kvm_vcpu_dirty_quota_free(&vcpu->vCPUdqctx); kvm_dirty_ring_free(&vcpu->dirty_ring); arch_vcpu_destroy: kvm_arch_vcpu_destroy(vcpu);