public inbox for patches@lists.linux.dev
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev, Hao Li <hao.li@linux.dev>,
	"Harry Yoo (Oracle)" <harry@kernel.org>,
	"Vlastimil Babka (SUSE)" <vbabka@kernel.org>,
	Joshua Hahn <joshua.hahnjy@gmail.com>,
	"David Hildenbrand (Arm)" <david@kernel.org>,
	Oscar Salvador <osalvador@suse.de>,
	Vlastimil Babka <vbabka@suse.cz>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH 6.19 51/86] mm/memory_hotplug: maintain N_NORMAL_MEMORY during hotplug
Date: Mon, 13 Apr 2026 17:59:58 +0200	[thread overview]
Message-ID: <20260413155733.470910109@linuxfoundation.org> (raw)
In-Reply-To: <20260413155731.568515178@linuxfoundation.org>

6.19-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Hao Li <hao.li@linux.dev>

commit 2ecbe06abf9bfb2261cd6464a6bc3a3615625402 upstream.

N_NORMAL_MEMORY is initialized from zone population at boot, but memory
hotplug currently only updates N_MEMORY.  As a result, a node that gains
normal memory via hotplug can remain invisible to users iterating over
N_NORMAL_MEMORY, while a node that loses its last normal memory can stay
incorrectly marked as such.

The most visible effect is that
/sys/devices/system/node/has_normal_memory does not report a node even
after that node has gained normal memory via hotplug.

Also, list_lru-based shrinkers can undercount objects on such a node
and may skip reclaim on that node entirely, which can lead to a higher
memory footprint than expected.

Restore N_NORMAL_MEMORY maintenance directly in online_pages() and
offline_pages().  Set the bit when a node that currently lacks normal
memory onlines pages into a zone <= ZONE_NORMAL, and clear it when
offlining removes the last present pages from zones <= ZONE_NORMAL.

This restores the intended semantics without bringing back the old
status_change_nid_normal notifier plumbing which was removed in
8d2882a8edb8.

Current users that benefit include list_lru, zswap, nfsd filecache,
hugetlb_cgroup, and has_normal_memory sysfs reporting.

Link: https://lkml.kernel.org/r/20260330035941.518186-1-hao.li@linux.dev
Fixes: 8d2882a8edb8 ("mm,memory_hotplug: remove status_change_nid_normal and update documentation")
Signed-off-by: Hao Li <hao.li@linux.dev>
Reviewed-by: Harry Yoo (Oracle) <harry@kernel.org>
Acked-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Reviewed-by: Joshua Hahn <joshua.hahnjy@gmail.com>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 mm/memory_hotplug.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1209,6 +1209,13 @@ int online_pages(unsigned long pfn, unsi
 
 	if (node_arg.nid >= 0)
 		node_set_state(nid, N_MEMORY);
+	/*
+	 * Check whether we are adding normal memory to the node for the first
+	 * time.
+	 */
+	if (!node_state(nid, N_NORMAL_MEMORY) && zone_idx(zone) <= ZONE_NORMAL)
+		node_set_state(nid, N_NORMAL_MEMORY);
+
 	if (need_zonelists_rebuild)
 		build_all_zonelists(NULL);
 
@@ -1908,6 +1915,8 @@ int offline_pages(unsigned long start_pf
 	unsigned long flags;
 	char *reason;
 	int ret;
+	unsigned long normal_pages = 0;
+	enum zone_type zt;
 
 	/*
 	 * {on,off}lining is constrained to full memory sections (or more
@@ -2056,6 +2065,17 @@ int offline_pages(unsigned long start_pf
 	init_per_zone_wmark_min();
 
 	/*
+	 * Check whether this operation removes the last normal memory from
+	 * the node. We do this before clearing N_MEMORY to avoid the possible
+	 * transient "!N_MEMORY && N_NORMAL_MEMORY" state.
+	 */
+	if (zone_idx(zone) <= ZONE_NORMAL) {
+		for (zt = 0; zt <= ZONE_NORMAL; zt++)
+			normal_pages += pgdat->node_zones[zt].present_pages;
+		if (!normal_pages)
+			node_clear_state(node, N_NORMAL_MEMORY);
+	}
+	/*
 	 * Make sure to mark the node as memory-less before rebuilding the zone
 	 * list. Otherwise this node would still appear in the fallback lists.
 	 */



  parent reply	other threads:[~2026-04-13 16:05 UTC|newest]

Thread overview: 100+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-13 15:59 [PATCH 6.19 00/86] 6.19.13-rc1 review Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 01/86] usb: typec: ucsi: skip connector validation before init Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 02/86] wifi: rt2x00usb: fix devres lifetime Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 03/86] xfrm_user: fix info leak in build_report() Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 04/86] net: rfkill: prevent unlimited numbers of rfkill events from being created Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 05/86] Revert "ALSA: hda/realtek: Add quirk for Gigabyte Technology to fix headphone" Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 06/86] ALSA: hda/intel: enforce stricter period-size alignment for Intel NVL Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 07/86] Revert "mptcp: add needs_id for netlink appending addr" Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 08/86] mptcp: fix slab-use-after-free in __inet_lookup_established Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 09/86] seg6: separate dst_cache for input and output paths in seg6 lwtunnel Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 10/86] Input: uinput - fix circular locking dependency with ff-core Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 11/86] Input: uinput - take event lock when submitting FF request "event" Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 12/86] MIPS: Always record SEGBITS in cpu_data.vmbits Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 13/86] MIPS: mm: Suppress TLB uniquification on EHINV hardware Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 14/86] MIPS: mm: Rewrite TLB uniquification for the hidden bit feature Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 15/86] btrfs: remove pointless out labels from extent-tree.c Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 16/86] btrfs: fix incorrect return value after changing leaf in lookup_extent_data_ref() Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 17/86] i2c: imx: zero-initialize dma_slave_config for eDMA Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 18/86] netfilter: nft_ct: fix use-after-free in timeout object destroy Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 19/86] firmware: thead: Fix buffer overflow and use standard endian macros Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 20/86] workqueue: Add pool_workqueue to pending_pwqs list when unplugging multiple inactive works Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 21/86] modpost: Declare extra_warn with unused attribute Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 22/86] xfrm: clear trailing padding in build_polexpire() Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 23/86] xfrm: hold dev ref until after transport_finish NF_HOOK Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 24/86] tipc: fix bc_ackers underflow on duplicate GRP_ACK_MSG Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 25/86] kbuild: modules-cpio-pkg: Respect INSTALL_MOD_PATH Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 26/86] ASoC: SOF: Intel: hda: modify period size constraints for ACE4 Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 27/86] wifi: brcmsmac: Fix dma_free_coherent() size Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 28/86] x86/mce/amd: Filter bogus hardware errors on Zen3 clients Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 29/86] platform/x86: ISST: Reset core count to 0 Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 30/86] platform/x86/intel-uncore-freq: Handle autonomous UFS status bit Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 31/86] Revert "arm64: dts: rockchip: Further describe the WiFi for the Pinebook Pro" Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 32/86] Revert "arm64: dts: imx8mq-librem5: Set the DVS voltages lower" Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 33/86] arm64: dts: imx8mq-librem5: Bump BUCK1 suspend voltage up to 0.85V Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 34/86] arm64: dts: renesas: sparrow-hawk: Reserve first 128 MiB of DRAM Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 35/86] arm64: dts: hisilicon: poplar: Correct PCIe reset GPIO polarity Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 36/86] arm64: dts: hisilicon: hi3798cv200: Add missing dma-ranges Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 37/86] liveupdate: propagate file deserialization failures Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 38/86] nfc: pn533: allocate rx skb before consuming bytes Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 39/86] batman-adv: reject oversized global TT response buffers Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 40/86] X.509: Fix out-of-bounds access when parsing extensions Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 41/86] EDAC/mc: Fix error path ordering in edac_mc_alloc() Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 42/86] net/tls: fix use-after-free in -EBUSY error path of tls_do_encryption Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 43/86] net: altera-tse: fix skb leak on DMA mapping error in tse_start_xmit() Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 44/86] batman-adv: hold claim backbone gateways by reference Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 45/86] drm/i915/gt: fix refcount underflow in intel_engine_park_heartbeat Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 46/86] drm/i915/psr: Do not use pipe_src as borders for SU area Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 47/86] net/mlx5: Update the list of the PCI supported devices Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 48/86] pmdomain: imx8mp-blk-ctrl: Keep the NOC_HDCP clock enabled Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 49/86] igb: remove napi_synchronize() in igb_down() Greg Kroah-Hartman
2026-04-13 15:59 ` [PATCH 6.19 50/86] mm/vma: fix memory leak in __mmap_region() Greg Kroah-Hartman
2026-04-13 15:59 ` Greg Kroah-Hartman [this message]
2026-04-13 15:59 ` [PATCH 6.19 52/86] mm/damon/sysfs: dealloc repeat_call_control if damon_call() fails Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 53/86] mm/damon/stat: deallocate damon_call() failure leaking damon_ctx Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 54/86] mmc: vub300: fix NULL-deref on disconnect Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 55/86] mmc: vub300: fix use-after-free " Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 56/86] net: qualcomm: qca_uart: report the consumed byte on RX skb allocation failure Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 57/86] net: stmmac: fix integer underflow in chain mode Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 58/86] mm: filemap: fix nr_pages calculation overflow in filemap_map_pages() Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 59/86] idpf: fix PREEMPT_RT raw/bh spinlock nesting for async VC handling Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 60/86] idpf: improve locking around idpf_vc_xn_push_free() Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 61/86] idpf: set the payload size before calling the async handler Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 62/86] net: lan966x: fix page_pool error handling in lan966x_fdma_rx_alloc_page_pool() Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 63/86] net: lan966x: fix page pool leak in error paths Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 64/86] net: lan966x: fix use-after-free and leak in lan966x_fdma_reload() Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 65/86] rxrpc: Fix key quota calculation for multitoken keys Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 66/86] rxrpc: Fix key parsing memleak Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 67/86] rxrpc: Fix anonymous key handling Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 68/86] rxrpc: Fix call removal to use RCU safe deletion Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 69/86] rxrpc: Fix RxGK token loading to check bounds Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 70/86] rxrpc: Fix use of wrong skb when comparing queued RESP challenge serial Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 71/86] rxrpc: Fix rack timer warning to report unexpected mode Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 72/86] rxrpc: Fix key reference count leak from call->key Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 73/86] rxrpc: Fix to request an ack if window is limited Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 74/86] rxrpc: Only put the call ref if one was acquired Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 75/86] rxrpc: reject undecryptable rxkad response tickets Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 76/86] rxrpc: fix RESPONSE authenticator parser OOB read Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 77/86] rxrpc: fix oversized RESPONSE authenticator length check Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 78/86] rxrpc: fix reference count leak in rxrpc_server_keyring() Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 79/86] rxrpc: Fix key/keyring checks in setsockopt(RXRPC_SECURITY_KEY/KEYRING) Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 80/86] rxrpc: Fix missing error checks for rxkad encryption/decryption failure Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 81/86] rxrpc: Fix integer overflow in rxgk_verify_response() Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 82/86] rxrpc: Fix leak of rxgk context " Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 83/86] rxrpc: Fix buffer overread in rxgk_do_verify_authenticator() Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 84/86] rxrpc: only handle RESPONSE during service challenge Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 85/86] rxrpc: proc: size address buffers for %pISpc output Greg Kroah-Hartman
2026-04-13 16:00 ` [PATCH 6.19 86/86] net: skb: fix cross-cache free of KFENCE-allocated skb head Greg Kroah-Hartman
2026-04-13 17:01 ` [PATCH 6.19 00/86] 6.19.13-rc1 review Ronald Warsow
2026-04-13 17:43 ` Brett A C Sheffield
2026-04-13 19:46 ` Florian Fainelli
2026-04-14  7:54 ` Jon Hunter
2026-04-14 11:25 ` Ron Economos
2026-04-14 11:26 ` Takeshi Ogasawara
2026-04-14 17:42 ` Shuah Khan
2026-04-14 18:17 ` Mark Brown
2026-04-14 18:21 ` Miguel Ojeda
2026-04-14 23:34 ` Peter Schneider
2026-04-15  2:19 ` Barry K. Nathan
2026-04-15  3:47 ` Shung-Hsi Yu
2026-04-15 12:26 ` Dileep malepu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260413155733.470910109@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=hao.li@linux.dev \
    --cc=harry@kernel.org \
    --cc=joshua.hahnjy@gmail.com \
    --cc=osalvador@suse.de \
    --cc=patches@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=vbabka@kernel.org \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox