Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3654795pxt; Tue, 10 Aug 2021 08:23:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJN92CJFnzt28LVnzpzknghbGn6+PURp+irEtLwELdbaYmo0FSGyMCcr3iz1rwuj7om3Xb X-Received: by 2002:a17:906:ecf1:: with SMTP id qt17mr14006037ejb.339.1628609006864; Tue, 10 Aug 2021 08:23:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628609006; cv=none; d=google.com; s=arc-20160816; b=x+inY8QtBYjicDlaskgEPT6lg28ZHtmXrvwXXWwCszyCQkTgUW4djC3bwZnsrfD49C vGBdSMOMRv7Cw2Sz9Yw70H8CB0zfrYZV0XWglHeeqCaHakpuAKcmHyzREGpKPb9KLEE3 x+OTW0eBwKl3lA8gdX1zCsLXs7UnTCWjIjg75BVw5/3mU+yEsO5iox+0X9csWho3jjqd LJq9jMTFR48FnfbmXFfB16ynzt6X+oxUCmM8MKsqyNdBpuRcQWhfm/1AH/v+XgrY/qGb 2nX3zMn1bi6tgTVQp6dhnoJ8N2pzu1kUnwvuDiSjD/vqgc0DwqRmORnwNdrp/UXxPnvi 8yhw== 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; bh=MhEWeGIw9KGDLnLwbtyEiORNVqrl4JJylUkX17P4k1A=; b=KYY8nZKyshSnkPRy1n3nIxOd1sJjVQ3stiICGRcdgE4oUW9/ZYHVgaPFDTIikTNLyJ bz+oUJ8Afq+qGadfZ0lDJlDRDcFh8Zsa0HgwiEzraNnQkBaBQCva2EUi4A67j2BGX2yJ 3L1hPiyMAUlUU2GY5AavuJ8IGEX9k/KSkgnB/EPd+1nISmXxlTXJX61mgzApg2+Ku8t9 fY5G4hAFj3Zk2MSJerrVP+oJnsHNgim94zfvCkFd1AFuDIp0mhnhspZKAJ1veI4hH8cf zNq5d0c0fBL7M0VGk46IUlOK71PxnA98iSHLB1gxmM58U2CY0QPkErwD40xqOemx7L/F L8QA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r21si23674312ejo.665.2021.08.10.08.22.31; Tue, 10 Aug 2021 08:23:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241697AbhHJPTw (ORCPT + 99 others); Tue, 10 Aug 2021 11:19:52 -0400 Received: from mga05.intel.com ([192.55.52.43]:8045 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239937AbhHJPTw (ORCPT ); Tue, 10 Aug 2021 11:19:52 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10072"; a="300513128" X-IronPort-AV: E=Sophos;i="5.84,310,1620716400"; d="scan'208";a="300513128" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Aug 2021 08:16:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,310,1620716400"; d="scan'208";a="469054407" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 10 Aug 2021 08:16:15 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 03C38142; Tue, 10 Aug 2021 18:15:48 +0300 (EEST) Date: Tue, 10 Aug 2021 18:15:48 +0300 From: "Kirill A. Shutemov" To: Dave Hansen Cc: "Kirill A. Shutemov" , Borislav Petkov , Andy Lutomirski , Sean Christopherson , Andrew Morton , Joerg Roedel , Andi Kleen , Kuppuswamy Sathyanarayanan , David Rientjes , Vlastimil Babka , Tom Lendacky , Thomas Gleixner , Peter Zijlstra , Paolo Bonzini , Ingo Molnar , Varad Gautam , Dario Faggioli , x86@kernel.org, linux-mm@kvack.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/5] x86: Impplement support for unaccepted memory Message-ID: <20210810151548.4exag5uj73bummsr@black.fi.intel.com> References: <20210810062626.1012-1-kirill.shutemov@linux.intel.com> <4b80289a-07a4-bf92-9946-b0a8afb27326@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4b80289a-07a4-bf92-9946-b0a8afb27326@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 10, 2021 at 07:08:58AM -0700, Dave Hansen wrote: > On 8/9/21 11:26 PM, Kirill A. Shutemov wrote: > > UEFI Specification version 2.9 introduces concept of memory acceptance: > > Some Virtual Machine platforms, such as Intel TDX or AMD SEV-SNP, > > requiring memory to be accepted before it can be used by the guest. > > Accepting happens via a protocol specific for the Virtrual Machine > > platform. > > > > Accepting memory is costly and it makes VMM allocate memory for the > > accepted guest physical address range. We don't want to accept all memory > > upfront. > > This could use a bit more explanation. Any VM is likely to *eventually* > touch all its memory, so it's not like a VMM has a long-term advantage > by delaying this. > > So, it must have to do with resource use at boot. Is this to help boot > times? Yes, boot time is main motivation. But I'm going also to look at long-term VM behaviour with the fixed memory footprint. I think if a workload allocate/free memory within the same amount we can keep memory beyond the size unaccepted. Few tweaks likely will be required such as disabling page shuffling on free to keep unaccepted memory at the tail of free list. More investigation needed. > I had expected this series, but I also expected it to be connected to > CONFIG_DEFERRED_STRUCT_PAGE_INIT somehow. Could you explain a bit how > this problem is different and demands a totally orthogonal solution? > > For instance, what prevents us from declaring: "Memory is accepted at > the time that its 'struct page' is initialized" ? Then, we use all the > infrastructure we already have for DEFERRED_STRUCT_PAGE_INIT. That was my first thought too and I tried it just to realize that it is not what we want. If we would accept page on page struct init it means we would make host allocate all memory assigned to the guest on boot even if guest actually use small portion of it. Also deferred page init only allows to scale memory accept across multiple CPUs, but doesn't allow to get to userspace before we done with it. See wait_for_completion(&pgdat_init_all_done_comp). -- Kirill A. Shutemov