From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.71 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795983729; b=2MoxSy8gdBekKm9SgokMofelCpVJZMTQti2LBlIw3shoRLIp9oHi/SzmVWPLEowsIqgj nCql9Lp2yR9LC+X/9kOLKcgHfEyzBPDMQhEKsk4e7J0pyeKiJGBmT6nJnu3MyDzVZiWSF cSJua3Vv7oWiAD0lInFrj8xA+i5p9+Y/SqZGOb8Y5XQHLimB75/5mlQ5t3Moc1G+LrRUj r1+/3kLC8xABVHo22lw/cSWZ878mp3Sa6abxC4A6CBgUn2fTYQ5mBE9gy/4tTJHCsp8/1 PNSAiWu82omtT9whhwj8mIv918NpcxtsSAd0zzeiExDddUgSNU73YxlmFwObPAIjdkg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795983729; 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=PxQkeQ0tjbDs5KXYH7q2XwInyqUCD2Y0tYZUwbKCG6cyOAZGQ5jdFigEMXXiU7UktYMY 8BwRfIU5a14DwZ4PGe/IfMSUjXZtC/8g52Pf6wKb6cVCrav+3D4Z0r/L1MwZqAv9qblSy 7rQg4XAlttzQe7vof6YGkR6UE0vOQbq3nairhQ65bzdX+kj/wGsWI3mT8QJrM/drhTiCt 3aYLgyoQoieZxn4pXtdnRIYXwMKkbnpgFDemXtPDiumrdRV4Fi8WYiCnHKT/oGhYMvm0G DwdMzweY7rrU1jf9NnE0v1SaSkwCAQu2Vyezux8kkLIjZUbDM18ynnlrf5Uhwu4vwOw== 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.71 Received: from mail-dl1-f71.google.com (mail-dl1-f71.google.com [74.125.82.71]) (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 E68F5606A327 for ; Sun, 29 Nov 2026 20:22:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E68F5606A327 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-f71.google.com with SMTP id a92af1059eb24-1b3b45597c7so2543594c88.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=kDoVe8+jyzO7US81L6IHMFSefSYHaeV7Vy5PEbFqMCv0pPjz6QUNyvu1UEWhykiXsr O2NSVIjg/rjXfKzSNkxTuR2DqNNpDDk3sQNpV6XNbYhu7GODDEKaTRB9e+U4cDtcoQoY gZDY1m7lKeSYuBclN1MkQRh6A3u8O2W5/ykej1ksvFRzQ3oZxbvY9ZMTNOWh5f6RHcML uobTBzsf5YvDnmobkkQhdYNNBKp0fjwQfJ4h0pJbMqqMuSeYiRT8p32mNeFw3b1prEoU on39alnwD/prBeMIzim7xBtxuFrniD0bZ2Sy0/x2YQIR8mtoXrtR/3beluTySnJTZTCF m2SA== X-Forwarded-Encrypted: i=1; AL+hErHZl1pytJNq8mwmXXDsn+wEKX+Sy4lcBNGY8EsZTD1CZU4tCuGK+XggTPRsCrFxGSsKcNxmtwklBi0=@vger.kernel.org X-Gm-Message-State: APuU4Z/6AJjRQxVCXhBRCackz1pDGSBtR0PAyoQlavfjf/mEGYO7ENrx /DxHJ17Tyu6uexjKvTaet3qeChtXeOxOeEgjUFb7sb8/w+qrgrnUAoU7ATkhZBi+FN2QWexEhNA ezxQdOw== 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-doc@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