From nobody Mon Feb 9 12:08:57 2026 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (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 55C8733D4F2 for ; Fri, 19 Dec 2025 18:34:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766169245; cv=none; b=KNIRQWovchGyMC8G1QLNi2FBPrfzGs8LhmHk9zTH2AMYAK8XaPxxe6LvJwz5HzcIV5slG8rDSFpb4GYjvSKut4qcnxYYRxDmfnCw1MeXXDp5Rv4om7t4O7Kgfo+BKTV+da0ScdC7XKaThH/cZY/VMGxbALaJJLUx/caPq+uQdYg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766169245; c=relaxed/simple; bh=QrLZ8icNCwPgbzFit/hzKfnQS3FeTni6NOWImh/i+9I=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=uaT4kWx63LxiOpTFZne/EMmD2TWNw4NgxWsAASND4AnLPNMfQoR/vEYp+8EOnZk2rAkzLi60MH1xjfqh/lIPB1UdwYLyyjqGzJaNNt7vayQnozNmy4KWZ62CJp1/2p+cjdB3sajUQQIPiB7NTjwDdoH7sdgZSEyx6BMJpY+mQQY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jiaqiyan.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=d7N8pOVu; arc=none smtp.client-ip=209.85.214.202 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--jiaqiyan.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="d7N8pOVu" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2a07fa318fdso34297365ad.0 for ; Fri, 19 Dec 2025 10:34:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1766169242; x=1766774042; 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=dexQnRTVXD+ocEkT49jxHkdd8wk4eYUcAZvG8cXVntY=; b=d7N8pOVuiPrC3lGlqpgt4njmOTgj+8ntRNt9Pw+03BgJpRM9IrvXjUGKsfjE6TvbgD 2vOtqeQ29Hd8hk74Xty4Swhlj/o1uaNDcmHdZTMaxgxYW3AVYZZ41JZK9rmk1u7SwNum 0AVMcEPzWB9PXw2/n4OS5y0NIrmLD+ZNYlVjCxZO+pbICF4ykEPd6RcPcssQ62Q6iWI8 W9MXi/H/VfwdJeeFKOrp/k+4LcpMe9zG41HNBujLL8QCZRvqJdQxuKbEv5O8EbW9SIBe z1cxPLD/QvkfPphFcWJhP8oweENFj9uYi/cfC75nuKW7D2JC/eqmrrOFAzMcZkVgDs/U AxBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766169242; x=1766774042; 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=dexQnRTVXD+ocEkT49jxHkdd8wk4eYUcAZvG8cXVntY=; b=KzKdnJDCKIdtEFW5Kh2RK/dTB+X49XFuMzLsbZagZbe5slq4dNHbiF2L01cerAEdyQ 0zdgA7ZxJ97IvGxRFWEB71dn/YbbaX0kVxJgvxX76vLmRK/gTeHtXFPcLmCobWkfvUNA LjbKl7yoFKvnddjguadXpnogQYAN2HBIWrxEOAIv1evK7niGv4Smy1yezSMg7wDo0q3K YGySAI2fkqu8HK1PgY/SM7kBfFs5KIT23dwuBqKbf8DrvfygyBf8nWzu2EoK1delrkzj prATKkuhkS+IOIJmbvIUi+LD3lKCzwH8b0l9710ClJwXeTyXrYtKjceKtuzU+RXdjmEp krGw== X-Forwarded-Encrypted: i=1; AJvYcCXKJCyeowroaPyWUUvDVs285sxI+MPhgdnzP0X/+g9cNvB6oRgJmq3SAVvxgavFCBkpubekyghV8JkqLtg=@vger.kernel.org X-Gm-Message-State: AOJu0Yy1zvSRcf1DyZNS5tp69fJ34+NkW/xfUReHVsAYCQTg0sHZZE+9 SeiXhi/OufwcUgCsVgWphKUcHj0oY8IOCbYNcAOIoejrNMp1+CYAFLKPiR+uP9VzKAj0kim5jNo WJitR6nDhEAqBbg== X-Google-Smtp-Source: AGHT+IGpZ2pGRoO+xCgyW/fLk9ttUQoZ2NHr3ntaK2W3TUshAxXp/I0SeosreA/3425khqCO+Yb9NQ3gG+U3Yw== X-Received: from plbmf11.prod.google.com ([2002:a17:902:fc8b:b0:2a1:5f23:7ddd]) (user=jiaqiyan job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:2448:b0:2a0:b7d3:1bf4 with SMTP id d9443c01a7336-2a2f2212833mr41416655ad.5.1766169242492; Fri, 19 Dec 2025 10:34:02 -0800 (PST) Date: Fri, 19 Dec 2025 18:33:46 +0000 In-Reply-To: <20251219183346.3627510-1-jiaqiyan@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251219183346.3627510-1-jiaqiyan@google.com> X-Mailer: git-send-email 2.52.0.322.g1dd061c0dc-goog Message-ID: <20251219183346.3627510-4-jiaqiyan@google.com> Subject: [PATCH v2 3/3] mm/memory-failure: simplify __page_handle_poison From: Jiaqi Yan To: jackmanb@google.com, hannes@cmpxchg.org, linmiaohe@huawei.com, ziy@nvidia.com, harry.yoo@oracle.com, willy@infradead.org Cc: nao.horiguchi@gmail.com, david@redhat.com, lorenzo.stoakes@oracle.com, william.roche@oracle.com, tony.luck@intel.com, wangkefeng.wang@huawei.com, jane.chu@oracle.com, akpm@linux-foundation.org, osalvador@suse.de, muchun.song@linux.dev, rientjes@google.com, duenwen@google.com, jthoughton@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Liam.Howlett@oracle.com, vbabka@suse.cz, rppt@kernel.org, surenb@google.com, mhocko@suse.com, Jiaqi Yan Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now that no HWPoison page will be given away to buddy allocator at the end of dissolve_free_hugetlb_folio, there is no need to drain_all_pages and take_page_off_buddy anymore, so remove them. Also make __page_handle_poison return either 0 for success or negative for failure, following the convention for functions that perform an action. Signed-off-by: Jiaqi Yan --- mm/memory-failure.c | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index d204de6c9792a..54ea840ded162 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -164,33 +164,12 @@ static DEFINE_MUTEX(pfn_space_lock); =20 /* * Return values: - * 1: the page is dissolved (if needed) and taken off from buddy, - * 0: the page is dissolved (if needed) and not taken off from buddy, + * =3D 0: the page is dissolved (if needed) * < 0: failed to dissolve. */ static int __page_handle_poison(struct page *page) { - int ret; - - /* - * zone_pcp_disable() can't be used here. It will - * hold pcp_batch_high_lock and dissolve_free_hugetlb_folio() might hold - * cpu_hotplug_lock via static_key_slow_dec() when hugetlb vmemmap - * optimization is enabled. This will break current lock dependency - * chain and leads to deadlock. - * Disabling pcp before dissolving the page was a deterministic - * approach because we made sure that those pages cannot end up in any - * PCP list. Draining PCP lists expels those pages to the buddy system, - * but nothing guarantees that those pages do not get back to a PCP - * queue if we need to refill those. - */ - ret =3D dissolve_free_hugetlb_folio(page_folio(page)); - if (!ret) { - drain_all_pages(page_zone(page)); - ret =3D take_page_off_buddy(page); - } - - return ret; + return dissolve_free_hugetlb_folio(page_folio(page)); } =20 static bool page_handle_poison(struct page *page, bool hugepage_or_freepag= e, bool release) @@ -200,7 +179,7 @@ static bool page_handle_poison(struct page *page, bool = hugepage_or_freepage, boo * Doing this check for free pages is also fine since * dissolve_free_hugetlb_folio() returns 0 for non-hugetlb folios as wel= l. */ - if (__page_handle_poison(page) <=3D 0) + if (__page_handle_poison(page) < 0) /* * We could fail to take off the target page from buddy * for example due to racy page allocation, but that's @@ -1174,7 +1153,7 @@ static int me_huge_page(struct page_state *ps, struct= page *p) * subpages. */ folio_put(folio); - if (__page_handle_poison(p) > 0) { + if (!__page_handle_poison(p)) { page_ref_inc(p); res =3D MF_RECOVERED; } else { @@ -2067,7 +2046,7 @@ static int try_memory_failure_hugetlb(unsigned long p= fn, int flags, int *hugetlb */ if (res =3D=3D 0) { folio_unlock(folio); - if (__page_handle_poison(p) > 0) { + if (!__page_handle_poison(p)) { page_ref_inc(p); res =3D MF_RECOVERED; } else { --=20 2.52.0.322.g1dd061c0dc-goog