From nobody Thu Apr 2 17:40:22 2026 Received: from mail-qv1-f65.google.com (mail-qv1-f65.google.com [209.85.219.65]) (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 36AAF35F8C4 for ; Wed, 11 Feb 2026 21:54:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770846898; cv=none; b=QuRBa+LPQotorgkmOs9cO8rcdd46FSTPXI7xnG3ng6EZ1LBtDJGMAt+T1+y7mtPV0kVq+PLa8RW+HMQWeN48OIqoZjN0w5evm+CPV5nV+PDeZDLZRf4+TQiFIbmO1TtE3weD4kGg89dhYBmtNxY0WaJdePh65UgooUN73j6xIAU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770846898; c=relaxed/simple; bh=KjN2am+60FyqL6Aw8fMJuBlsvtKu+gSJQr1kSgmtVPQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=kJ//9O1urnWXDhkisuFLO9qB6ZdjwOwcn1zsmQbkUeQAQIiCZulJyLZ9037W0Lmt+GJ0MY666WPfAJTm+zQJQ2nE6PI5eIOR7EGbOREAI3bPqLUYOY4A8P1VScZ4EHFoiIB6ZtywZ5+KEybog2mEsp2ZT0kIQeOotLLwvXzqagg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net; spf=pass smtp.mailfrom=gourry.net; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b=Gc2PyINH; arc=none smtp.client-ip=209.85.219.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gourry.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b="Gc2PyINH" Received: by mail-qv1-f65.google.com with SMTP id 6a1803df08f44-8946f12b1cfso80273216d6.0 for ; Wed, 11 Feb 2026 13:54:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1770846895; x=1771451695; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=wY7FoCoT6W3h+FhLeVYQDgJWzgS3oWiQlGuojbJGq/I=; b=Gc2PyINHKvcQribH74dAptXxwn9ixQmCAALKf+1qt7Tr4UkiyzrCYjDanjcdXUa5gB kbPqXjMDJqdQmE29oKu17r1K4OmJFDfbm+Lvzr2b0p1+B74kIAqhiZsV8FbxG3jIEphh UEO9L7ZCmVYTf8ehJtjVjSGRKEPitvhOXnM5thj5q+tZH6e06m6wtyDEQvg3cUXxZ5ex x0EoH7/1zWVBltBuJOf6LQhq10I4vJMQzXAmED3g1TEVaE9P7fYaiQOdNi1FyR/F1fFN FYikpMgy7pKIXxYTQkZRTxDVzI912KoBaGwJwF1dsDey6xN3ROrkhwbVdQX27vqbEfyS 2gjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770846895; x=1771451695; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=wY7FoCoT6W3h+FhLeVYQDgJWzgS3oWiQlGuojbJGq/I=; b=GUxxceA2e2GlQbf5RQ83CecoDzZnwL+x6Irppwsrxq0ZgocMYS9MWO5KrOLaArS6Pb Nj3xmIOkirgLonjiaAQ0giqkvlk5E7oWIn+RycjCG3CiIC+dWzI6GndmzcVrfvZ7cDLi PKASc2joQPW9axetJEcLbeUEpLHLz6sMR5rIUjZFVyJ++D9pflSaVER70aG00N7n3Wa1 rgAvLIZPwH7EEHQ5gLuym5LKDMEU8jg0Vz8ZRshSSO74SwxNDNpClQPVjziOA6ssJiEQ cceK8N6Ud3dkUd8g14he9ENa73lnIdSsTIJzzBYTiNURm0MVjN5UaKW+2Xpw82eZP8+6 nDgQ== X-Forwarded-Encrypted: i=1; AJvYcCWJqzHJctUwctDKem3t/kQObTrvFt61Y7AmmQ+N2YmGULZmcaNbHwOGQD0Q2DY2R2ErQkwvpehI85gcqDM=@vger.kernel.org X-Gm-Message-State: AOJu0YzdjIRbwShiiS0vy8iV4AfP8gLFsDA8/b96u3Hgw95H6obzt6Sy JeuXCRPy1Q5ajahXwQHpj2vTsAQtE/CjLiAlVun1H8Er90hblmJclM5oi+tKeR1t0W8= X-Gm-Gg: AZuq6aJIiqp8cRx23jRJx8yDZSDG9YBRXQQdukipakvZxkMKAd70pTII5q1RS4ThxQZ xxkezpxyrR8P9GZDmuBDBW+lek8Amjrmldtmf/dxDd38hFey6dc/MZT75lKBRMOL/UwKN2vUT9z eJr0ULx/ragDMwi8iyJHKE+F3vilcuM9RnkmphPZPRwRGiR3c8wIrMgORUl2boyYrPi7AJ0mjh1 0q60cFTPpKbgAsxYXhIKP6Gzx0aIEGMii8rlbYlJ5eg9P2BMfUFEhUEKZfMcatPXhv0IqHqAjA6 JFa+DamZ0iNN13wXnRP0WfFKspIsG009J2mQPX0aohQ+eAgQvBkw/b4ub1U7rxyWcgTZDxIgy8o J8aRyBLXsW5zvUuZw0jGCGtY40lu8vD+vw+J8MEEow1HTbj/Hmz4PcONBM4kqoEYBY511jyHVo2 SCorDb5pG8f+7SJomESUIrgQ9kiM5H0Q3c3CyR/OK2535nqwrtQYdqKCaNPwe1SHfRDu0D8x/i/ 9jGVLB4MNRoNZ0= X-Received: by 2002:a05:6214:258a:b0:893:42f1:ebb with SMTP id 6a1803df08f44-897279b27a6mr15748206d6.24.1770846894943; Wed, 11 Feb 2026 13:54:54 -0800 (PST) Received: from gourry-fedora-PF4VCD3F.lan (pool-96-255-20-138.washdc.ftas.verizon.net. [96.255.20.138]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8971cdb5f26sm23742686d6.42.2026.02.11.13.54.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Feb 2026 13:54:54 -0800 (PST) From: Gregory Price To: linux-mm@kvack.org Cc: linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, david@kernel.org, osalvador@suse.de, gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org, akpm@linux-foundation.org, lorenzo.stoakes@oracle.com, Liam.Howlett@oracle.com, vbabka@suse.cz, rppt@kernel.org, surenb@google.com, mhocko@suse.com, Jonathan Cameron Subject: [PATCH] mm: name the anonymous MMOP enum as enum mmop Date: Wed, 11 Feb 2026 16:54:47 -0500 Message-ID: <20260211215447.2194189-1-gourry@gourry.net> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Give the MMOP enum (MMOP_OFFLINE, MMOP_ONLINE, etc) a proper type name so the compiler can help catch invalid values being assigned to variables of this type. Leave the existing functions returning int alone to allow for value-or-error pattern to remain unchanged without churn. mmop_default_online_type is left as int because it uses the -1 sentinal value to signal it hasn't been initialized yet. Keep the uint8_t buffer in offline_and_remove_memory() as-is for space efficiency, with an explicit cast when we consume the value. Move the enum definition before the CONFIG_MEMORY_HOTPLUG guard so it is unconditionally available for struct memory_block in memory.h. No functional change. Link: https://lore.kernel.org/linux-mm/3424eba7-523b-4351-abd0-3a888a3e5e61= @kernel.org/ Suggested-by: Jonathan Cameron Suggested-by: "David Hildenbrand (arm)" Signed-off-by: Gregory Price Acked-by: David Hildenbrand (Arm) Reviewed-by: Ben Cheatham Reviewed-by: Dave Jiang Reviewed-by: Davidlohr Bueso Reviewed-by: Jonathan Cameron --- drivers/base/memory.c | 2 +- include/linux/memory.h | 3 ++- include/linux/memory_hotplug.h | 16 ++++++++-------- mm/memory_hotplug.c | 10 +++++----- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 751f248ca4a8..3753ca80069d 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -452,7 +452,7 @@ static ssize_t phys_device_show(struct device *dev, static int print_allowed_zone(char *buf, int len, int nid, struct memory_group *group, unsigned long start_pfn, unsigned long nr_pages, - int online_type, struct zone *default_zone) + enum mmop online_type, struct zone *default_zone) { struct zone *zone; =20 diff --git a/include/linux/memory.h b/include/linux/memory.h index faeaa921e55b..5bb5599c6b2b 100644 --- a/include/linux/memory.h +++ b/include/linux/memory.h @@ -19,6 +19,7 @@ #include #include #include +#include =20 #define MIN_MEMORY_BLOCK_SIZE (1UL << SECTION_SIZE_BITS) =20 @@ -77,7 +78,7 @@ enum memory_block_state { struct memory_block { unsigned long start_section_nr; enum memory_block_state state; /* serialized by the dev->lock */ - int online_type; /* for passing data to online routine */ + enum mmop online_type; /* for passing data to online routine */ int nid; /* NID for this memory block */ /* * The single zone of this memory block if all PFNs of this memory block diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index f2f16cdd73ee..e77ef3d7ff73 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -16,11 +16,8 @@ struct resource; struct vmem_altmap; struct dev_pagemap; =20 -#ifdef CONFIG_MEMORY_HOTPLUG -struct page *pfn_to_online_page(unsigned long pfn); - /* Types for control the zone type of onlined and offlined memory */ -enum { +enum mmop { /* Offline the memory. */ MMOP_OFFLINE =3D 0, /* Online the memory. Zone depends, see default_zone_for_pfn(). */ @@ -31,6 +28,9 @@ enum { MMOP_ONLINE_MOVABLE, }; =20 +#ifdef CONFIG_MEMORY_HOTPLUG +struct page *pfn_to_online_page(unsigned long pfn); + /* Flags for add_memory() and friends to specify memory hotplug details. */ typedef int __bitwise mhp_t; =20 @@ -286,8 +286,8 @@ static inline void __remove_memory(u64 start, u64 size)= {} =20 #ifdef CONFIG_MEMORY_HOTPLUG /* Default online_type (MMOP_*) when new memory blocks are added. */ -extern int mhp_get_default_online_type(void); -extern void mhp_set_default_online_type(int online_type); +extern enum mmop mhp_get_default_online_type(void); +extern void mhp_set_default_online_type(enum mmop online_type); extern void __ref free_area_init_core_hotplug(struct pglist_data *pgdat); extern int __add_memory(int nid, u64 start, u64 size, mhp_t mhp_flags); extern int add_memory(int nid, u64 start, u64 size, mhp_t mhp_flags); @@ -310,8 +310,8 @@ extern void sparse_remove_section(unsigned long pfn, un= signed long nr_pages, struct vmem_altmap *altmap); extern struct page *sparse_decode_mem_map(unsigned long coded_mem_map, unsigned long pnum); -extern struct zone *zone_for_pfn_range(int online_type, int nid, - struct memory_group *group, unsigned long start_pfn, +extern struct zone *zone_for_pfn_range(enum mmop online_type, + int nid, struct memory_group *group, unsigned long start_pfn, unsigned long nr_pages); extern int arch_create_linear_mapping(int nid, u64 start, u64 size, struct mhp_params *params); diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index a63ec679d861..41f48f493b8e 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -221,7 +221,7 @@ void put_online_mems(void) bool movable_node_enabled =3D false; =20 static int mhp_default_online_type =3D -1; -int mhp_get_default_online_type(void) +enum mmop mhp_get_default_online_type(void) { if (mhp_default_online_type >=3D 0) return mhp_default_online_type; @@ -240,7 +240,7 @@ int mhp_get_default_online_type(void) return mhp_default_online_type; } =20 -void mhp_set_default_online_type(int online_type) +void mhp_set_default_online_type(enum mmop online_type) { mhp_default_online_type =3D online_type; } @@ -1046,7 +1046,7 @@ static inline struct zone *default_zone_for_pfn(int n= id, unsigned long start_pfn return movable_node_enabled ? movable_zone : kernel_zone; } =20 -struct zone *zone_for_pfn_range(int online_type, int nid, +struct zone *zone_for_pfn_range(enum mmop online_type, int nid, struct memory_group *group, unsigned long start_pfn, unsigned long nr_pages) { @@ -2305,7 +2305,7 @@ EXPORT_SYMBOL_GPL(remove_memory); =20 static int try_offline_memory_block(struct memory_block *mem, void *arg) { - uint8_t online_type =3D MMOP_ONLINE_KERNEL; + enum mmop online_type =3D MMOP_ONLINE_KERNEL; uint8_t **online_types =3D arg; struct page *page; int rc; @@ -2338,7 +2338,7 @@ static int try_reonline_memory_block(struct memory_bl= ock *mem, void *arg) int rc; =20 if (**online_types !=3D MMOP_OFFLINE) { - mem->online_type =3D **online_types; + mem->online_type =3D (enum mmop)**online_types; rc =3D device_online(&mem->dev); if (rc < 0) pr_warn("%s: Failed to re-online memory: %d", --=20 2.47.3