Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp183279imw; Wed, 13 Jul 2022 22:36:21 -0700 (PDT) X-Google-Smtp-Source: AGRyM1scehMV4T8IXBuCx5pBA67z3Nc8nkCybAYhUioU968pi71XOxZsVK3i/ruPSZrNJgvSrCt/ X-Received: by 2002:a17:90a:8b8f:b0:1ef:9130:f96c with SMTP id z15-20020a17090a8b8f00b001ef9130f96cmr7769569pjn.20.1657776981593; Wed, 13 Jul 2022 22:36:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1657776981; cv=pass; d=google.com; s=arc-20160816; b=psT57/rWhv7ZJMql9edPzd+f0nxY8++35welRsecczc0vLHmEepZfUbfv1xA2sDxQR qljagHCMP20xazHpCUUWihedJsFCvavKSfu9+q6WB9xxAeoudgkpJZEqxKWcFtQ4mL/V yWX9HXpNEzXHbIxvxVYe4PMYPa4CUkhxPjJWSGkMGCKHZil40K9YzA6rxP55YQKFb53a ZO3aerIxDJ7wGyi1KkrMU08bQkd5Pf7TXu+M39cvl7vCFRJaWcOUdJIfuYSnaN7itk+g SX3Ps75LnBaGAs4tDsA3xOHMnwYsUDAoAikHa2vGXGYO4Lp8ALVwFD3Imt5Fqdo1Covc n6oQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=JiH++72cP6PvlniAvI81A14IGuMIsNrP70AVG88c3VE=; b=h0uh+V4NngaiAWeaQ4RS7tSg7EyTapPDV2s1opwSIlouq5+M4uJEog014wrj1VqYud zTRitnr6xN2mbnoxb5lxFHARudM3RlI0LI5BB7uX9u02ARj7/fYR6Vb2iQNcSDc1AgFq +yDVfTU1YxLNfquLYLnApXltiPsG2N79sNXB9PJ2DSGybTVtO8vjQp5XQ5d0nlxJUZ8j nho71RkDZz9ViSu/jDsHxeMcOBXQeodrtcgsfo7dj+oQ6gk/0zVa0n5LheG3RBj3MtcC 2pBLO+NcsmwbV/7PYS+yXQOrthaIRbMrmLc4k/MQ/jP30wYWi77CPKUbA2q7O0XT/qjw NtlA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=GcV40z1o; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c7-20020a056a00248700b00525781f40f1si1409172pfv.103.2022.07.13.22.36.09; Wed, 13 Jul 2022 22:36:21 -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=@amd.com header.s=selector1 header.b=GcV40z1o; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234804AbiGNE4E (ORCPT + 99 others); Thu, 14 Jul 2022 00:56:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234711AbiGNEzi (ORCPT ); Thu, 14 Jul 2022 00:55:38 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2081.outbound.protection.outlook.com [40.107.92.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B25C643EF; Wed, 13 Jul 2022 21:39:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AbhdvKZJNdyQATNtK8VNYXFora/+OLu12r7hGO+cyh9ZV6cjSfVPEPAMrwJe7Y9rXDvENCb8/omx4bLBysl900EyjL+1lXNsGAA/6cp6tOMwt4KN36o/by4jSDc1GjsZOEkEKKFL9XTlh9bFl9K7Si9md0wwW4GEa7c1oaAJXYd6ePWoRtskSgbdkDUJaSjxhBvpbo+oepAwnOmhbD1woBKg0f2ASNPJPsET+Fbrd6MN8PO3ZIjT6pMx78hXcXBUIBB9WFGPWCbBM6PJWWwQ3KXBVHGfzEhBD/FYft1F/BizVn7JUHsHy8RSHL7aE/IZKl8dq2f08M8UEEcOS9i7MA== 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=JiH++72cP6PvlniAvI81A14IGuMIsNrP70AVG88c3VE=; b=Ikbv8R5SK7EcqRfms0jKu8cS3iy9Hs2L87eFjggDtVMqsonQHA3EhbZ7MGfatj+rrv/BcZ45qy7d3L4BcuTmtyoCncan4E/RiNDIXky/gFahA38Z6nkQFdnSXZv3wjMTopR9SKlqzIPUfhir7Lidl6ULErtXi/VZ0xhyJxgPbS+IU7swlJ980VfSc9rYF3KUFZo74WqdoUMDxyerjCOD46ZXnMQlNWwnsMldWJ17OFW7EYw7i0rl9mVXyEh04VrMb7Xndgltb2Y6q13sxrAm/x586MglRdA7Q/pbzMgm8ipiPibTWC0/g5VxF/mAQ3GubRLHLaKbRvQNzgxBBDhZrw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JiH++72cP6PvlniAvI81A14IGuMIsNrP70AVG88c3VE=; b=GcV40z1oIlNNKEoaDhe4B2vZPdREYwEz7Q7GPDg+po0Xf2AZOJgeMUo0yBs1kryIy4axlyeouSSGRz/MtJ+yAQGRxwV51UKyKsQVNrw2D6Tzk9Qm1ZjOyasExWcyLwBFvVk4UfJX5Inbei56XId4MLiLhUfg7nu+ufuukB/GxXI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from CY4PR1201MB0181.namprd12.prod.outlook.com (2603:10b6:910:1f::11) by DM6PR12MB4139.namprd12.prod.outlook.com (2603:10b6:5:214::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.20; Thu, 14 Jul 2022 04:39:50 +0000 Received: from CY4PR1201MB0181.namprd12.prod.outlook.com ([fe80::1001:3c79:9504:8d6a]) by CY4PR1201MB0181.namprd12.prod.outlook.com ([fe80::1001:3c79:9504:8d6a%10]) with mapi id 15.20.5417.026; Thu, 14 Jul 2022 04:39:50 +0000 Message-ID: <9f868fd3-ae47-d44e-fd55-566793405121@amd.com> Date: Thu, 14 Jul 2022 06:39:37 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH v7 00/14] KVM: mm: fd-based approach for supporting KVM guest private memory Content-Language: en-US To: Chao Peng Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, linux-doc@vger.kernel.org, qemu-devel@nongnu.org, linux-kselftest@vger.kernel.org, Paolo Bonzini , Jonathan Corbet , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H . Peter Anvin" , Hugh Dickins , Jeff Layton , "J . Bruce Fields" , Andrew Morton , Shuah Khan , Mike Rapoport , Steven Price , "Maciej S . Szmigiero" , Vlastimil Babka , Vishal Annapurve , Yu Zhang , "Kirill A . Shutemov" , luto@kernel.org, jun.nakajima@intel.com, dave.hansen@intel.com, ak@linux.intel.com, david@redhat.com, aarcange@redhat.com, ddutile@redhat.com, dhildenb@redhat.com, Quentin Perret , Michael Roth , mhocko@suse.com, Muchun Song References: <20220706082016.2603916-1-chao.p.peng@linux.intel.com> <20220713075738.GC2831541@chaop.bj.intel.com> <13d25d2e-ff79-5762-ddb8-87df56f5cbcf@amd.com> <20220713235922.GB2881285@chaop.bj.intel.com> From: "Gupta, Pankaj" In-Reply-To: <20220713235922.GB2881285@chaop.bj.intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: AM5PR0601CA0067.eurprd06.prod.outlook.com (2603:10a6:206::32) To CY4PR1201MB0181.namprd12.prod.outlook.com (2603:10b6:910:1f::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ead61a78-b9f2-4e38-26ac-08da6552e31c X-MS-TrafficTypeDiagnostic: DM6PR12MB4139:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: X2nA99ESSA7nLrA3tjdi1twrBW1DeGkcb6vzB4pVRNw52Vade6QYBQ1IBGuuGa8YNZyI6Dw4jfxSNkCQfFuvcmOJQiCRXz3OR3B1zib/J4aIge06aHePD6eIJmDw4SMI8zQKiMq4XxT2O0jPbt0xqeDbRVrbPkdXIGThsKs2P+0J5c4JjtJx5IKdVWea6NCQwF4R7215zYpt/K4yGchY/j+U8X8TYy47jfhbr2MI4wJw+xULz9tpgGQPBc3hT6xp9+kJGAMu9CwVDFhj4AKJuE/tGcNjP2KX5+Gmwr+ocjXd+GhQASqqZdah+FzJsjmZrhDCvSqpJ5mxglKzm5OrvAbFXf7klah/2q0/xDynVMbo/BUjIZGhtVe661XgWp4aTmZhI/S5YZfBNLMCHxGThg1mDIb8u2lPIfcZAFGU9UuI4RDZSdVO+hO5XX55sFAPLG0AxIIsRO8aqYwD1nu6FPwAwpwNUo1JxKizVoK//IRXQhbVFCAkKYCbTkdwFAcLt2WGcmEXUddDxSYYA1ytMvKtR1X/KMY0zh86gypRd9TRYP/kN+ueV0DJTojXM10t8AXPXtB4WbpsRZPOD2Y1+r2KE3Npjc1eIBiUX3xrMefiFMt2Ez5qrJu354CMXQsiIqgjCtdEdV5qmbucipawuUGaaUz3NnWVuPBiSrLmWlM//P1Rbs126Ni4hmTqNRy9z14lWQlSkMmvuL5M4T5p5UEmXForllBLKz2UUowQ+HtMkQpMK7cn+ItBUUM6Voob5KQm2P6tRxeYGzQB73DQimt+6AxLGNq9IiSSPdAenEogX+lJPo7/7vQ2qWNxA2awm2eWZ4UM2FjHMhc1m/7JIg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY4PR1201MB0181.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(346002)(39860400002)(366004)(376002)(136003)(396003)(66946007)(66476007)(2616005)(4326008)(8676002)(8936002)(186003)(5660300002)(86362001)(478600001)(36756003)(54906003)(316002)(7406005)(31696002)(31686004)(6486002)(7416002)(6916009)(2906002)(66556008)(41300700001)(6506007)(6666004)(6512007)(38100700002)(26005)(83380400001)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?VjJxMG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XNSOEw3OUhBTWEvNjh3THVtMkJ3MEM0RVVFemRWazdkN2pp?= =?utf-8?B?NHFyWW9TL2hPZkoyb0xETmhlcHNMUjh4NHRTK1YxaUhrdk1YcmZvakxkRXA1?= =?utf-8?B?ZkF2VlR4RGhab2VtVW9mR2k0YUJURGpXSndhdEI0U09zMXVLTDUxQTNLNm9o?= =?utf-8?B?YzZLYjArc2NtYmdmSGJCYzlwUmxHd0wraERsb0JFVm9ZVjdoaFduU2hOWkdi?= =?utf-8?B?Z203OVpySXVteWoyQVNmOTZJQy82YTZUTlN0c3E3VHNiWlB4ODNUUlA0blBQ?= =?utf-8?B?aFc2T2VISlc0MHluK2paRlRaMGxtakErZ3k3bi9MM1FTRm9pOHlSbDBsN3Bw?= =?utf-8?Q?J0ApEf6WsLAOlIX1buvLtdaxQ?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: ead61a78-b9f2-4e38-26ac-08da6552e31c X-MS-Exchange-CrossTenant-AuthSource: CY4PR1201MB0181.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2022 04:39:50.1780 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HxjmDwv+ndNmA8b/s9rWD17Gc/TJNq1Ppwthczdjs1HPNvU/iPKcNDyMpOE3jhjd3ftMB4D1HOXfjLqRYmHTag== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4139 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 >>>>> This is the v7 of this series which tries to implement the fd-based KVM >>>>> guest private memory. The patches are based on latest kvm/queue branch >>>>> commit: >>>>> >>>>> b9b71f43683a (kvm/queue) KVM: x86/mmu: Buffer nested MMU >>>>> split_desc_cache only by default capacity >>>>> >>>>> Introduction >>>>> ------------ >>>>> In general this patch series introduce fd-based memslot which provides >>>>> guest memory through memory file descriptor fd[offset,size] instead of >>>>> hva/size. The fd can be created from a supported memory filesystem >>>>> like tmpfs/hugetlbfs etc. which we refer as memory backing store. KVM >>>> >>>> Thinking a bit, As host side fd on tmpfs or shmem will store memory on host >>>> page cache instead of mapping pages into userspace address space. Can we hit >>>> double (un-coordinated) page cache problem with this when guest page cache >>>> is also used? >>> >>> This is my understanding: in host it will be indeed in page cache (in >>> current shmem implementation) but that's just the way it allocates and >>> provides the physical memory for the guest. In guest, guest OS will not >>> see this fd (absolutely), it only sees guest memory, on top of which it >>> can build its own page cache system for its own file-mapped content but >>> that is unrelated to host page cache. >> >> yes. If guest fills its page cache with file backed memory, this at host >> side(on shmem fd backend) will also fill the host page cache fast. This can >> have an impact on performance of guest VM's if host goes to memory pressure >> situation sooner. Or else we end up utilizing way less System RAM. > > (Currently), the file backed guest private memory is long-term pinned > and not reclaimable, it's in page cache anyway once we allocated it for > guest. This does not depend on how guest use it (e.g. use it for guest > page cache or not). Even if host shmem backed memory always be always un-reclaimable, we end up utilizing double RAM (both in guest & host page cache) for guest disk accesses? I am considering this a serious design decision before we commit to this approach. Happy to be enlightened on this and know the thoughts from others as well. Thanks, Pankaj