Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp26209434rwd; Mon, 3 Jul 2023 06:53:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlEFBfPj2eyBwGKFOyopaVzmB91jkUmtW9L6xQjxxSf5BdIvXQkbqTdo85hot2pyLmlkDj2W X-Received: by 2002:a17:90a:a88c:b0:263:69c7:f494 with SMTP id h12-20020a17090aa88c00b0026369c7f494mr8763646pjq.8.1688392423187; Mon, 03 Jul 2023 06:53:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688392423; cv=none; d=google.com; s=arc-20160816; b=lEER3Kj9D3wx74sJNfdtgefRclNaq5jE70EM7kPR3Od1PHo9Fx8C2v6NqUTyATyr9+ L1JB+U6e4cD7V7DwU+5n7WrVm0KDOh1a2CMnGmegn84IWuzC6pVkfOncQ/oDgR9uXHip CZ+9m9k+Mh3js6HwLUbn2MWZiShwPVRyU5+i8UIQCWg9TDC/jy6tOpnT/BQODaNZMERl nZyu0VJGI852cD6QZOWiQIyeugHyUFAfALy2Oqozr9cyfvaBc89LxqaJ1HS2HdxUj/Fl E1T9z3v/ZUt9JYz7C+1waX8ONpEchQ4g3wzUiPDAWuyxyi7eR6RUgl0T0f+5TNGpwimc TWQA== 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=4D8eGDIvShzACbO99gH0VSqIfRLGBlcdM+UUh9VP1F0=; fh=6jEelm1DjsmRbjK8xK/DNWj1F12EJUStV+2HYflxLew=; b=OUeNJvBvep4Z9J0ynf68+b/ESymxZDeqZmKyT5I7aGbvZonpzz4ST+q60hC7VNCTvx P9pidhdmmCZKd5XA5qTGvT6Ym2OeutAFXMBxuQ1J0C8gfOgWptK/8RObF2alUAN9uNGw 6yxH0uxQ/SrcVIWQ+E7yCjcdBfCUdndWAhKGev2hMi7mjUfFoc3AkC744D6BikEAyUa3 BM6OsBOG5X8kNkOVvlDkJFoCgT456oZNaD/pR2eX6x1aiAqZJIwjCT6RXKPrCz9QZi5S dZjvLQeNtqN87tfLASwHi5HxYW8M106JIciw2tTWBvrdSp1VXiKE+rCrkGRZpcEdZoAt s9qw== ARC-Authentication-Results: i=1; mx.google.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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ml19-20020a17090b361300b00262ee7c6cafsi15418837pjb.87.2023.07.03.06.53.31; Mon, 03 Jul 2023 06:53:43 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230395AbjGCNZa (ORCPT + 99 others); Mon, 3 Jul 2023 09:25:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230016AbjGCNZ3 (ORCPT ); Mon, 3 Jul 2023 09:25:29 -0400 Received: from outbound-smtp31.blacknight.com (outbound-smtp31.blacknight.com [81.17.249.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 347DDE67 for ; Mon, 3 Jul 2023 06:25:24 -0700 (PDT) Received: from mail.blacknight.com (pemlinmail02.blacknight.ie [81.17.254.11]) by outbound-smtp31.blacknight.com (Postfix) with ESMTPS id 8967CC0E7A 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, 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 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