From mboxrd@z Thu Jan 1 00:00:00 1970 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4818BE732FE for ; Thu, 28 Sep 2023 17:29:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C16DD8D00C0; Thu, 28 Sep 2023 13:29:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BA08F8D00A1; Thu, 28 Sep 2023 13:29:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A1A1B8D00C0; Thu, 28 Sep 2023 13:29:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 8E00E8D00A1 for ; Thu, 28 Sep 2023 13:29:38 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 59B2BA1016 for ; Thu, 28 Sep 2023 17:29:38 +0000 (UTC) X-FDA: 81286693236.30.B35D2C7 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by imf21.hostedemail.com (Postfix) with ESMTP id 72B3B1C001D for ; Thu, 28 Sep 2023 17:29:35 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=HkknTCjG; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf21.hostedemail.com: domain of dave.hansen@intel.com designates 134.134.136.24 as permitted sender) smtp.mailfrom=dave.hansen@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695922176; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=nYUUfxmle6vbuAXFvC9ohtpYL22BWNfwS486wB44hA0=; b=LByQv17BaSOXx5/7xII8J+L4IGtk7NSZe8VUT9hsCU5RS0k+rjPGKSxmCswo+u/TCvrzSC E4Svt7YYBoe7Ao9Eiu9cB9CMJlYgzxrIIgS3rd9LT1kD0SJ0f/GpPbE4I2g72oBIk3HpS2 qvrymi2RKRz7Ov3A840562gM5z7lTBg= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=HkknTCjG; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf21.hostedemail.com: domain of dave.hansen@intel.com designates 134.134.136.24 as permitted sender) smtp.mailfrom=dave.hansen@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695922176; a=rsa-sha256; cv=none; b=8adk08LiAgRXsxvH3Lzjof9ZbIUYRfk0I/43s/uKCQ78PX8hhFbk+/6hMPk72FA1+xFy5K 9UfIeXG1i9CqtX/QcoceMdqWPeba6xMkNDalZn589CJx66pZKuIcjFWI4t7YqNhNn4uxq+ 4N/oiURqaZNBk9Kp+GXfpJFQ8crIlmU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695922175; x=1727458175; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=+i5DZweb1DmFnq+1NXhKYb+RqfLnbbybywHY7SzT/fw=; b=HkknTCjGeumkpRpT2F5Z70j2LhlgXr5ewAKVm1oRk5hKrVeLNtmNZQfh 011PVcl8zRa6TCBVlLvIuKoIwv/g7GQKkovXYWwu+uQE2sGvYUI/riIKl EzMBUH5kKbBaYfd3DwM5Zw2JYFp3UrttEHTbunvXKR0H47EFnnvpooC0L nBTGJzuNHimkhi1yCtXueQr9tLvTnmsP0tIVndJ7dIWSv4FlX+QWJZTUX VtREdkMHj8MCwUKRIIBz2ZJmI/vebTNbPlXseIiJP73UXK2cWOAg949KV /T1/Ac0af7rnB5J9WPXlltVtsbGszm43usReJ9p7H4hoykLyod78JbnmE w==; X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="384939691" X-IronPort-AV: E=Sophos;i="6.03,184,1694761200"; d="scan'208";a="384939691" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2023 10:29:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="743149449" X-IronPort-AV: E=Sophos;i="6.03,184,1694761200"; d="scan'208";a="743149449" Received: from jveerasa-mobl.amr.corp.intel.com (HELO [10.255.231.134]) ([10.255.231.134]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2023 10:29:33 -0700 Message-ID: Date: Thu, 28 Sep 2023 10:29:32 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [RFC PATCH v2 0/7] Introduce persistent memory pool Content-Language: en-US To: Stanislav Kinsburskii Cc: Baoquan He , tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, ebiederm@xmission.com, akpm@linux-foundation.org, stanislav.kinsburskii@gmail.com, corbet@lwn.net, linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-mm@kvack.org, kys@microsoft.com, jgowans@amazon.com, wei.liu@kernel.org, arnd@arndb.de, gregkh@linuxfoundation.org, graf@amazon.de, pbonzini@redhat.com References: <01828.123092517290700465@us-mta-156.us.mimecast.lan> <20230927161319.GA19976@skinsburskii.> <20230927232548.GA20221@skinsburskii.> From: Dave Hansen In-Reply-To: <20230927232548.GA20221@skinsburskii.> Content-Type: text/plain; charset=UTF-8 Content-Trans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wyltvPnEe3TIh6H6ETVag/NjVtzBgoGwyNDvbTG3rQ3 atzGLwRX j9b5Up/CaGnsg7NaKwOe6zMbvoCUqLuq7nNnNbWmxyEXA5VEzOGdxnniW5hmz2aDG6JsFIbJEND+3Dp0jWOV5h2TFFMjgdBgqjuBOQo9Xzl24yzIDYZ1lYX7TWapzpI8mfy9LQM2bDo6qAm533MDzroMrpAYOhOx3nsxpo/6tv0hc9p5vaXJxHNtpGuQWZ1gteKpkifmykPNSUR+sLbiD/YDpidr1l1nZQdEw X-Bogosity: Ham, tests=bogofilter, spamicity=0.000005, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 9/27/23 16:25, Stanislav Kinsburskii wrote: > On Thu, Sep 28, 2023 at 06:22:54AM -0700, Dave Hansen wrote: >> On 9/27/23 09:13, Stanislav Kinsburskii wrote: >>> Once deposited, these pages can't be accessed by Linux anymore and thus >>> must be preserved in "used" state across kexec, as hypervisor state is >>> unware of kexec. >> >> If Linux can't access them, they're not RAM any more. I'd much rather >> remove them from the memory map and move on with life rather than >> implement a bunch of new ABI that's got to be handed across kernels. > > Could you elaborate more on the new ABIs? FDT is handled by x86 already, > and passing it over kexec looks like a natural extension. > Also, adding more state to it also doens't look like a new ABI. > Or does it? FDT makes it easier to pass arbitrary data around, but you're still creating a new "default_pmpool" device tree node on one end and consuming it on the other. That's a new ABI in my book. > Let me also comment on removing this regions from the memory map. The > major peculiarity here is that hypervisor distinguish between the pages, > deposited for guests to rnu and the pages deposited for the Linux root > partition to keep the guest-related portion of hypervisor state in the > root partition. And the latter is the matter in question. > > We can indeed isolate and deposit a excessive amount of memory upfront > in hope that hypervisor will never get into the situation, when it needs > more memory. > However, it's not reliable, as the amount of memory will always be an > estimation, depending on the number of expected guests, guest-attached > devices, etc. And this becomes even a bigger problem when most of the > memory is already removed from the memory map to host guest partitions. > It's also not efficient as the amount of memory required by hypervisor > can grow or shrink depending on the use case or host configuration, and > deposting excessive amount of memory will be a waste. > > But, actually, the idea of removing the pages from memory map was > reflected to some extent in the first version of this proposal, > so let me elaborate on it a bit. > > Effectively, instead of reserving and depositing a lot of memory to > hypervisor upfront, the memory can be allocated from kernel memory when > needed and then returned back when unused. > This would still require pages removal from the memory map upon kexec, > but that's another problem. Let's distill this down a bit. I agree that it's a waste to reserve an obscene amount of memory up front for all guests for rare cases. Having the amount of consumed memory grow is a nice feature. You can also quite easily *shrink* the amount of memory on a given kernel without new code. Right? The problem comes when you've grown the footprint of hypervisor-donated memory, kexec, and *THEN* want to shrink it. That's what needs new metadata to be communicated over to the new kernel. 1. Boot some kernel 2. Grow the deposited memory a bunch 3. Kexec 4. Shrink the deposited memory Right? That's where you lose me. Can't the deposited memory just be shrunk before kexec? Surely there aren't a bunch of pathological things consuming that memory right before kexec, which is basically a reboot.