From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.69 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795983733; b=keGKCGFmvZa3Z7IEixRIt5EplFUNVWnLMP5S6uyPEQH3wNMapN3wV0U/tVQhAfuR4yKt b6yw0UKxunJyPvek97CY2ObURzkcEAy1Cj525aq179taGug6oxAF0zX17mFZKzbZQ8cQF LbICCLXUInM37Zm2JJYKT9NbRyBG8lqY1OGvIwG9UexvOrLdwvm22l615Ue4aRSCLSySe mIu1hFwetw1uvR+324DQgEodtWJJP57oLTapogIdaHmwygfwKQeghlAJcWbrQU7L/rCPZ 3ofmpT46Ov0QKr3jYtT97Rdep9HmxV4yu5Eh18tmOVPJkFGqnLvJ+uP8mEbrY2VUbng== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795983733; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:Mime-Version: X-Mailer:Message-ID:Subject:From:To:Cc:Content-Type; bh=msyIQ0zByGrOualZNhJ148I8FSacYFmBKjOmZVvRDzM=; b=KAcwUYAdvcNyTjjGwwZhtdQKPXZTxgSZNncua37J6MVw5KApQdCgb9L4AscitkExVDMe eSFYKyi7hEDny8hPTGssD16jLMynnusjnapPg+k5LJBtEmDhK7lLZK3u22KX3WaggBDiZ XemW+avGUMTP31Si3pW+WToEjriU5g2eNwl7SuFv8IlBsqI13VWq+DgHoR4LEt/QhixSk gx0IufgaJv0zjx6i4w8hqO7Aan+rgm+G6VpOaJvrJJB3Z2K2zQiF3R/tb73UCZ+URo27C eF72W9HfZAdqweohOISkSnlONp32/gb90KjOMsqRds3vM2nCAIU8mUlVDk/2KaU0gbA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--surenb.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=B9KfPMH4; arc=none smtp.remote-ip=74.125.82.69 Received: from mail-dl1-f69.google.com (mail-dl1-f69.google.com [74.125.82.69]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB9AF606A329 for ; Sun, 29 Nov 2026 20:22:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EB9AF606A329 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--surenb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=B9KfPMH4 Received: by mail-dl1-f69.google.com with SMTP id a92af1059eb24-1b3b45597c7so2543597c88.1 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=vger.kernel.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=B9KfPMH4q2n8GeADp8juv+CTM+hNzDk4uac+g1/kQVeFe/t3mvnONQRSbYZamxBCdy Y0Yuf/Rw7dzWzmgrBwNXLVZveRg+tkeZfKrdC9OuL8HP8Oqj7flf93fJidnKoW4um2UC 1z/sJN8VFiUEGGPeWBouJaO7qtRqS7DRDjxK+u192XmpKFawI0Q5pEcgFvbyR+ysLnWo YlVY+0vQ+rIsXf2f9eHh7sysCTJgbuZQXu1QbKOUhX5D5zOp7xo9wYGzp1d/zddnQ46f 0YUDhSp51YPJEreOpvDjt4f1B47QvQwQNu8xNuLjTQVgFqk4a+KlKifR0YsMhudnXd+S 5O7Q== 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=TfbFbT9dW+5vS1Hz8tU32pLA/Subq5FJJ7uctg4d4TA7caglX6FHg2IX/peIYv07f0 XAP8deQQWtpT1oWsDAS/ZF6PLGjBHhLsX6LLafBDxOdADRexJhxBL5XA+cmq7LReyHYP r5WX9W68uNRVip9jvL7VhOHmwj6KwJGH8Vjt9mREGYKm/ytjaijLZ5a4IHvMrNduvuWc gMqAuvZGgzzOpBNsw/Vx1vyriuzxYBN1ivblz4vJ6IdCjnzll/hRxy2pRLDwqet209/b ynzYg7anfriwGs8NrakJxSqU2oF+r2X9YF3YsXMnaa7qn7QzP5erkn5+Jg8ZzLP14BI1 eoCQ== X-Forwarded-Encrypted: i=1; AL+hErEy/dANdbeOlZcF5RRYm/c9lKtG3vmRY34LSeZ/7m5MKiiGPs0W8GGfU94ngmlysWgb3suwsy2LrRql@vger.kernel.org X-Gm-Message-State: APuU4Z+gVslRIBCVWpcINiGLjU4oMIbMW+9uUujcBgg087JpdL2PBbB9 EhB3MpkyveNqU3wlN6Ful1SrjpbPZOgvfEDTsSZM5MUGwNw1Yj5y1Z14e0qQtB9q3qT5jfK2l/+ fYc0rIQ== 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-Mailing-List: linux-s390@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 Content-Type: text/plain; charset="UTF-8" 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