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 X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC4E1C4338F for ; Thu, 19 Aug 2021 09:55:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7606B610FA for ; Thu, 19 Aug 2021 09:55:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7606B610FA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 002976B006C; Thu, 19 Aug 2021 05:55:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EF5DA8D0001; Thu, 19 Aug 2021 05:55:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DBDE16B0072; Thu, 19 Aug 2021 05:55:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0130.hostedemail.com [216.40.44.130]) by kanga.kvack.org (Postfix) with ESMTP id BDDC26B006C for ; Thu, 19 Aug 2021 05:55:12 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 6B7241802DA7C for ; Thu, 19 Aug 2021 09:55:12 +0000 (UTC) X-FDA: 78491372064.24.34EC164 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf08.hostedemail.com (Postfix) with ESMTP id 84AB5300D988 for ; Thu, 19 Aug 2021 09:55:11 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 3A63E200B8; Thu, 19 Aug 2021 09:55:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629366910; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pBx7UvjXszKNzjrsiqHLkrPggQDMMUiJVYYt4I/aFBY=; b=Gb3P5uQsliDPSyaSdPwt9DDA/+NZsn8pb8lq88jTIZv9/3O282MkGBKjMJd02MfQAmRiux 80YRH5jd6dF9pnmUxVfjcUCM9qYttgOcCAPatQS1HNpTDeChF5LVaQitWdRtlPCjp6h+e5 GG1YL5EYBriHTJE6nc5LgGgpfQypIlw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629366910; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pBx7UvjXszKNzjrsiqHLkrPggQDMMUiJVYYt4I/aFBY=; b=ZTvPUcKZrNXECsQm0diB42W33txsl3l+81DrtzSPnII0dabhm0Flu3KcbMI2L+aqhwYkvs c7v2zmNCoxx6QICg== Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id 6602F1389C; Thu, 19 Aug 2021 09:55:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id iY8kF30qHmGZNAAAGKfGzw (envelope-from ); Thu, 19 Aug 2021 09:55:09 +0000 Date: Thu, 19 Aug 2021 11:55:07 +0200 From: Joerg Roedel To: David Hildenbrand Cc: Dave Hansen , Andi Kleen , "Kirill A. Shutemov" , Borislav Petkov , Andy Lutomirski , Sean Christopherson , Andrew Morton , 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, "Kirill A. Shutemov" Subject: Re: [PATCH 1/5] mm: Add support for unaccepted memory Message-ID: References: <9748c07c-4e59-89d0-f425-c57f778d1b42@linux.intel.com> <17b6a3a3-bd7d-f57e-8762-96258b16247a@intel.com> <796a4b20-7fa3-3086-efa0-2f728f35ae06@linux.intel.com> <3caf5e73-c104-0057-680c-7851476e67ac@linux.intel.com> <25312492-5d67-e5b0-1a51-b6880f45a550@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 84AB5300D988 Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=Gb3P5uQs; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=ZTvPUcKZ; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf08.hostedemail.com: domain of jroedel@suse.de designates 195.135.220.29 as permitted sender) smtp.mailfrom=jroedel@suse.de X-Rspamd-Server: rspam04 X-Stat-Signature: 6oja359rkwke1qesebstidpdkxdfwzek X-HE-Tag: 1629366911-472783 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Hi David, On Tue, Aug 17, 2021 at 05:00:55PM +0200, David Hildenbrand wrote: > Not sure if already discussed, but what about making sure that free pages > are not a mixture (partially unaccepted, partially accepted). > > You'd have to expose the pages in that granularity to the buddy > (__free_pages_core), indicating the state. You'd have to reject merging > pages of differing acceptance state. > > Accepting a page would then be handled outside of the zone lock, completely > controlled by the state. > > So a page in the buddy would either be completely accepted or completely > unaccepted, signaled e.g., by PageOffline(). > > Consequently, when allocating a 4KiB page, you'd split an unaccepted 2MiB > page into separate unaccepted pages. You'd grab one of the unaccepted 4KiB > pages and accept it before initializing it and handing it out. Yes, that is the alternative to over-accepting memory on allocation. But the problem here is that accepting/validating memory is an expensive operation which also requires a hypercall. The hypercalls on SNP and TDX can accept/validate multiple pages in one call. So the recommendation is to accept memory in bigger chunks, like the 2MB that have been proposed. Only accepting memory in allocation size might be too slow, as there is a lot of code doing order-0 allocations. I think this approach will also be more intrusive to the page alloctor, as it needs more changes on the free path to check for acceptance states before pages can be merged. Regards, Joerg