From nobody Mon Feb 9 20:30:16 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 349DF309F00 for ; Mon, 2 Feb 2026 19:41:35 +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=1770061296; cv=none; b=SlhhAtghtkkIvc374eRTxmre36dCxhVRh7IKAX/aG8c3102Pi9AaCLCfhivFvHbjZl6RhasL1Pl5b2i2JPVe+TGQr7lESCpyQhE01AZnaV2I0JzSPLYyJfyXLh+DMra4ocPVuelzpaA3MSL6YBqVwuCTWOjvocMvVJsH82I6qIM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770061296; c=relaxed/simple; bh=lwOPe/g7+6yRLxIFHIwh0Mns1KwAYuyxSV/XhDD4v/g=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=IAEs2CuR3QF5mhu9A7u9u+M85g3g2x2pouE29zdPSmfuxRjnkYIaAwMDP6G7OzLQEayOUvG2qRYjDegRBfBnB+8eKpc6O3AO9B9VizfCbreAVERFJETpo6DMHO8sQ8eFsm9cMLlxhSW9sQG1KgZ05XYqtrkVCM2aUV35aLDSKeY= 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=P+1AC4vf; 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="P+1AC4vf" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2a07fa318fdso49479655ad.0 for ; Mon, 02 Feb 2026 11:41:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1770061294; x=1770666094; 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=2xJyNzAFjx6HxtPx+hx1i0rUvha8B/sysQiqMz13rtk=; b=P+1AC4vfwNL+YSVDZx2h8EF5UXO3uMewNUnX5h3VuZ+0d3ZMFADsChKh4VnNcZ4HtS JlLOt07YrPrAYZ55G5UOi2iUig9HYPgO0zznbYhYAfAGUEFehUOCYtB+czqZBt287qIl QXaCbtcbjiw81az8rYUZhSJxdGI1HnVn2wb6vaIdWQOOVHtboudigBIglNTaqx3vEwv6 fdjO4FrVKR7lqKDoSrsmFZUSt3d/7UFQ4YAaAgAcGJXCJGbUwDJnV6AVD8Vl5MfpK5vO jezGhEnOAtC3EJ2vxg4SXYvXgmmNNdv9Z5laDYph7+C5/jyIsC1fL8dev4zX7tASJbka uJNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770061294; x=1770666094; 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=2xJyNzAFjx6HxtPx+hx1i0rUvha8B/sysQiqMz13rtk=; b=NScvqbeqKZRm3N5J1ToA/XC+qSeVXXQUNXAIZGJT8xEP7iNo5Mq9cHqEIeo21CX5++ yTYzZ4UR6KCbppboH0UaqaZoSEkoAJ3cPnRHkCaSCQ62lzFHpJ69xza1a47AQhx/f190 AXLfEbM8bM9DJmuoRIL1zBV7FX98tEmaudPagJPK69EzYFtINTHm0DrsAIwFUXqvElqu gVM96syyQAGJGElVU4lxL1unqpjSVPL1TSaeCYlHY7hzTMYhwnPD85B5r+75E6mMgbkJ 5zhrAdCZM0tTic+vWq/plyW16s04QM4Tz2AE/7pSjvaaOaj3vFv17jb/K2O3+XzMMJlM MCgA== X-Forwarded-Encrypted: i=1; AJvYcCVojNe+kEWld3Z07ZPhTnbgcWRpKj1xy11N4G/uT2A5U4ARSobXkhZirbS60jzsfK6vZojBKeqSNW0Z1Ys=@vger.kernel.org X-Gm-Message-State: AOJu0Yxos7DPWN34whV9cTTwbTfS06XJwk6NsKkpy1gnnKUnFg2hkXC2 5YV51V19S/+x/M4TnZhuR4RowcjOIptnnwwG8jAqRUJS79Eiht6m2Kc2OZ+PYqjfnpWZx7/OW4R nUzs2cs989qF2CQ== X-Received: from plps16.prod.google.com ([2002:a17:902:9890:b0:2a3:29a1:b818]) (user=jiaqiyan job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:1984:b0:2a7:9196:a94e with SMTP id d9443c01a7336-2a8d96a2af7mr109252935ad.15.1770061294535; Mon, 02 Feb 2026 11:41:34 -0800 (PST) Date: Mon, 2 Feb 2026 19:41:25 +0000 In-Reply-To: <20260202194125.2191216-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: <20260202194125.2191216-1-jiaqiyan@google.com> X-Mailer: git-send-email 2.53.0.rc1.225.gd81095ad13-goog Message-ID: <20260202194125.2191216-4-jiaqiyan@google.com> Subject: [PATCH v4 3/3] mm/memory-failure: skip take_page_off_buddy after dissolving HWPoison HugeTLB page 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, boudewijn@delta-utec.com, Jiaqi Yan Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now that HWPoison subpage(s) within HugeTLB page will be rejected by buddy allocator during dissolve_free_hugetlb_folio(), there is no need to drain_all_pages() and take_page_off_buddy() anymore. In fact, calling take_page_off_buddy() after dissolve_free_hugetlb_folio() succeeded returns false, making caller think __page_handle_poison() failed. Add __hugepage_handle_poison() and replace __page_handle_poison() at HugeTLB specific call sites. The being handled HugeTLB page either is free at the moment of try_memory_failure_hugetlb(), or becomes free at the moment of me_huge_page(). Signed-off-by: Jiaqi Yan --- mm/memory-failure.c | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 529a83a325740..58b34f5d2c05d 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -163,6 +163,30 @@ static struct rb_root_cached pfn_space_itree =3D RB_RO= OT_CACHED; static DEFINE_MUTEX(pfn_space_lock); =20 /* + * Only for a HugeTLB page being handled by memory_failure(). The key + * difference to soft_offline() is that, no HWPoison subpage will make + * into buddy allocator after a successful dissolve_free_hugetlb_folio(), + * so take_page_off_buddy() is unnecessary. + */ +static int __hugepage_handle_poison(struct page *page) +{ + struct folio *folio =3D page_folio(page); + + VM_WARN_ON_FOLIO(!folio_test_hwpoison(folio), folio); + + /* + * Can't use dissolve_free_hugetlb_folio() without a reliable + * raw_hwp_list telling which subpage is HWPoison. + */ + if (folio_test_hugetlb_raw_hwp_unreliable(folio)) + /* raw_hwp_list becomes unreliable when kmalloc() fails. */ + return -ENOMEM; + + return dissolve_free_hugetlb_folio(folio); +} + +/* + * Only for a free or HugeTLB page being handled by soft_offline(). * 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, @@ -1174,11 +1198,11 @@ static int me_huge_page(struct page_state *ps, stru= ct page *p) * subpages. */ folio_put(folio); - if (__page_handle_poison(p) > 0) { + if (__hugepage_handle_poison(p)) { + res =3D MF_FAILED; + } else { page_ref_inc(p); res =3D MF_RECOVERED; - } else { - res =3D MF_FAILED; } } =20 @@ -2067,11 +2091,11 @@ static int try_memory_failure_hugetlb(unsigned long= pfn, int flags, int *hugetlb */ if (res =3D=3D 0) { folio_unlock(folio); - if (__page_handle_poison(p) > 0) { + if (__hugepage_handle_poison(p)) { + res =3D MF_FAILED; + } else { page_ref_inc(p); res =3D MF_RECOVERED; - } else { - res =3D MF_FAILED; } return action_result(pfn, MF_MSG_FREE_HUGE, res); } --=20 2.53.0.rc2.204.g2597b5adb4-goog