From nobody Mon Feb 9 15:25:49 2026 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (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 5A008145321 for ; Thu, 4 Jul 2024 04:32:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720067544; cv=none; b=se85nRSlXCcCatiV407qPoRrrb6skKxT2N2STrQgQbC1MUkVWJ97MbsUX5qWGPHN3FPalbL/2PI3kBj9U2dKsEqQcw1wDDwbh93KTyObJqQBgyLZqB3uDlvAE6FBuFsOzdFjyFhFEKNxUJ/dxJSB8uykjCQtK3UepvFk65dFP8o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720067544; c=relaxed/simple; bh=bGPa2HcHFWxQQ0CcFTQOgWln/PaFjOUQol7Z0orXRkM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eSNnjYVc2x3ozlUeg7PPdN41uuikUg4LfqF1MOSSbSAXEEvEHjcXtEQNU4yuvfhmOqoxMsidPVDd3vJ9X7R46JX4KXnhiCx05vlJix5i5YraCqPVVXj8wURky6dEXVBI6RlMS29df73jcOUly13r+dTX4+UeqtJZcUMuV7yXi7A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id ABF721FD00; Thu, 4 Jul 2024 04:32:21 +0000 (UTC) Authentication-Results: smtp-out2.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 8D48513889; Thu, 4 Jul 2024 04:32:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id sKv0HdQlhmbnDAAAD6G6ig (envelope-from ); Thu, 04 Jul 2024 04:32:20 +0000 From: Oscar Salvador To: Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Peter Xu , Muchun Song , David Hildenbrand , SeongJae Park , Miaohe Lin , Michal Hocko , Matthew Wilcox , Christophe Leroy , Oscar Salvador Subject: [PATCH 25/45] mm/memory-failure: Create check_hwpoisoned_pud_entry to handle PUD-mapped hugetlb vmas Date: Thu, 4 Jul 2024 06:31:12 +0200 Message-ID: <20240704043132.28501-26-osalvador@suse.de> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240704043132.28501-1-osalvador@suse.de> References: <20240704043132.28501-1-osalvador@suse.de> 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 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spam-Flag: NO X-Spam-Score: -4.00 X-Spam-Level: X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Queue-Id: ABF721FD00 X-Rspamd-Action: no action X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org Content-Type: text/plain; charset="utf-8" Normal THP cannot be PUD-mapped (besides devmap), but hugetlb can, so create check_hwpoisoned_pud_entry in order to handle PUD-mapped hugetlb vmas. Signed-off-by: Oscar Salvador --- mm/memory-failure.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 8cae95e36365..622862c4c300 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -771,6 +771,43 @@ static int check_hwpoisoned_entry(pte_t pte, unsigned = long addr, short shift, return 1; } =20 +#ifdef CONFIG_PGTABLE_HAS_HUGE_LEAVES +static int hwpoison_pud_range(pud_t *pudp, unsigned long addr, + unsigned long end, struct mm_walk *walk) +{ + int ret =3D 0; + spinlock_t *ptl; + pud_t pud =3D *pudp; + unsigned long pfn; + struct hwpoison_walk *hwp =3D walk->private; + + ptl =3D pud_huge_lock(pudp, walk->vma); + if (!ptl) + return 0; + + if (pud_present(pud)) { + pfn =3D pud_pfn(pud); + } else { + swp_entry_t swp =3D pud_to_swp_entry(pud); + + if (!is_hwpoison_entry(swp)) + goto out_unlock; + pfn =3D swp_offset_pfn(swp); + } + + if (!pfn || pfn !=3D hwp->pfn) + goto out_unlock; + + set_to_kill(&hwp->tk, addr, huge_page_shift(hstate_vma(walk->vma))); + ret =3D 1; +out_unlock: + spin_unlock(ptl); + return ret; +} +#else +hwpoison_pud_range NULL +#endif + #ifdef CONFIG_PGTABLE_HAS_HUGE_LEAVES static int check_hwpoisoned_pmd_entry(pmd_t *pmdp, unsigned long addr, struct hwpoison_walk *hwp, @@ -862,6 +899,7 @@ static int hwpoison_hugetlb_range(pte_t *ptep, unsigned= long hmask, #endif =20 static const struct mm_walk_ops hwpoison_walk_ops =3D { + .pud_entry =3D hwpoison_pud_range, .pmd_entry =3D hwpoison_pte_range, .hugetlb_entry =3D hwpoison_hugetlb_range, .walk_lock =3D PGWALK_RDLOCK, --=20 2.26.2