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 2DBBEEB64DC for ; Mon, 3 Jul 2023 13:25:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7F1D2900006; Mon, 3 Jul 2023 09:25:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 77A1C8E00BA; Mon, 3 Jul 2023 09:25:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 61BF3900006; Mon, 3 Jul 2023 09:25:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 4FA518E00BA for ; Mon, 3 Jul 2023 09:25:27 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 12140A08F1 for ; Mon, 3 Jul 2023 13:25:27 +0000 (UTC) X-FDA: 80970372294.10.3E7676F Received: from outbound-smtp40.blacknight.com (outbound-smtp40.blacknight.com [46.22.139.223]) by imf07.hostedemail.com (Postfix) with ESMTP id CCAC34000E for ; Mon, 3 Jul 2023 13:25:24 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf07.hostedemail.com: domain of mgorman@techsingularity.net designates 46.22.139.223 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688390725; 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: in-reply-to:in-reply-to:references:references; bh=4D8eGDIvShzACbO99gH0VSqIfRLGBlcdM+UUh9VP1F0=; b=A69uFgGOQ0rfX2JX0V80bHMA0gkj5YXv2xjLZFfXkwbsEuMeAb4pa4n5DZ0zgSOBdvUGxi SOP33iHz48Fzon6Wgob+Q1AO5obTi0pO2cjrAsqDOTJKHKIRHbTqTfs41NybxUIdkXRJI6 var8GWtHHS4Jk1bTy3/M1qfImsNrg4k= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf07.hostedemail.com: domain of mgorman@techsingularity.net designates 46.22.139.223 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688390725; a=rsa-sha256; cv=none; b=rp6P2+FGtQW3oCo7IvxKNv5CyiM+wHhRwRX0/gq4GoGFDKJ7Qt7Pvq71VnDPqzYn68s9gP R6r3quI7dz5WVHNSxbWON5o1jprt7bfilQ9gzrFAd12WLoyKsoqs4K2Bk3V4VKWIcLAbEr QqNTVWjc2kyZp2VFdP8MXusL3cQKWvA= Received: from mail.blacknight.com (pemlinmail02.blacknight.ie [81.17.254.11]) by outbound-smtp40.blacknight.com (Postfix) with ESMTPS id 893A01C4244 for ; Mon, 3 Jul 2023 14:25:22 +0100 (IST) Received: (qmail 10291 invoked from network); 3 Jul 2023 13:25:22 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.21.103]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 3 Jul 2023 13:25:21 -0000 Date: Mon, 3 Jul 2023 14:25:18 +0100 From: Mel Gorman To: "Kirill A. Shutemov" Cc: Borislav Petkov , Andy Lutomirski , Dave Hansen , Sean Christopherson , Andrew Morton , Joerg Roedel , Ard Biesheuvel , Andi Kleen , Kuppuswamy Sathyanarayanan , David Rientjes , Vlastimil Babka , Tom Lendacky , Thomas Gleixner , Peter Zijlstra , Paolo Bonzini , Ingo Molnar , Dario Faggioli , Mike Rapoport , David Hildenbrand , marcelo.cerri@canonical.com, tim.gardner@canonical.com, khalid.elmously@canonical.com, philip.cox@canonical.com, aarcange@redhat.com, peterx@redhat.com, x86@kernel.org, linux-mm@kvack.org, linux-coco@lists.linux.dev, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCHv14 5/9] efi: Add unaccepted memory support Message-ID: <20230703132518.3ukqyolnes47i5r3@techsingularity.net> References: <20230606142637.5171-1-kirill.shutemov@linux.intel.com> <20230606142637.5171-6-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20230606142637.5171-6-kirill.shutemov@linux.intel.com> X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: CCAC34000E X-Stat-Signature: b8r9xkop3x4z9zi6hjmgtp16c5ieq6ea X-HE-Tag: 1688390724-783673 X-HE-Meta: U2FsdGVkX19NGpZXdkOsO0ROflc9YnFs1sWOHMvE2F3oc8+oMoCUhxG5sp5yqEvyuq+owwoZvQp60efv4Ndk29+l0NNXefs8FOoeQ7qiNt/dDsBRcW81pytdl6BA8A989wCSge27hPylrRUICK1VVaamSi4sqlygC6rHNc/HRlEMASxOYogZlNkmqpXj7jDcVvrvOtiOt7lo4FIhQbVCBJPXxnfUJvmTCGTuUv6hs6CIhE8zYgwVzCa12Ua3+XDVzYG/ovP5UcD8JQVJ1i6VN/ThLQUdtRB1hCO567KZH9lolZhfyBuW8CWcMrFUrOaT4CHkLsPOkrY3tmnVoL17ZrAVL/hu+otzalzTOPJ3Ov/wfyvaSzpoKvxf0e+2D71Sp8g7C0eu8flhL2WnTmmEzHl3XKy8rw79LrZXXF56fRFpt9Bmvy5TcLtMJeIA7hTo5XT3GNmBkviTmsTJMQ9YQ4RivqMYAWLww7BH5xesR1VDdZoCCCnbjxGWWOZg7ErHtjSeeDDmyn9vHkwce7hPmro6FK2gSx03ofGkxcuWY44XaY9uJ5luvHCvUJPUUPG0Rqi3eQnQv4rTHad8qvVQw9nNrmwcwapLgtOGR0dtZ9pBKOnJK5DIT1vzGsdtNnT5fbgF0XzKgDMKEyaAwOi5SF5z0IQJtesvhgwD5zgj8oCUrh+0ab+zpMJSb0lR8ZQ7MDzBN1mMoBqqC345WBc8ycjP5NGCtvWvc9b95r8mfTJkJSStCrPiLECcvqzd5dMp8S2OU6vmIaeZBKYs8EjnOuBNyF0S1P97P54nhTS2y6abk1+90ji00hl9ax6DJXMfX4KxcfUop0Z2UFNzET6ceAJMn0JUFIFkXMwTtyq8esMSAo7ar0chYYWnyLuRCwNscZE/GoNm37MDeGxZ9tZQawc8oCypH0i8E8ssD6t/iA9RuxMk6wtoYR5vbhgeGedMrQlZuKA2EMylbq3RTgx k/PTRjwV JAj9NszwLR/a4CIrAigT0u8M7d07a4f6Y6PsnU+YvVqoL9DVfFaHWtvn/PMKneoVvnSpNCKm6LsjpQQAcpbebm0ppPWWfScw1nBs6IqCiyqT6UvaAhaDIeCUpyNRrtNso1b1qSXSGvFGRLUYesatxNmUtE4vjqzsONDLddeWkAM8aj1WWmk8Tgbp+fBnAghLibYkkoJDsQV0wNE5QWrX3iazncWzq2+VqaTT4LkmZDgPQdb5zG6stoJ4heGukj/jiaXuA3xueOucLmDfuBYzLalKFdw== 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: On Tue, Jun 06, 2023 at 05:26:33PM +0300, Kirill A. Shutemov wrote: > efi_config_parse_tables() reserves memory that holds unaccepted memory > configuration table so it won't be reused by page allocator. > > Core-mm requires few helpers to support unaccepted memory: > > - accept_memory() checks the range of addresses against the bitmap and > accept memory if needed. > > - range_contains_unaccepted_memory() checks if anything within the > range requires acceptance. > > Architectural code has to provide efi_get_unaccepted_table() that > returns pointer to the unaccepted memory configuration table. > > arch_accept_memory() handles arch-specific part of memory acceptance. > > Signed-off-by: Kirill A. Shutemov > Reviewed-by: Ard Biesheuvel > Reviewed-by: Tom Lendacky By and large, this looks ok from the page allocator perspective as the checks for unaccepted are mostly after watermark checks. However, if you look in the initial fast path, you'll see this /* * Forbid the first pass from falling back to types that fragment * memory until all local zones are considered. */ alloc_flags |= alloc_flags_nofragment(ac.preferred_zoneref->zone, gfp); While checking watermarks should be fine from a functional perspective and the fast paths are unaffected, there is a risk of premature fragmentation until all memory has been accepted. Meeting watermarks does not necessarily mean that fragmentation is avoided as pageblocks can get mixed while still meeting watermarks. This will be tricky to detect in most cases so it may be worth considering augmenting the watermark checks with a check in this block for unaccepted memory /* * It's possible on a UMA machine to get through all zones that are * fragmented. If avoiding fragmentation, reset and try again. */ if (no_fallback) { alloc_flags &= ~ALLOC_NOFRAGMENT; goto retry; } I think the watermark checks will still be needed because hypothetically if 100% of allocations were MIGRATE_UNMOVABLE then there never would be a request that fragments memory and memory would not be accepted. It's not a blocker to the series, simply a suggestion for follow-on work. -- Mel Gorman SUSE Labs