From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A1F2606A329 for ; Sun, 29 Nov 2026 20:22:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=X5TtAX0C; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=ZMfdkil5 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: Mime-Version:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Unsubscribe-Post:List-Owner; bh=BufXMHgyXiKL2PUWgPN9oVi+MH4NxuTVNsz7CEOhvlg=; b=X5TtAX0Cegu8YY2TrzUPfDDOGY Ux7odl5DRCyX6vJzaZScazHIQJs7HJK7Cey3mcnkosoL35+cBcRJbORL41Mg2U+OnNXcEJqyXUP4x hck/5pUTFv2eFuxgNrSyYnXma/2dWdp9Mp/riojegfmCplr7y9E705vx7V/9qRONhsb0d5BcInHKq mhU/tdtZahnMUMOwDiYRnxfhVY0TTKx/TdBrbXqJX3oOmZ+IMvh61kk1n4xPi2uicVFQVaOWmFMJU nSrKPq5Z9kN8+c7coA9Xrpq8MuX3lr/GYXKq3v2qbLWK0Pe8gcHZUFvh/WtFwcJ33kBdeJKH10dlV 1R8zx2rw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXlPX-00000002S7m-35Ej; Sun, 29 Nov 2026 20:22:14 +0000 Received: from mail-dl1-x1245.google.com ([2607:f8b0:4864:20::1245]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXlPU-00000002S6Y-28wV for linux-riscv@lists.infradead.org; Sun, 29 Nov 2026 20:22:09 +0000 Received: by mail-dl1-x1245.google.com with SMTP id a92af1059eb24-154e9d2d94fso2631109c88.0 for ; Sun, 29 Nov 2026 12:22:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1795983727; x=1796588527; darn=lists.infradead.org; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=msyIQ0zByGrOualZNhJ148I8FSacYFmBKjOmZVvRDzM=; b=ZMfdkil5N1/M+9uqqjsEbDUgUN8ROWYaDRDrxEUBwzq9PiSJ1rV42xoN643xQZ622a QUR4W3UruDtUu3XnPXWYQyZNjtvvMSENflOeR2h+slqRqxAddKigvvOw7kbuZkT7eBjV lxu7oAjYk0xt0lFHPO703uZ4RYPwrPsH0U5fX058ZADa9wZhUO89BSrIVzC4GfG3hB0M fjOBj9USeyeGOgEEnXwUuW17Kfy1Zt/bTXZ+EWem32KzVomdndULKrts6KdsTvq4ivA6 ZjVKm2IO4VaV+GpulbsQJe2ySBn8txEKNTLQrPWgNK5Ha5aOod3SBEof9bpmCMnAUEOA lH1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795983727; x=1796588527; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=msyIQ0zByGrOualZNhJ148I8FSacYFmBKjOmZVvRDzM=; b=deVBSFkskco7pvv9xJ71jz/THdUdq4AJdrkea/nf4068g04WVs6LuT2Tln6Hbeur9o L4PBFd0IAORG5ZWdBzzoVdr+J1dK7k8kzttm1PeN8yb0pPRpmltxuvF8cnCmsCJoyD17 MBQd1eu6YIIe6bT/+QxXLQ0PPLOR3vPl2w8MZlC80Ck2QA+0hf5uy70AgVQzgLW1wOF4 SYZs44xcl5WfqdDPnS+SMNzg4eUxofLkZWA9DLJKu8Hffi2ky0eb7buM3fuGXZaA0edM j9pXsRJkTp6lOjXVTZncC1jh4ZK9/b2N7y9w+RMqyRCUo7kmipRC62yKm9Ne7JCcwtTb qU2A== X-Forwarded-Encrypted: i=1; AL+hErGRbt5j8EiYiX45Jtxp+lKZIy/6ugaezGeW0sWhZsZ8pBtrZ+7ni8TqTQocfbchas8Cc0JgEV0neiudBA==@lists.infradead.org X-Gm-Message-State: APuU4Z8bPMfzFaqo273cW/Tcc//Ru5iinsRG4Jw/NmMi5TATCJ50V8DE sRDzo/VzN356D/J/t9R1yvnhOQnHLA4BNyUbosBU49/NGTp2vD+95m2P/WM3BiZ9uj+diLAoFq2 C6FGahA== X-Received: from dldz13-n2.prod.google.com ([2002:a05:701b:418d:20b0:15d:6b8d:2adc]) (user=surenb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:b044:10b0:181:73fc:e53 with SMTP id a92af1059eb24-1b5568e7699mr34510073c88.29.1795983726433; Sun, 29 Nov 2026 12:22:06 -0800 (PST) Date: Sun, 29 Nov 2026 12:22:01 -0800 X-Archived-By: Mime-Version: 1.0 X-Mailer: git-send-email 2.56.1.839.g22a8290db9-goog Message-ID: <20261129202203.1183277-1-surenb@google.com> Subject: [RFC PATCH 0/2] mm: separate the fallback to mmap_lock from VM_FAULT_RETRY From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: david@kernel.org, willy@infradead.org, ljs@kernel.org, liam@infradead.org, vbabka@kernel.org, rppt@kernel.org, jannh@google.com, ziy@nvidia.com, baolin.wang@linux.alibaba.com, nico.pache@linux.dev, ryan.roberts@arm.com, dev.jain@arm.com, baohua@kernel.org, lance.yang@linux.dev, usama.arif@linux.dev, kas@kernel.org, muchun.song@linux.dev, osalvador@suse.de, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, linux@armlinux.org.uk, catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, chenhuacai@kernel.org, kernel@xen0n.name, maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com, chleroy@kernel.org, ritesh.list@gmail.com, sshegde@linux.ibm.com, pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu, alex@ghiti.fr, agordeev@linux.ibm.com, gerald.schaefer@linux.ibm.com, corbet@lwn.net, skhan@linuxfoundation.org, rdunlap@infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-doc@vger.kernel.org, Suren Baghdasaryan X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261129_122208_663634_FCFD86AD X-CRM114-Status: GOOD ( 10.79 ) X-Spam-Score: -9.5 (---------) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" X-Spam-Status: No, score=-11.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 VM_FAULT_RETRY is returned from the page fault path for two different reasons. Usually it means that the fault handler had to drop its lock, typically to wait for something, and the fault has to be handled again. With per-VMA locks it is also returned when the fault can not be handled under the per-VMA lock at all and has to be handled under mmap_lock. The architecture fault handlers can not tell these two cases apart, so every VM_FAULT_RETRY from a fault handled under the per-VMA lock results in a retry under mmap_lock. This series separates the two cases: Patch 1 introduces should_retry_mm_fault() and uses it in the per-VMA lock path of the architecture fault handlers, in fault_signal_pending() and in mm_account_fault() instead of testing VM_FAULT_RETRY directly. Patch 2 introduces VM_FAULT_RETRY_LOCK_MM and returns it from the places that fall back from the per-VMA lock to mmap_lock: vmf_can_call_fault(), __vmf_anon_prepare() and the device private paths in do_swap_page() and do_huge_pmd_device_private(). VM_FAULT_RETRY keeps being returned in all the other cases. should_retry_mm_fault() accepts both codes and the architecture fault handlers keep retrying under mmap_lock in both cases, so no functional change is intended. The series only makes the reason for the retry visible to the callers of handle_mm_fault(). Only the checks in the per-VMA lock path are converted. The checks done after handling a fault under mmap_lock still test VM_FAULT_RETRY, since VM_FAULT_RETRY_LOCK_MM is never returned there. Drivers and filesystems that return VM_FAULT_RETRY are left unchanged. panthor_gem_any_fault() might return it after dropping the per-VMA lock and waiting, which is treated as a generic retry. The series is based on mm-unstable. Suren Baghdasaryan (2): mm: introduce should_retry_mm_fault() helper mm: split VM_FAULT_RETRY_LOCK_MM out of VM_FAULT_RETRY Documentation/filesystems/porting.rst | 4 ++-- arch/arm/mm/fault.c | 4 ++-- arch/arm64/mm/fault.c | 4 ++-- arch/loongarch/mm/fault.c | 4 ++-- arch/powerpc/mm/fault.c | 4 ++-- arch/riscv/mm/fault.c | 4 ++-- arch/s390/mm/fault.c | 4 ++-- arch/x86/mm/fault.c | 4 ++-- include/linux/mm_types.h | 23 ++++++++++++++++++++++- include/linux/sched/signal.h | 2 +- mm/huge_memory.c | 2 +- mm/hugetlb.c | 9 +++++---- mm/internal.h | 2 +- mm/memory.c | 20 +++++++++++--------- 14 files changed, 57 insertions(+), 33 deletions(-) base-commit: 890dc639d8a33e674caa7ea9993dbd2416660447 -- 2.56.1.839.g22a8290db9-goog _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv