From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f74.google.com (mail-ej1-f74.google.com [209.85.218.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17EB93E95A3 for ; Wed, 25 Feb 2026 16:34:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772037291; cv=none; b=EBwuamGyU7FHEa0mjWcnFm9UaPexAIvua4qU1B3mHkcvHj1L3UZTpG2g7uItwaLYdIHhhdg0g/MoAhf+906m4NT1htOe1+thyUzlLytdgZymejDvVOr1E9UX8hA5dkA/egnD8Hesqq6T8FfXUol6E5F/DQ321Z/YMKxcuxCGEEo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772037291; c=relaxed/simple; bh=0Ir/PBvJZVYMBYViR320QXbxAMY6bdSdQ7UYbcrNNvQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=hqjMKNdbKN+asqzFgPTer09D8maAk+IeR+tCTSZh9tGi7zwxDQCSUHxiC1gVdYELG3OnLP4N4oQuVJnFZ1csOTqSjfA2teAAVok7TOWZZl8FxwMRtPgB7OegO+iafm783gB+5GN7nMkQHvUeDGMkgCjHUSGy01OFh2x/ytipT20= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=4Pmk+Ahs; arc=none smtp.client-ip=209.85.218.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="4Pmk+Ahs" Received: by mail-ej1-f74.google.com with SMTP id a640c23a62f3a-b8fa51ade75so180349566b.3 for ; Wed, 25 Feb 2026 08:34:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1772037288; x=1772642088; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ZPavfHtzfndzWIXWdPBl+t2V385Pl6oyLSG23Scoa5U=; b=4Pmk+AhsIjd00ukLIXWfmISxGbr5daUYtSRiQoCLE48OfHYCjiRYhk5+NtnK55EnnM gGMXA9xDAfWRCEhxLHZZTYzrirptfn2sEIaB/voGrclDryYnyZDu/Z9QOcMtpNa2PyT3 ZKREYgfgmWKPL5kalSVHKoDauUkHNJQsoVk5hT7j8zLRVXx5YqLXxgRlaVz8DgZH2l5r yvd3wrLXOCRGK+4WJK1fx8+yH+BwhUOmBid2N2b9xoVmNAX7cPF4VcR6l5eKEy9MAwAw 7/s2e84lcKMLnK+K0arXBODhMabKoQm/UxeF9xMrzB5PD43P1PVp0/gHUDBiId+8VXjS B72w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772037288; x=1772642088; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZPavfHtzfndzWIXWdPBl+t2V385Pl6oyLSG23Scoa5U=; b=j3QGkaS/LT4CWp2yn3Vc20d+hXs3naryDXdSX3ta7ia0oMDiaTU9v/ILIvO9Lv/2l7 /N8OgoALULZsTeTUWfDjRNay8DzDS02svo8WBUISzF8QpIvSbM84cAFVIrlx98Q7/O16 fhLUfWgDDBzybG+jd4jQqXZAlXH/NisU0wSWWt+k4k+W1/1CoAe3VE5bvmta5HiJG2e6 e4fgiAanRgD8qP2DHFVuSlPMGMGhlxpYT9NAVPEjHXLyQVCvW/iyQVuaLoeM3I1tx/CK 6/FRKyH13i5OUlgfFYDDaZzq9Erb8IojuzJKRjloI+2+aFNzHlof3NBJYmTYTIMeWuAl JCtA== X-Forwarded-Encrypted: i=1; AJvYcCUrgxV4uQho5cWdiMxNBBIIQWxsd8lcbMVfOd/CHLsJOwzlgce91Mow6v0wNJWY1uw//csBxokMsOyUB/c=@vger.kernel.org X-Gm-Message-State: AOJu0YxcsDMwpdrzREW7x0no/v73TvYGbF3yzkrjF/XpWQTld2RQmawu BhFnhFP5fzjFPgfBQjJAnITCLNyfeksf93SRIcg0UnzL/DQxRDciCzHNo6aCZc5LnHA/9GBuwwV gc3ZsWCbMeIXlcg== X-Received: from ejdbx6.prod.google.com ([2002:a17:907:fdc6:b0:b93:4df6:8a2]) (user=jackmanb job=prod-delivery.src-stubby-dispatcher) by 2002:a17:906:8c5:b0:b80:3346:496 with SMTP id a640c23a62f3a-b9081b98d24mr912485466b.42.1772037288223; Wed, 25 Feb 2026 08:34:48 -0800 (PST) Date: Wed, 25 Feb 2026 16:34:34 +0000 In-Reply-To: <20260225-page_alloc-unmapped-v1-0-e8808a03cd66@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260225-page_alloc-unmapped-v1-0-e8808a03cd66@google.com> X-Mailer: b4 0.14.3 Message-ID: <20260225-page_alloc-unmapped-v1-9-e8808a03cd66@google.com> Subject: [PATCH RFC 09/19] mm: move migratetype definitions to freetype.h From: Brendan Jackman To: Borislav Petkov , Dave Hansen , Peter Zijlstra , Andrew Morton , David Hildenbrand , Lorenzo Stoakes , Vlastimil Babka , Wei Xu , Johannes Weiner , Zi Yan Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, x86@kernel.org, rppt@kernel.org, Sumit Garg , derkling@google.com, reijiw@google.com, Will Deacon , rientjes@google.com, "Kalyazin, Nikita" , patrick.roy@linux.dev, "Itazuri, Takahiro" , Andy Lutomirski , David Kaplan , Thomas Gleixner , Brendan Jackman , Yosry Ahmed Content-Type: text/plain; charset="utf-8" Since migratetype are a sub-element of freetype, move the pure definitions into the new freetype.h. This will enable referring to these raw types from pageblock-flags.h. Signed-off-by: Brendan Jackman --- include/linux/freetype.h | 84 ++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mmzone.h | 73 ----------------------------------------- 2 files changed, 84 insertions(+), 73 deletions(-) diff --git a/include/linux/freetype.h b/include/linux/freetype.h index 9f857d10bb5db..11bd6d2b94349 100644 --- a/include/linux/freetype.h +++ b/include/linux/freetype.h @@ -3,6 +3,66 @@ #define _LINUX_FREETYPE_H #include +#include + +/* + * A migratetype is the part of a freetype that encodes the mobility + * requirements for the allocations the freelist is intended to serve. + * + * It's also currently overloaded to encode page isolation state. + */ +enum migratetype { + MIGRATE_UNMOVABLE, + MIGRATE_MOVABLE, + MIGRATE_RECLAIMABLE, + MIGRATE_PCPTYPES, /* the number of types on the pcp lists */ + MIGRATE_HIGHATOMIC = MIGRATE_PCPTYPES, +#ifdef CONFIG_CMA + /* + * MIGRATE_CMA migration type is designed to mimic the way + * ZONE_MOVABLE works. Only movable pages can be allocated + * from MIGRATE_CMA pageblocks and page allocator never + * implicitly change migration type of MIGRATE_CMA pageblock. + * + * The way to use it is to change migratetype of a range of + * pageblocks to MIGRATE_CMA which can be done by + * __free_pageblock_cma() function. + */ + MIGRATE_CMA, + __MIGRATE_TYPE_END = MIGRATE_CMA, +#else + __MIGRATE_TYPE_END = MIGRATE_HIGHATOMIC, +#endif +#ifdef CONFIG_MEMORY_ISOLATION + MIGRATE_ISOLATE, /* can't allocate from here */ +#endif + MIGRATE_TYPES +}; + +/* In mm/page_alloc.c; keep in sync also with show_migration_types() there */ +extern const char * const migratetype_names[MIGRATE_TYPES]; + +#ifdef CONFIG_CMA +# define is_migrate_cma(migratetype) unlikely((migratetype) == MIGRATE_CMA) +#else +# define is_migrate_cma(migratetype) false +#endif + +static inline bool is_migrate_movable(int mt) +{ + return is_migrate_cma(mt) || mt == MIGRATE_MOVABLE; +} + +/* + * Check whether a migratetype can be merged with another migratetype. + * + * It is only mergeable when it can fall back to other migratetypes for + * allocation. See fallbacks[MIGRATE_TYPES][3] in page_alloc.c. + */ +static inline bool migratetype_is_mergeable(int mt) +{ + return mt < MIGRATE_PCPTYPES; +} /* * A freetype is the index used to identify free lists. This consists of a @@ -35,4 +95,28 @@ static inline bool freetypes_equal(freetype_t a, freetype_t b) return a.migratetype == b.migratetype; } +static inline freetype_t migrate_to_freetype(enum migratetype mt, + unsigned int flags) +{ + freetype_t freetype; + + /* No flags supported yet. */ + VM_WARN_ON_ONCE(flags); + + freetype.migratetype = mt; + return freetype; +} + +static inline enum migratetype free_to_migratetype(freetype_t freetype) +{ + return freetype.migratetype; +} + +/* Convenience helper, return the freetype modified to have the migratetype. */ +static inline freetype_t freetype_with_migrate(freetype_t freetype, + enum migratetype migratetype) +{ + return migrate_to_freetype(migratetype, freetype_flags(freetype)); +} + #endif /* _LINUX_FREETYPE_H */ diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 66a4cfc2afcb0..301328cbb8449 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -62,39 +62,7 @@ */ #define PAGE_ALLOC_COSTLY_ORDER 3 -enum migratetype { - MIGRATE_UNMOVABLE, - MIGRATE_MOVABLE, - MIGRATE_RECLAIMABLE, - MIGRATE_PCPTYPES, /* the number of types on the pcp lists */ - MIGRATE_HIGHATOMIC = MIGRATE_PCPTYPES, #ifdef CONFIG_CMA - /* - * MIGRATE_CMA migration type is designed to mimic the way - * ZONE_MOVABLE works. Only movable pages can be allocated - * from MIGRATE_CMA pageblocks and page allocator never - * implicitly change migration type of MIGRATE_CMA pageblock. - * - * The way to use it is to change migratetype of a range of - * pageblocks to MIGRATE_CMA which can be done by - * __free_pageblock_cma() function. - */ - MIGRATE_CMA, - __MIGRATE_TYPE_END = MIGRATE_CMA, -#else - __MIGRATE_TYPE_END = MIGRATE_HIGHATOMIC, -#endif -#ifdef CONFIG_MEMORY_ISOLATION - MIGRATE_ISOLATE, /* can't allocate from here */ -#endif - MIGRATE_TYPES -}; - -/* In mm/page_alloc.c; keep in sync also with show_migration_types() there */ -extern const char * const migratetype_names[MIGRATE_TYPES]; - -#ifdef CONFIG_CMA -# define is_migrate_cma(migratetype) unlikely((migratetype) == MIGRATE_CMA) # define is_migrate_cma_page(_page) (get_pageblock_migratetype(_page) == MIGRATE_CMA) /* * __dump_folio() in mm/debug.c passes a folio pointer to on-stack struct folio, @@ -103,27 +71,10 @@ extern const char * const migratetype_names[MIGRATE_TYPES]; # define is_migrate_cma_folio(folio, pfn) \ (get_pfnblock_migratetype(&folio->page, pfn) == MIGRATE_CMA) #else -# define is_migrate_cma(migratetype) false # define is_migrate_cma_page(_page) false # define is_migrate_cma_folio(folio, pfn) false #endif -static inline bool is_migrate_movable(int mt) -{ - return is_migrate_cma(mt) || mt == MIGRATE_MOVABLE; -} - -/* - * Check whether a migratetype can be merged with another migratetype. - * - * It is only mergeable when it can fall back to other migratetypes for - * allocation. See fallbacks[MIGRATE_TYPES][3] in page_alloc.c. - */ -static inline bool migratetype_is_mergeable(int mt) -{ - return mt < MIGRATE_PCPTYPES; -} - #define for_each_free_list(list, zone, order) \ for (order = 0; order < NR_PAGE_ORDERS; order++) \ for (unsigned int idx = 0; \ @@ -131,30 +82,6 @@ static inline bool migratetype_is_mergeable(int mt) idx < NR_FREETYPE_IDXS; \ idx++) -static inline freetype_t migrate_to_freetype(enum migratetype mt, - unsigned int flags) -{ - freetype_t freetype; - - /* No flags supported yet. */ - VM_WARN_ON_ONCE(flags); - - freetype.migratetype = mt; - return freetype; -} - -static inline enum migratetype free_to_migratetype(freetype_t freetype) -{ - return freetype.migratetype; -} - -/* Convenience helper, return the freetype modified to have the migratetype. */ -static inline freetype_t freetype_with_migrate(freetype_t freetype, - enum migratetype migratetype) -{ - return migrate_to_freetype(migratetype, freetype_flags(freetype)); -} - extern int page_group_by_mobility_disabled; freetype_t get_pfnblock_freetype(const struct page *page, unsigned long pfn); -- 2.51.2