From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CEE893ACA6B for ; Thu, 19 Mar 2026 13:00:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773925219; cv=none; b=Q9KT/MCLM7vJE7HWar5y0SSzfcvjkx/hu8H/PrkxNFll+CUwWUskPsoCZUThm7hloWjaxNAr5mMQ5CpVQXSsQYeiD/GOoPKUpsiS0XVr1v/hBgzyC/uhCBkW+F1x5RnLEl6RP0SUmUJm8kzyoGA8/3CGKAsmq5PN+0HAAxiY/kg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773925219; c=relaxed/simple; bh=3MiP4hdPB4G8SsgHRaYWC54kCzT1i0VZfFsgmWsL5ag=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=B/v4o/Mz9P5h0YxIGLiPg8GXul8KvU3wk1SI05zK1VFs5FpZuo3kGy7ikKnK6GZzDiqvJpvCK0yVzSEBY7b21f+rJjfZBbupAveFB7h9iStEja2/5/kkoTLrBUQryRjA1JagAOJpE96TXcLHanQWL1VtzlHL2jNHUc5NfSq34x0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NwrSrQ4n; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NwrSrQ4n" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 206D6C19424; Thu, 19 Mar 2026 13:00:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773925219; bh=3MiP4hdPB4G8SsgHRaYWC54kCzT1i0VZfFsgmWsL5ag=; h=From:To:Cc:Subject:Date:From; b=NwrSrQ4nGZ05RHaH3tM9BK2AkchwEf1OlaR8TntUqSeSQfcXPrB2CaPhDZRMd0Spy 8CKeUnleDvtJkJ5Uf2PfYHOeIos0Z+HU0/vcwlkEf57LYCy68qQi7EsdNqjrDI7et+ FpiApDXM1c2glnuiSk+WhG9lRcQ4rYXHv4vIXz9y4qjkblc9trVG560s7AYir2VnAG PVoGL5FAEKi0sAlKx6b4Q9fw/xpnyNKYUqvLqoHu6iPyLuWEL/3oltgVnL0N4ifxH0 EOLmtIrFZ6Cc6ufnjQsS0zpJczJyvWLkxC/Y7FHYi+MrdjftFvhGSlqtypz1LMUX6z JUv+lovSkTDkQ== From: "Lorenzo Stoakes (Oracle)" To: Andrew Morton Cc: David Hildenbrand , Zi Yan , Baolin Wang , "Liam R . Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 0/9] mm/huge_memory: refactor zap_huge_pmd() Date: Thu, 19 Mar 2026 13:00:06 +0000 Message-ID: X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The zap_huge_pmd() function is overly complicated, clean it up and also add an assert in the case that we encounter a buggy PMD entry that doesn't match expectations. This is motivated by a bug discovered [0] where the PMD entry was none of: * A non-DAX, PFN or mixed map. * The huge zero folio * A present PMD entry * A softleaf entry In zap_huge_pmd(), but due to the bug we manged to reach this code. It is useful to explicitly call this out rather than have an arbitrary NULL pointer dereference happen, which also improves understanding of what's going on. [0]:https://lore.kernel.org/all/6b3d7ad7-49e1-407a-903d-3103704160d8@lucifer.local/ v2: * Added tags thanks everybody! * Fixed issue with returning false on bug case potentially looping forever as per Baolin. * Fixed further issue in bug path in 5/8 with double pte unlock. * Add patch to use vm_normal_folio_pmd() as per David. v1: https://lore.kernel.org/all/cover.1773865827.git.ljs@kernel.org/ Lorenzo Stoakes (Oracle) (9): mm/huge_memory: simplify vma_is_specal_huge() mm/huge: avoid big else branch in zap_huge_pmd() mm/huge_memory: have zap_huge_pmd return a boolean, add kdoc mm/huge_memory: handle buggy PMD entry in zap_huge_pmd() mm/huge_memory: add a common exit path to zap_huge_pmd() mm/huge_memory: remove unnecessary VM_BUG_ON_PAGE() mm/huge_memory: deduplicate zap deposited table call mm/huge_memory: deduplicate zap_huge_pmd() further by tracking state mm/huge_memory: have zap_huge_pmd() use vm_normal_folio_pmd() include/linux/huge_mm.h | 8 +-- include/linux/mm.h | 16 ----- mm/huge_memory.c | 141 +++++++++++++++++++++++----------------- 3 files changed, 85 insertions(+), 80 deletions(-) -- 2.53.