From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25540379C32 for ; Tue, 4 Aug 2026 23:02:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785884565; cv=none; b=VR7xBkAb2Zgp10hAUhHs6w2Utu6r9BRmaxtKLIyht0WV8P4PORWOdreSCjhv48xnUHmE3VLtZSGu+G7vDmLlrJykRmvGqdriTQxThjfBQtmRjuYgUQnwjBN9F6XcsrW+ZvtgtgMHaxP/p6mhnJcBbnRdspyrVfPHF6Z3PTI/rjE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785884565; c=relaxed/simple; bh=+Sjb4VlDrQW2kUs8a49Swpwu7ZAiKHiMb7mhPrusH20=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Ty4/S3U/9eLxDoxU4yJyDvY+f6Epmdq1VIBpc+OMwqYloyrhv0ibS4R0YJBd3PK/wZYQTmY4XsrMcuAKim2BXsc7SSBo4CcNS/Ch481PIJQl+vUsdOETufOOYHtGzJyPJa4p1IJYIntF8SeWqVAuKnD1VhyY2D00hKnE+np+fFc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=b1n/7s+S; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="b1n/7s+S" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0CB051F000E9; Tue, 4 Aug 2026 23:02:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785884564; bh=u5UncBf9PwoRD0ejcHo6g/DrJr0SQ17oPbMYwAtLhTs=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=b1n/7s+SUku3EzUeCDV5pq7MAn9cr1oatGCiJRui3LH1bxVXpgnrp1jOzORgPA0f/ jvxHc/0YXHAvXxLhwobqqM7Bp60timPVvggk6pD+PEDPmkvQp4q6lbdtQUKuVcJA3o ghTz4EpNp/JjsGf13OXUAYDkV65BeG1vFoTPUGTd/QVysPIoc2YNpwa4LVgKD1cCcp XbFb+ewiW7ssUAKomW5a0SRfnfw717hT9vAsFjVFGLefhyYo50i0MGZPyJxBj+T3mr RWoG+1NRSTkuKj3hgvIPQFRFu+KzsIOMfpCqq87QrHa2uM7cUjxKgKcnM45VKmd4Rs pdU64IKZIEiCg== Date: Tue, 4 Aug 2026 23:02:41 +0000 From: Yosry Ahmed To: Brendan Jackman Cc: Borislav Petkov , Dave Hansen , Peter Zijlstra , Andrew Morton , David Hildenbrand , Vlastimil Babka , Mike Rapoport , Wei Xu , Johannes Weiner , Zi Yan , Lorenzo Stoakes , linux-mm@kvack.org, linux-kernel@vger.kernel.org, x86@kernel.org, Sumit Garg , Will Deacon , rientjes@google.com, patrick.roy@linux.dev, "Itazuri, Takahiro" , Andy Lutomirski , David Kaplan , Thomas Gleixner , Patrick Bellasi , Reiji Watanabe , Sean Christopherson Subject: Re: [PATCH v3 13/26] mm: introduce freetype_t Message-ID: References: <20260726-page_alloc-unmapped-v3-0-6f5729aa9832@google.com> <20260726-page_alloc-unmapped-v3-13-6f5729aa9832@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260726-page_alloc-unmapped-v3-13-6f5729aa9832@google.com> > @@ -3190,9 +3272,9 @@ EXPORT_SYMBOL_GPL(split_page); > int __isolate_free_page(struct page *page, unsigned int order) > { > struct zone *zone = page_zone(page); > - int mt = get_pageblock_migratetype(page); > + freetype_t ft = get_pageblock_freetype(page); > > - if (!is_migrate_isolate(mt)) { > + if (!is_migrate_isolate(free_to_migratetype(ft))) { > unsigned long watermark; > /* > * Obey watermarks as if the page was being allocated. We can > @@ -3205,7 +3287,7 @@ int __isolate_free_page(struct page *page, unsigned int order) > return 0; > } > > - del_page_from_free_list(page, zone, order, mt); > + del_page_from_free_list(page, zone, order, ft); > > /* > * Set the pageblock if the isolated page is at least half of a > @@ -3214,14 +3296,16 @@ int __isolate_free_page(struct page *page, unsigned int order) > if (order >= pageblock_order - 1) { > struct page *endpage = page + (1 << order) - 1; > for (; page < endpage; page += pageblock_nr_pages) { > - int mt = get_pageblock_migratetype(page); > + freetype_t old_ft = get_pageblock_freetype(page); > + freetype_t new_ft = freetype_with_migrate(old_ft, > + MIGRATE_MOVABLE); > + > /* > * Only change normal pageblocks (i.e., they can merge > * with others) > */ > - if (migratetype_is_mergeable(mt)) > - move_freepages_block(zone, page, mt, > - MIGRATE_MOVABLE); > + if (migratetype_is_mergeable(free_to_migratetype(ft))) > + move_freepages_block(zone, page, old_ft, new_ft); While poking at the code with AI, it pointed out that new_ft here may be an invalid freetype (e.g. unmapped movable). I don't think anything in move_freepages_block() or its callees checks against this. There may not be an actual code path that would lead to this, but it's very subtle. We can add a check to can_merge_freetypes() (introduced in later patches) to check for invalid types. But I think we may actually want a check in prep_move_freepages_block(), which is called by move_freepages_block() and others before moving a pageblock. WDYT? > } > }