From mboxrd@z Thu Jan 1 00:00:00 1970 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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3D81A10AB83C for ; Fri, 27 Mar 2026 02:15:07 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4fhkk70bVyz2yrg; Fri, 27 Mar 2026 13:14:55 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=91.218.175.180 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1774577695; cv=none; b=jmRXhDG67jMzLpym0WzXihWIKPtA6g5iRplY5twc+ZiefiINmLJ+GGUF7/ebVCdLE8us7+fIh7XiqeIoatKqAQAFRP6bLsc4pG+xzl8mQpGWMiqgk0UKQappBkdNVPcEPdCnGKSxbwjRLSgT/oTYjKwZhGkLYfr6MdWI0bbbCNw1A+JmDe1G85axnljFFtY+9w32BlplbX+h41InDcc70upOtui7SFbxu3Sxo/V9H7kRx/Syy8HQ0rleshSmCVuTZ482BhZF5+l5SDGklSWtvYXfv59gS8w/MMy72XiQIT+AzKxuONGOHkPmIsC7Y68WM9EyOvRbNPIJC9SscaSj9Q== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1774577695; c=relaxed/relaxed; bh=AsidUyaFSU2OL+6pIevfNbim9vED85JJGBowf2ctQP8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=a3Dlybh7LWIaf5AaPHAXjrePNxlUHN3GR6nnBHmLp6CaMyTndPy5th2oCSs7MypN3pewzriKyzAlrBs70tUEhHkSrueEQYAqSCZTrAztrwz1mc6s92zupZZHpQj7C2qQx0oYh9kOVwTbmpV+S6blpdwOTm03SZEpmuS/4wxTMJGtpD+QqUKv0eImqBciFXj9/fk3+f00Ox1RqtnaSQZPfR16OBz1oumR+vGxh5z6Vpf+YXnR+0rvjLovtQ4XnrDb2ZZselizhjoTrcyIgJIcM/p9BmB4rGWOrdbLRfuAVrxAEPqNEJlyVFtP953p5G86V32ZeSN4vTKuC3xTshOSiQ== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.dev; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=KJYNK18n; dkim-atps=neutral; spf=pass (client-ip=91.218.175.180; helo=out-180.mta0.migadu.com; envelope-from=usama.arif@linux.dev; receiver=lists.ozlabs.org) smtp.mailfrom=linux.dev Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=KJYNK18n; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.dev (client-ip=91.218.175.180; helo=out-180.mta0.migadu.com; envelope-from=usama.arif@linux.dev; receiver=lists.ozlabs.org) Received: from out-180.mta0.migadu.com (out-180.mta0.migadu.com [91.218.175.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4fhkk62gYbz2xR4 for ; Fri, 27 Mar 2026 13:14:54 +1100 (AEDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1774577674; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AsidUyaFSU2OL+6pIevfNbim9vED85JJGBowf2ctQP8=; b=KJYNK18nvflazGbUsGQzniopI3KPVpz1LShSWjjSbT+hxFnh/0tpkw+tfNe3j+MVojye1j wdQPu4/bxNWWVoy1HF/DFPdbf1u5jrpcQiHNSPWDNk1zHFhU0vPcRAGI2daPSXBje5u6Yr R2eLlqWUdaQ4fQFe4gaiAaU+oQXNXZY= From: Usama Arif To: Andrew Morton , david@kernel.org, Lorenzo Stoakes , willy@infradead.org, linux-mm@kvack.org Cc: fvdl@google.com, hannes@cmpxchg.org, riel@surriel.com, shakeel.butt@linux.dev, kas@kernel.org, baohua@kernel.org, dev.jain@arm.com, baolin.wang@linux.alibaba.com, npache@redhat.com, Liam.Howlett@oracle.com, ryan.roberts@arm.com, Vlastimil Babka , lance.yang@linux.dev, linux-kernel@vger.kernel.org, kernel-team@meta.com, maddy@linux.ibm.com, mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, borntraeger@linux.ibm.com, svens@linux.ibm.com, linux-s390@vger.kernel.org, Usama Arif Subject: [v3 04/24] mm: thp: handle split failure in do_huge_pmd_wp_page() Date: Thu, 26 Mar 2026 19:08:46 -0700 Message-ID: <20260327021403.214713-5-usama.arif@linux.dev> In-Reply-To: <20260327021403.214713-1-usama.arif@linux.dev> References: <20260327021403.214713-1-usama.arif@linux.dev> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT do_huge_pmd_wp_page() splits the PMD when a COW of the entire huge page fails (e.g., can't allocate a new folio or the folio is pinned). It then returns VM_FAULT_FALLBACK so the fault can be retried at PTE granularity. If the split fails, the PMD is still huge. Returning VM_FAULT_FALLBACK would re-enter the PTE fault path, which expects a PTE page table at the PMD entry — not a huge PMD. Return VM_FAULT_OOM on split failure, which signals the fault handler to invoke the OOM killer or return -ENOMEM to userspace. Signed-off-by: Usama Arif --- mm/huge_memory.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 8ad43897bdf80..9f4be707c8cb0 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2137,7 +2137,13 @@ vm_fault_t do_huge_pmd_wp_page(struct vm_fault *vmf) folio_unlock(folio); spin_unlock(vmf->ptl); fallback: - __split_huge_pmd(vma, vmf->pmd, vmf->address, false); + /* + * Split failure means the PMD is still huge; returning + * VM_FAULT_FALLBACK would re-enter the PTE path with a + * huge PMD, causing incorrect behavior. + */ + if (__split_huge_pmd(vma, vmf->pmd, vmf->address, false)) + return VM_FAULT_OOM; return VM_FAULT_FALLBACK; } -- 2.52.0