From nobody Mon Jun 8 08:35:32 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 009823264DE for ; Sun, 31 May 2026 05:58:33 +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=1780207115; cv=none; b=jzhJNY6/CxSgzEXWRhbiSHt8nV3mpLlom4FVBQDFFTwDkd96DYId71S/fD/FZv89cnKqwFXUyaQrGJwa3F2Y9ExsW/qA6Hgm+zRP2CvvrcW4LW1KQw9Cy40K1/eMZJFobycQgHcYOsY9Qovcw68b9+ZJyEVEwRVMeV2BMzo3N+0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780207115; c=relaxed/simple; bh=oJTbJ4rC3HckIGNYnW+CgN8+OfWbnuHbTistF1Nq/zs=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=b5LjrzJEmxGQuQM5ysGPnFax4cPloxUBboAoI8juEn1cXwJ3YAQiqb4BNekkUBsiBwEHI/jabtqvejPq+sCen5dMtbh6jZefj81sf30IljTCpyJbSVa5SZLx6MPl3URDzDZY04HAGkVmWqbVBQAOPyiSWmS8RnJlL+RhgsMQIiU= 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=aGFpMVGG; 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="aGFpMVGG" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2bf0b7425bbso56164875ad.0 for ; Sat, 30 May 2026 22:58:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780207113; x=1780811913; 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=snShNS8B0A/roLa9I0WH5+4cW+eeLsBmpxsgxamM+Gw=; b=aGFpMVGGfFXQC609VFlyGu2dsB18l6+uNgaMgfG83UvmrqzXHZk8HNe+1v22csIxTh e6zBkwEFk67m4euNNS0y3soXuUpPA7e1iqStgsIAgzd4HstQOgItpj4jOd72/aHuolYH TwxNjVL/8HT02LIF1UYQ5g4hZIuYKY1pVFU6wCHrs2eSUSD2uSsjA1cVBwEyi5YZoyH0 JBXWAIQTp+qp6VTXyAnmkwFD07EpFYUonUMJG+F3/FrkQMgOll9iXlG64abt88mgMfPn 7auUjLJ9qUlfDYSMMzUfIn+TItE3oZk05Eymswrc9B05TQ145lXn8jYA3OvTmN8t9GR4 FneA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780207113; x=1780811913; 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=snShNS8B0A/roLa9I0WH5+4cW+eeLsBmpxsgxamM+Gw=; b=ap/hglfpvTK2KjelBmpyu/mNTMwjXNm29/ktPFYUzn9FdL2F1H7TY8hxj4bXP+Hz4/ KeXUjHHZnQ39Cn5vXYcACUEXInr0kKQ/LbSe87P/rPxQb7POpUg121OE4PhJ7E+8CXYf 3RWO2Cpz0qOKXNWM2EmebooPXy/uda8EK+d6+E8oO8qSLBYhW9fikP4XC9YrqI+sjAiR cnK1sbGUtmNdEYD22BFzFX6/PsNpQij/oBCirZ6APeIqlnn1E43+KbbBuqCxJAmfCq0o 5gJLVoBVsqU/X1A6J3iLZSzzDVyTyZx/RKAkrfugF3al5uUT14VDJ4V3DooC3byrdW/c u0aw== X-Forwarded-Encrypted: i=1; AFNElJ9Qq8jcXqM70/Y8S9KBh2q6MnFV0no8EJGLUncWm2VktyPft/aep4irADoxe7qK612An0vABwL6hq1elzI=@vger.kernel.org X-Gm-Message-State: AOJu0YxVe/WfP4oKgNQmlOXv0Yv5dTxjt5lztyOE3Ap6XEa09TP2GW7D 11NnA/nVFKjn95pSOmKc6i4d0o6hlDt1meucThoW4aHK8gtgtzBczaUiI1l0k56J7jxFVyJa74F J7We8eq3kxBgRnQ== X-Received: from plcp19.prod.google.com ([2002:a17:902:e353:b0:2bd:7a0a:2d41]) (user=jiaqiyan job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:e88e:b0:2c0:a3dd:4e6c with SMTP id d9443c01a7336-2c0a3dd4f17mr55603535ad.38.1780207113137; Sat, 30 May 2026 22:58:33 -0700 (PDT) Date: Sun, 31 May 2026 05:58:26 +0000 In-Reply-To: <20260531055829.3636554-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: <20260531055829.3636554-1-jiaqiyan@google.com> X-Mailer: git-send-email 2.54.0.823.g6e5bcc1fc9-goog Message-ID: <20260531055829.3636554-2-jiaqiyan@google.com> Subject: [PATCH v5 1/4] mm/page_alloc: only free healthy pages in high-order has_hwpoisoned folio From: Jiaqi Yan To: ljs@kernel.org, linmiaohe@huawei.com, osalvador@kernel.org, ziy@nvidia.com, harry.yoo@oracle.com, willy@infradead.org Cc: osalvador@suse.de, lorenzo.stoakes@oracle.com, jackmanb@google.com, hannes@cmpxchg.org, nao.horiguchi@gmail.com, david@kernel.org, william.roche@oracle.com, tony.luck@intel.com, wangkefeng.wang@huawei.com, jane.chu@oracle.com, akpm@linux-foundation.org, muchun.song@linux.dev, liam@infradead.org, rientjes@google.com, duenwen@google.com, jthoughton@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, vbabka@suse.cz, rppt@kernel.org, shuah@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" At the end of dissolve_free_hugetlb_folio(), a free HugeTLB folio becomes non-HugeTLB, and it is released to buddy allocator as a high-order folio, e.g. a folio that contains 262144 pages if the folio was a 1G HugeTLB hugepage. This is problematic if the HugeTLB hugepage contained HWPoison subpages. In that case, since buddy allocator does not check HWPoison for non-zero-order folio, the raw HWPoison page can be given out with its buddy page and be re-used by either kernel or userspace. Memory failure recovery (MFR) in kernel does attempt to take raw HWPoison page off buddy allocator after dissolve_free_hugetlb_folio(). However, there is always a time window between dissolve_free_hugetlb_folio() frees a HWPoison high-order folio to buddy allocator and MFR takes HWPoison raw page off buddy allocator. Another similar situation is when a transparent huge page (THP) runs into memory failure but splitting failed. Such THP will eventually be released to buddy allocator when owning userspace processes are gone, but with certain subpages having HWPoison. One obvious way to avoid both problems is to add page sanity checks in page allocate or free path. However, it is against the past efforts to reduce sanity check overhead [1,2,3]. Introduce free_has_hwpoisoned() to only free the healthy pages and to exclude the HWPoison ones in the high-order folio. The idea is to iterate through the sub-pages of the folio to identify contiguous ranges of healthy pages. free_has_hwpoisoned() is added in free_pages_prepare() as a shortcut and is only invoked if PG_has_hwpoisoned indicates HWPoison page exists and after checks and preparations in free_pages_prepare() all succeeded. free_has_hwpoisoned() then can re-use free_prepared_contig_range() [4] to decompose healthy ranges into the largest possible chunks of different orders. Every chunk meets the requirements to be freed via free_one_page(). free_has_hwpoisoned() has linear time complexity wrt the number of pages in the folio. While the power-of-two decomposition ensures that the number of calls to the buddy allocator is logarithmic for each contiguous healthy range, the mandatory linear scan of pages to identify PageHWPoison() defines the overall time complexity. For a 1G hugepage having 8 HWPoison pages, free_has_hwpoisoned() takes around 1ms on average on a system having 56 Intel Skylake physical cores. This is 15x to the case of freeing no HWPoison page. The cost is far from triggering soft lockup, and fair for handling exceptional hardware memory errors. [1] https://lore.kernel.org/linux-mm/1460711275-1130-15-git-send-email-mgor= man@techsingularity.net [2] https://lore.kernel.org/linux-mm/1460711275-1130-16-git-send-email-mgor= man@techsingularity.net [3] https://lore.kernel.org/all/20230216095131.17336-1-vbabka@suse.cz [4] https://lore.kernel.org/all/20260401101634.2868165-2-usama.anjum@arm.com Signed-off-by: Jiaqi Yan --- mm/page_alloc.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index e47679e7a9db..03df929abca6 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -208,6 +208,7 @@ gfp_t gfp_allowed_mask __read_mostly =3D GFP_BOOT_MASK; unsigned int pageblock_order __read_mostly; #endif =20 +static void free_has_hwpoisoned(struct page *page, unsigned int order); static void __free_pages_ok(struct page *page, unsigned int order, fpi_t fpi_flags); static void reserve_highatomic_pageblock(struct page *page, int order, @@ -1309,6 +1310,14 @@ static inline void pgalloc_tag_sub_pages(struct allo= c_tag *tag, unsigned int nr) =20 #endif /* CONFIG_MEM_ALLOC_PROFILING */ =20 +/* + * Returns + * - true: checks and preparations all good, caller can proceed freeing. + * - false: do not proceed freeing for one of the following reasons: + * 1. Some check failed so it is not safe to proceed freeing. + * 2. A compound page has some HWPoison pages. The healthy pages + * are already safely freed, and the HWPoison ones isolated. + */ static __always_inline bool __free_pages_prepare(struct page *page, unsigned int order, fpi_t fpi_flags) { @@ -1317,6 +1326,15 @@ static __always_inline bool __free_pages_prepare(str= uct page *page, bool init =3D want_init_on_free(); bool compound =3D PageCompound(page); struct folio *folio =3D page_folio(page); + /* + * When dealing with compound page, PG_has_hwpoisoned is cleared + * with PAGE_FLAGS_SECOND. So the check must be done first. + * + * Note we can't exclude PG_has_hwpoisoned from PAGE_FLAGS_SECOND. + * Because PG_has_hwpoisoned =3D=3D PG_active, free_page_is_bad() will + * confuse and complaint that the first tail page is still active. + */ + bool should_fhh =3D compound && folio_test_has_hwpoisoned(folio); =20 if (fpi_flags & FPI_PREPARED) return true; @@ -1443,6 +1461,16 @@ static __always_inline bool __free_pages_prepare(str= uct page *page, =20 debug_pagealloc_unmap_pages(page, 1 << order); =20 + /* + * After breaking down compound page and dealing with page metadata + * (e.g. page owner and page alloc tags), take a shortcut if this + * was a compound page containing certain HWPoison subpages. + */ + if (should_fhh) { + free_has_hwpoisoned(page, order); + return false; + } + return true; } =20 @@ -6936,6 +6964,63 @@ void __free_contig_range(unsigned long pfn, unsigned= long nr_pages) __free_contig_range_common(pfn, nr_pages, /* is_frozen=3D */ false); } =20 +/* + * Given a high-order compound page containing certain number of HWPoison + * pages, free only the healthy ones. + * + * Pages must have passed free_pages_prepare(). Even if having HWPoison + * pages, breaking down compound page and updating metadata (e.g. page + * owner, alloc tag) can be done together during free_pages_prepare(), + * which simplifies the splitting here: unlike __split_unmapped_folio(), + * there is no need to turn split pages into a compound page or to carry + * metadata. + * + * It scans every raw page of the compound page and cause nontrivial overh= ead. + * So only use this when the compound page contains HWPoison page(s). + * + * This implementation needs rework in memdesc world. + */ +static void free_has_hwpoisoned(struct page *page, unsigned int order) +{ + unsigned long curr =3D page_to_pfn(page); + unsigned long end_pfn =3D curr + (1 << order); + unsigned long next; + unsigned long total_freed =3D 0; + unsigned long total_hwp =3D 0; + + VM_WARN_ON(order =3D=3D 0); + VM_WARN_ON(page->flags.f & PAGE_FLAGS_CHECK_AT_PREP); + + while (curr < end_pfn) { + next =3D curr; + + while (next < end_pfn && !PageHWPoison(pfn_to_page(next))) + ++next; + + if (next !=3D end_pfn && PageHWPoison(pfn_to_page(next))) { + /* + * Avoid accounting error when the page is freed + * by unpoison_memory(). + */ + clear_page_tag_ref(pfn_to_page(next)); + ++total_hwp; + } + + free_prepared_contig_range(pfn_to_page(curr), next - curr); + total_freed +=3D next - curr; + + if (next =3D=3D end_pfn) + break; + + VM_WARN_ON(!PageHWPoison(pfn_to_page(next))); + curr =3D next + 1; + } + + VM_WARN_ON(total_freed + total_hwp !=3D (1 << order)); + pr_info("Freed %#lx pages, excluded %lu HWPoison pages\n", + total_freed, total_hwp); +} + #ifdef CONFIG_CONTIG_ALLOC /* Usage: See admin-guide/dynamic-debug-howto.rst */ static void alloc_contig_dump_pages(struct list_head *page_list) --=20 2.54.0.823.g6e5bcc1fc9-goog From nobody Mon Jun 8 08:35:32 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 D4EB63093C6 for ; Sun, 31 May 2026 05:58:34 +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=1780207115; cv=none; b=ABgo5FPSliDiIDs9rKeqCKWzs4xM+VrtfOXk6FlVTV5gzG+SLbeFJFabCp87piE8JoK1zhQlum00t+AXvqRfNtsmrAgkMAe+8WXKymt74I4tjh8lD5L2DAx+TC8QE/L9vBndulw27pLChqm02KZco3/0aG2nuWg6VnMBJNhLnsE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780207115; c=relaxed/simple; bh=rVImHXnWW6fyrHb6TA7DxHEkM5jl0uLcI5/lsMCtVt8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=CJo22IVWLA3WiestMz99xkej8ZLgZN3dEqiJrrDgyqt7OpqYWVpNl27gEmQLBGAbEU+lBCHuw2IhXnw6/dPXtODKYdWX2DJir05SKJYlnO6xquInJ/4LwbpS9Kcye/sm7OTcgpAsAvaUT1lprX+C7lsmcupTs/8N3Om0cn/O+eo= 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=N0+/vfs8; 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="N0+/vfs8" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2bf32fb7cb2so10640045ad.2 for ; Sat, 30 May 2026 22:58:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780207114; x=1780811914; 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=Watx4wiVZz594G8gV72LCTq/SUp1MPbV3HBGL6Hr2ho=; b=N0+/vfs87cjzrjq+eCu1HwKi6z+zsVQ5s5Gt3MHAcDOzOeiuz8cKC8DJExvL9PO5x+ XW38OqYbd2UxoT5blp4r2iNrrQahLzaO0CYSgwqmdXNXflTsc/3ydWrViYzo1aJ5VsK1 gGmTT/GuGsm1ClkTNd0Xd80RUKdO1PlY+3l+2cMbXuBZWaCG801JPg+37dthnA2IN0l6 Yk/8H/JsZHBLAk0170xtvut5bcVcxHpBU3hjD6wkapKS/Mo6PVsSAyuG34kSJ9Vcl0ly TqbjbqmoGWj7MeMeQegObYw1uPtMKFABVxJa1MFIQpGyvK/SoqcH7dn3/UqKw8R11xVl Yfkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780207114; x=1780811914; 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=Watx4wiVZz594G8gV72LCTq/SUp1MPbV3HBGL6Hr2ho=; b=gZR+SneiHvCxz0CdoS10EXQxdhaJ1g1nyuBHJeF37ylfQOZH3I+8Z//B4T0Gs5ozx7 bCcBh4RZdZimAhoUbL9VG+cdhBJ7ZRbteSOTWEiifwUv0fV8nmYR7MEMOOmusKQT5V8/ 7dXNprMHSc2rx4kv8ls4gX8rgOEDTOzRhH9kH0F1PYIMcXfNnVksAo61/2rK9tOcTekV 7yBHi2a9RgEJgxXcrbyVu23aMAlyDJyI3qXG7Pxw3c6E7FSCM8McIpxPDDBAYS+Libnl psLX6nYVOAydRI/kAk4mma5doffmzAf5QRdFCoEJ4odkrwX0y9tVMj9s0k2F0yUIE67W VuDQ== X-Forwarded-Encrypted: i=1; AFNElJ/sSrfY1qQ8uQ/4zf62BQmcDFsOXl1CmpjZCdB8P2JY1Af+0s5OlMQ3Xg1OF48Y/TGHjFOUccguOKApw6I=@vger.kernel.org X-Gm-Message-State: AOJu0Yx22glUgNqQIGAThGgOQCFjpQkA2qyz9E2OYisVJQqIO3GbjVwC DgsCHCwIG2vqgEX/s69gPVq5d3I1Om3AwelX84MeTpTLUbQ793kZTY5aoyTaaip/dK2yJNERxHc SWrubT7QUpXq+6Q== X-Received: from plgy12.prod.google.com ([2002:a17:903:22cc:b0:2b2:4713:9ce4]) (user=jiaqiyan job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:ce85:b0:2bd:4d4b:9143 with SMTP id d9443c01a7336-2bf36795110mr71007705ad.8.1780207113952; Sat, 30 May 2026 22:58:33 -0700 (PDT) Date: Sun, 31 May 2026 05:58:27 +0000 In-Reply-To: <20260531055829.3636554-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: <20260531055829.3636554-1-jiaqiyan@google.com> X-Mailer: git-send-email 2.54.0.823.g6e5bcc1fc9-goog Message-ID: <20260531055829.3636554-3-jiaqiyan@google.com> Subject: [PATCH v5 2/4] mm/memory-failure: set has_hwpoisoned flags on dissolved HugeTLB folio From: Jiaqi Yan To: ljs@kernel.org, linmiaohe@huawei.com, osalvador@kernel.org, ziy@nvidia.com, harry.yoo@oracle.com, willy@infradead.org Cc: osalvador@suse.de, lorenzo.stoakes@oracle.com, jackmanb@google.com, hannes@cmpxchg.org, nao.horiguchi@gmail.com, david@kernel.org, william.roche@oracle.com, tony.luck@intel.com, wangkefeng.wang@huawei.com, jane.chu@oracle.com, akpm@linux-foundation.org, muchun.song@linux.dev, liam@infradead.org, rientjes@google.com, duenwen@google.com, jthoughton@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, vbabka@suse.cz, rppt@kernel.org, shuah@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" When a free HWPoison HugeTLB folio is dissolved, it becomes non-HugeTLB and is released to buddy allocator as a high-order folio. Set has_hwpoisoned flags on the high-order folio so that buddy allocator can tell that it contains certain HWPoison page(s), and can handle it specially with free_has_hwpoisoned(). Signed-off-by: Jiaqi Yan --- include/linux/page-flags.h | 2 +- mm/memory-failure.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 7223f6f4e2b4..223ec3b2d62f 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -893,7 +893,7 @@ static inline int PageTransCompound(const struct page *= page) TESTPAGEFLAG_FALSE(TransCompound, transcompound) #endif =20 -#if defined(CONFIG_MEMORY_FAILURE) && defined(CONFIG_TRANSPARENT_HUGEPAGE) +#if defined(CONFIG_MEMORY_FAILURE) && (defined(CONFIG_TRANSPARENT_HUGEPAGE= ) || defined(CONFIG_HUGETLB_PAGE)) /* * PageHasHWPoisoned indicates that at least one subpage is hwpoisoned in = the * compound page. diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 51508a55c405..95979b7995c1 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1951,6 +1951,7 @@ void folio_clear_hugetlb_hwpoison(struct folio *folio) if (folio_test_hugetlb_vmemmap_optimized(folio)) return; folio_clear_hwpoison(folio); + folio_set_has_hwpoisoned(folio); folio_free_raw_hwp(folio, true); } =20 --=20 2.54.0.823.g6e5bcc1fc9-goog From nobody Mon Jun 8 08:35:32 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 B984432937A for ; Sun, 31 May 2026 05:58: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=1780207117; cv=none; b=QjsO2Mp9RKbZPRHZcWP3OV0a9k4XkBEnsHrXdh5Y8zb9oA2pV9P8O/9PY/5LA05eXvcxvpRf3fozIm3U01jnr1Y1RIX2qlIee7Y7qqXdLStZLrWnTma287Ywep8AicN8HcTA7sGOAiz6sj5snngiZLZDzIYSlHaSCe6dv/xyU3A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780207117; c=relaxed/simple; bh=TUvW6376g3KB8xyMm7kLmqPxUuft4wG8bsL17fT0O+M=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=l/3OVkg7SdmBIXD8y8MKQABoD6ALXm0KCilF36sQAJj98Sao6aI10N7qHgMjZu+TomP23lQRJTdnJf7pyUcTDyYnw9TyJtTvF5TRVgiE1DukU9agJL3DXG/ZiJ26e+GjTy5GhuZUDbtd71CqVg9p1YhIXGgP7SypkZMK2QhrJaY= 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=i3VsqqFm; 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="i3VsqqFm" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2c0b35fa876so6520415ad.1 for ; Sat, 30 May 2026 22:58:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780207115; x=1780811915; 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=WZW1Swft1eWJtZExgmIavtPOzBDQuGx01Vq9nniKO/I=; b=i3VsqqFmN5hHYVl+92ZbEL0gubP02oFPn179MhTZoV/Z4Pjulq1tsVICRqnaUDAiaE sqgxhIqACB+oCr0nd4QdKvAtAuLTjds0GQhg24tlu+C9Dr/2fU789LnmzTU+15Lzq7+3 RHIT+FUVbVTwTZYvgLeSrv0yvQSud4Yy1riNW2FLKQx6AWj0myb5l0nu4uijXttvBhGb ivaN2bgctxN9vPT+vy659w12wwK4oqspR/HMEkq74u+U1c9fRnBVniiPmyqeZ+Bx7TJl SIa4xFkeiDKkeFAovlnJv0P1ov4DXxNhrLRvubPi7s4shPa1hwfBqp4vg0o5L50q8uqy cx9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780207115; x=1780811915; 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=WZW1Swft1eWJtZExgmIavtPOzBDQuGx01Vq9nniKO/I=; b=s/QtJbG9TsHcmdFjIRbjqinHCtBB0RIMYLEymjyFNAe3UEPTFmgLrIMP8H/Qvnxuvx aqJE89sO51O9YxGM11X4fz3KZbuCMZgTrbU0BhkgQ4vLqAJx0jham+DZu2oL0CHRfFwA gN80etNbRsz0ktVV0Gl4t7iSXBGV3HYhTln9w+jv7L2q4vjXVlvPXzEvurXMQMci++mB PMqFy0MD2wmtu/AaXK5lzyBpdfT9zFKt2cx3C9dlFMWBJoV/BVuq7NjYQxNOGM/agscK QVBr3DaDRwyt3y+0OwJihu9cyyy9tS7VrG43C4OPDTsfC6chTqVnFW1jdK5gG7Nmadqz 1rmA== X-Forwarded-Encrypted: i=1; AFNElJ+BrphWHLfbl9SPuBMYDuLVLAxPPmiuYK+YR39rD2eW9oiteig7YoNbBJVBE+1qDSZAU0DCzKfmTXR448A=@vger.kernel.org X-Gm-Message-State: AOJu0YzrsquJpNGvZhgC3TVJK4BE7vjuILsQ/lxYgLwAEItwH86HSfBn u0xNTfWGMWl2swu7R532Lj0l0v1uJhdRVp0T77T35Fd1t+FtEIxsK3/n2I7nMXV5C7e1BT6Bx+m ERk25g4vRBjMcug== X-Received: from plbkn8.prod.google.com ([2002:a17:903:788:b0:2bf:20bc:ee77]) (user=jiaqiyan job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:1c6:b0:2bd:9c0a:32c with SMTP id d9443c01a7336-2bf3683b78dmr65642835ad.19.1780207114820; Sat, 30 May 2026 22:58:34 -0700 (PDT) Date: Sun, 31 May 2026 05:58:28 +0000 In-Reply-To: <20260531055829.3636554-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: <20260531055829.3636554-1-jiaqiyan@google.com> X-Mailer: git-send-email 2.54.0.823.g6e5bcc1fc9-goog Message-ID: <20260531055829.3636554-4-jiaqiyan@google.com> Subject: [PATCH v5 3/4] mm/memory-failure: skip take_page_off_buddy after dissolving HWPoison HugeTLB page From: Jiaqi Yan To: ljs@kernel.org, linmiaohe@huawei.com, osalvador@kernel.org, ziy@nvidia.com, harry.yoo@oracle.com, willy@infradead.org Cc: osalvador@suse.de, lorenzo.stoakes@oracle.com, jackmanb@google.com, hannes@cmpxchg.org, nao.horiguchi@gmail.com, david@kernel.org, william.roche@oracle.com, tony.luck@intel.com, wangkefeng.wang@huawei.com, jane.chu@oracle.com, akpm@linux-foundation.org, muchun.song@linux.dev, liam@infradead.org, rientjes@google.com, duenwen@google.com, jthoughton@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, vbabka@suse.cz, rppt@kernel.org, shuah@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 95979b7995c1..098c4407e818 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, @@ -1166,11 +1190,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 @@ -2076,11 +2100,11 @@ static int try_memory_failure_hugetlb(unsigned long= pfn, int flags) */ if (res =3D=3D MF_HUGETLB_FREED) { 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.54.0.823.g6e5bcc1fc9-goog From nobody Mon Jun 8 08:35:32 2026 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.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 9D5B032B981 for ; Sun, 31 May 2026 05:58:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780207118; cv=none; b=PWtD86zq3EwyHBwo/ryF28Y/1RC+6ylHQ1T3cQCSKR0R/DfuLysF87hilBu/Pt6NrmAKscTRY9b3ms2Z75bahvUkmt5y1GGxEczWyG2GH+hEx1THyVO/9B8nMexMkpExFFJ6CyU+zvsqT51hjy8WShdUHtdKKGutUYUgVoG6UUQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780207118; c=relaxed/simple; bh=SZWZPJWGyZ4Y4qxqaULM6epTJGugPNAJ8oZwETj4sgo=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ugGu+DDu4YNzw1rUvmP9PjXvbQnSuhm4EnLt3aeGfJ3wWfUJM8KVH8OWtZ4/PtecT4BGrqOvw7kFUtqdAxcxlfzxdJe+ixiuLUX3OJFxgrrB2VAkP+mAeSmw1t7ZUR3CL6VMblsTSSlbHF/wBjyRAXaM6Yv7zvl0iBTvV/VR6iw= 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=huS6Ve77; arc=none smtp.client-ip=209.85.216.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--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="huS6Ve77" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-36d98b54cf2so204462a91.1 for ; Sat, 30 May 2026 22:58:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780207116; x=1780811916; 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=Nv+dqUY9M7caT19LqyoDWfIhP+5KrZo4lI6j0vjgDSg=; b=huS6Ve77V4Iwmp5Vi3f14KUCVY0lP8056+gSz1Nmej9IPOzE1hLuI+G2juediCgHTj abZLA8kwoHnh0B/gkRqsISyfgpzLUvVLRGpWNZMW3U0p8PG9YJt8dBHx4UbfyfJTUCeO bHyPe25ecCfweiStWW6OTy5j9SddZOSUZPfg2jGY20LMaK0iax5UU4bzZMAEKND/szXX bjU3hxo4dEI5UuL799D173cYS1PGH5atWoZO8YsahkZhNBgnO7fPAXrOZohIcYEwFHIR kf5kmHpgmf1vloQ3KMjQLy5YSfIOpkZWw8HHxS927Xm7/Gyg0tMYQw0kScOGt9qnctQ0 JgLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780207116; x=1780811916; 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=Nv+dqUY9M7caT19LqyoDWfIhP+5KrZo4lI6j0vjgDSg=; b=CCYacyxRuEVvMfXlF1k8BO6bEho8v4mj/yiuPdAsu7gWJoNwWQJAlr3qI05eSwHw3r FENXFIREklwGwnAuELdUmOFNWu+VFyfcx6br+GutmIueLRginAkUSz5ZztFKUV6n9wKJ Ob1AfqeJH05mxqdTk1NHyOCetTH2PIHEXjOknc3MKpQg+EORKbeGTzmJJrsyMdRTHsLh kZHf2gbAluhILhAGykkfgLTgmCLfew2SwfvyJCpEq5tKTx4Q2q6W/KrHBOKUS82rcNPX MoMhM8sOX3kQg7I7YIBwSWjgtUhBKqA990X/puh8ALRUtbVpwJnrQw6BpcIYNagAQeV4 crXA== X-Forwarded-Encrypted: i=1; AFNElJ/kBRvmCvt7I0uJlCvH+Iy/tpzIdjKkWkjESz8j/jxumfE4X7V0vFvi9VR1pxDGQBXear9UaXcA1wPlfs8=@vger.kernel.org X-Gm-Message-State: AOJu0YxbxUTJZ+K44MfxinxfTNdZIME3v2dgmnIVUyn7YOHXrIOYoZLh MiOIRGs2hE/cKAapwOtvHYdT46/9gYeOyeHLyhkOwT9bFYrC0G/Ca5L4f7U2AMw3PZt93VlKteW D1lJQxt3jx4ZFQg== X-Received: from pghu10.prod.google.com ([2002:a63:ef0a:0:b0:c79:81bb:79df]) (user=jiaqiyan job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:5848:b0:36b:afa0:c676 with SMTP id 98e67ed59e1d1-36c68476da9mr5562659a91.22.1780207115665; Sat, 30 May 2026 22:58:35 -0700 (PDT) Date: Sun, 31 May 2026 05:58:29 +0000 In-Reply-To: <20260531055829.3636554-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: <20260531055829.3636554-1-jiaqiyan@google.com> X-Mailer: git-send-email 2.54.0.823.g6e5bcc1fc9-goog Message-ID: <20260531055829.3636554-5-jiaqiyan@google.com> Subject: [PATCH v5 4/4] selftests/mm: add hard memory failure anonymous 1G HugeTLB page test From: Jiaqi Yan To: ljs@kernel.org, linmiaohe@huawei.com, osalvador@kernel.org, ziy@nvidia.com, harry.yoo@oracle.com, willy@infradead.org Cc: osalvador@suse.de, lorenzo.stoakes@oracle.com, jackmanb@google.com, hannes@cmpxchg.org, nao.horiguchi@gmail.com, david@kernel.org, william.roche@oracle.com, tony.luck@intel.com, wangkefeng.wang@huawei.com, jane.chu@oracle.com, akpm@linux-foundation.org, muchun.song@linux.dev, liam@infradead.org, rientjes@google.com, duenwen@google.com, jthoughton@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, vbabka@suse.cz, rppt@kernel.org, shuah@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" Add a new testcase to validate memory failure recovery for HWPoison anonymous 1G HugeTLB page, including proper SIGBUS delivery, releasing a 1G HugeTLB page containing one HWPoison page to buddy allocator, and isolation of the raw HWPoison page. Although can be added in future, this patch does not support testing the MADV_SOFT variant. Signed-off-by: Jiaqi Yan --- tools/testing/selftests/mm/memory-failure.c | 73 +++++++++++++++++++-- 1 file changed, 68 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/mm/memory-failure.c b/tools/testing/se= lftests/mm/memory-failure.c index 032ed952057c..ea43b2877c81 100644 --- a/tools/testing/selftests/mm/memory-failure.c +++ b/tools/testing/selftests/mm/memory-failure.c @@ -18,6 +18,7 @@ #include #include =20 +#include "hugepage_settings.h" #include "vm_util.h" =20 enum inject_type { @@ -27,6 +28,7 @@ enum inject_type { =20 enum result_type { MADV_HARD_ANON, + MADV_HARD_ANON_HUGETLB, MADV_HARD_CLEAN_PAGECACHE, MADV_HARD_DIRTY_PAGECACHE, MADV_SOFT_ANON, @@ -47,6 +49,8 @@ FIXTURE(memory_failure) int pagemap_fd; int kpageflags_fd; bool triggered; + /* Number of initial HugeTLB pages with default page size. */ + unsigned long nr_hugetlb_pages; }; =20 FIXTURE_VARIANT(memory_failure) @@ -157,11 +161,11 @@ static void check(struct __test_metadata *_metadata, = FIXTURE_DATA(memory_failure void *vaddr, enum result_type type, int setjmp) { unsigned long size; + unsigned long nr_hugetlb_pages; uint64_t pfn_flags; =20 switch (type) { case MADV_SOFT_ANON: - case MADV_HARD_CLEAN_PAGECACHE: case MADV_SOFT_CLEAN_PAGECACHE: case MADV_SOFT_DIRTY_PAGECACHE: /* It is not expected to receive a SIGBUS signal. */ @@ -174,6 +178,7 @@ static void check(struct __test_metadata *_metadata, FI= XTURE_DATA(memory_failure ASSERT_NE(pagemap_get_pfn(self->pagemap_fd, vaddr), self->pfn); break; case MADV_HARD_ANON: + case MADV_HARD_ANON_HUGETLB: case MADV_HARD_DIRTY_PAGECACHE: /* The SIGBUS signal should have been received. */ ASSERT_EQ(setjmp, 1); @@ -183,17 +188,36 @@ static void check(struct __test_metadata *_metadata, = FIXTURE_DATA(memory_failure ASSERT_EQ(siginfo.si_code, BUS_MCEERR_AR); ASSERT_EQ(1UL << siginfo.si_addr_lsb, self->page_size); ASSERT_EQ(siginfo.si_addr, vaddr); - - /* XXX Check backing pte is hwpoison entry when supported. */ - ASSERT_TRUE(pagemap_is_swapped(self->pagemap_fd, vaddr)); break; default: SKIP(return, "unexpected inject type %d.\n", type); } =20 + if (type =3D=3D MADV_HARD_ANON || type =3D=3D MADV_HARD_DIRTY_PAGECACHE) { + /* + * Check backing pte is hwpoison entry when supported. + * Although try_to_unmap_one() also installs hwpoison entry + * for HugeTLB, pagemap_hugetlb_range() doesn't parse + * swap entries at all. + */ + ASSERT_TRUE(pagemap_is_swapped(self->pagemap_fd, vaddr)); + } + /* Check if the value of HardwareCorrupted has increased. */ ASSERT_EQ(get_hardware_corrupted_size(&size), 0); - ASSERT_EQ(size, self->corrupted_size + self->page_size / 1024); + + if (type =3D=3D MADV_HARD_ANON_HUGETLB) { + /* + * Only one page is hardware corrupted; the rest should all be + * released to buddy allocator. + */ + ASSERT_EQ(size, self->corrupted_size + getpagesize() / 1024); + /* HugeTLB should have lost the HWPoison HugeTLB page. */ + nr_hugetlb_pages =3D hugetlb_nr_default_pages(); + ASSERT_EQ(nr_hugetlb_pages + 1, self->nr_hugetlb_pages); + } else { + ASSERT_EQ(size, self->corrupted_size + self->page_size / 1024); + } =20 /* Check if HWPoison flag is set. */ ASSERT_EQ(pageflags_get(self->pfn, self->kpageflags_fd, &pfn_flags), 0); @@ -247,6 +271,45 @@ TEST_F(memory_failure, anon) ASSERT_EQ(munmap(addr, self->page_size), 0); } =20 +TEST_F(memory_failure, anon_hugetlb) +{ + char *addr; + int ret; + const unsigned long nr_alloc_hugetlb_pages =3D 4; + unsigned long alloc_size; + + if (variant->type =3D=3D MADV_SOFT) + SKIP(return, "Soft offline test is not implemented"); + + /* HugeTLB settings will be automatically restored when test exits. */ + hugetlb_setup_default(nr_alloc_hugetlb_pages); + + alloc_size =3D default_huge_page_size() * nr_alloc_hugetlb_pages; + self->page_size =3D default_huge_page_size(); + self->nr_hugetlb_pages =3D hugetlb_nr_default_pages(); + + addr =3D mmap(0, alloc_size, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE | MAP_HUGETLB, -1, 0); + if (addr =3D=3D MAP_FAILED) + SKIP(return, "mmap failed, not enough memory or 1G hugetlb not supported= .\n"); + memset(addr, 0xce, alloc_size); + + prepare(_metadata, self, addr); + + ret =3D sigsetjmp(signal_jmp_buf, 1); + if (!self->triggered) { + self->triggered =3D true; + ASSERT_EQ(variant->inject(self, addr), 0); + FORCE_READ(*addr); + } + + check(_metadata, self, addr, MADV_HARD_ANON_HUGETLB, ret); + + cleanup(_metadata, self, addr); + + ASSERT_EQ(munmap(addr, alloc_size), 0); +} + static int prepare_file(const char *fname, unsigned long size) { int fd; --=20 2.54.0.823.g6e5bcc1fc9-goog