From patchwork Thu Jul 4 04:31:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 13723203 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 165B5C30653 for ; Thu, 4 Jul 2024 04:33:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 720846B00B2; Thu, 4 Jul 2024 00:32:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6829D6B00B3; Thu, 4 Jul 2024 00:32:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 410B86B00B4; Thu, 4 Jul 2024 00:32:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 1EBA46B00B2 for ; Thu, 4 Jul 2024 00:32:25 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id CFDC9A07E3 for ; Thu, 4 Jul 2024 04:32:24 +0000 (UTC) X-FDA: 82300798608.01.E47B49D Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf14.hostedemail.com (Postfix) with ESMTP id DFEBA100017 for ; Thu, 4 Jul 2024 04:32:22 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=none; spf=pass (imf14.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.131 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720067531; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8g3OGkXPEHlFEZuyFqxzuyVJtkyZFU8vkNp30PpsX/A=; b=8J7UVMblHbKEErsYMTORp7z84Iasw2UhOTeFhf+S3pN2XDPkbw/6YtON+adknwgFj9yi8O JRT8pwOXbrU+CE5zVwO1jdGEtWzAMWxDUqu7oWuP7vTG//6AQuI0e+JQaPNgGc/Pa8RBnb Cr55f35rmo/zne4m5wv0O01OTkLyVmQ= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=none; spf=pass (imf14.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.131 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720067531; a=rsa-sha256; cv=none; b=Mi046oYXVU8niqQMidJlXOBLod/yvh7peT1m6c1EQudhIC4TGp7nfp/bSsQlvRIYKcTfn3 MdRbHKS3zZMeID297Tns5DzYb/lK9ciF8slSBlsVe236H7QABVcl4yo3t0FrpTF8KKDt+2 9+/BfHG9xjZeP/mtaGYQPrF4+La5D08= 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) 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> MIME-Version: 1.0 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: DFEBA100017 X-Stat-Signature: foade67mkfacsftubgbkrrihxc4bnffg X-HE-Tag: 1720067542-74229 X-HE-Meta: U2FsdGVkX1+BbSkEFsLVVUbmXX+vQSlkhZhnx708YNtT1PZXnbWyLIG5jyUEW4wamRU1cJ40DxAVuuj9jLUMoTVro8df40x2XWqGRFRIHHOCA3npjbgH5+9podlFHcrcGhD8km42rCZwn0MoWrmXEAIQEps+3u6/1cvE5AQVdPqnlViYkt00JQaLW0uAxjdw0I8SOhKv1tODCvm+gR5j9vvp6EEuJ9/ptxspjQIQwF12upWki4B2A+nOynFfXc/eVuIQGDKrEC8bSX7MNGw/kebusfTYvFqbvfSNRg+NYvsTkr8eCyUx4dZEeSftwbGmpX0EpuwYJQv5EyU+3jqEnnHWWSP0o3rgFbVd2IdeYRFdQ33p8aHy2y3WzjjFGuR7dlMZNwTS8aCHjbRQCWna2o9gxQVa8b1ecojBPA01GOTBFOxUu3cOMu1FWQ/0ZojOhoy2OGhaJJcUWxS9Z861yQNn1m8qf+EkIeonhb3Gvwv9aWjBHgfyWo5wM1wlanzLCrxiFoXu9zcT/lVltLezkbqLi/ZWeikU164il4t7cawOBA7Mz9N2Nos+sWjEZYdJ7RcrqHCCxHS4/HuFNIUjEO2PMyP1n4ROOb10tc5W+FJkHqf172hjBdDCh5eZT9OvP6YAVi0AoHHEVByQnjqifdKo1lPLtUtvBFPsTQl+rllatNjtj3rGnYEoPpdVQ9mnx7ab0ZZYpj6hD/vtS4xbaqGn9yR01LAvEHfn2MM9KPS061FjIrMitzz43smwg7rOW5s1vspiJLFgpAe+tJQZlHzvVoGXtmbF9PSe45HQ3X1JGddqqMZdFCZfadtgkwYtmY2RlPUpW6Y7UtJl0YxSsfyeWT/EMeO8efxOl2O/EBH7dC9Az2faHyalJobyS7C1LupAMkMtiTM3dVP1+SicPi8okteloRJpqHxff2G6Zszw+akFIrAv/a3+VJW/rN2XNFY1vYnoEtogbc/v69q TGSCZ7AB iRWa0CtC+5H+lGgBMJmTP9a7Qa8BNa/T1kS0GFx4SsBBoYSbmf36TRGIBv56KbkXustKGcErpqjTdKuJD+acjRkOxep9Mh+jQWxX7Q2wgevXv6Bu2oPRubX4gIkGpzLADDqiLVVfeJW4E8DhIbWjeVeHo7GUrrsNGHmXXseKRv/x8DIM= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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; } +#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 = 0; + spinlock_t *ptl; + pud_t pud = *pudp; + unsigned long pfn; + struct hwpoison_walk *hwp = walk->private; + + ptl = pud_huge_lock(pudp, walk->vma); + if (!ptl) + return 0; + + if (pud_present(pud)) { + pfn = pud_pfn(pud); + } else { + swp_entry_t swp = pud_to_swp_entry(pud); + + if (!is_hwpoison_entry(swp)) + goto out_unlock; + pfn = swp_offset_pfn(swp); + } + + if (!pfn || pfn != hwp->pfn) + goto out_unlock; + + set_to_kill(&hwp->tk, addr, huge_page_shift(hstate_vma(walk->vma))); + ret = 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 static const struct mm_walk_ops hwpoison_walk_ops = { + .pud_entry = hwpoison_pud_range, .pmd_entry = hwpoison_pte_range, .hugetlb_entry = hwpoison_hugetlb_range, .walk_lock = PGWALK_RDLOCK,