From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.70 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795983728; b=RgJdmxfIUlz5Lhxe45IVRcLnFgP9WRcRcwHmgzmENkP4GjSdot3bA3Loo2K7Lli9XrnT UeCKauZnVdfLb3o7HiHu3knUIhwMdPlxKb6WHksH2N2rV/g+A+NR+cm0cldso3Z3e/qvY IWqds2fu6t4NpD0b1Jfu0nEjsiUvnMpOzzFtiWA5l38fpcfjIgliT7eDGA+XxaHBXNSAn 1cBiuojEQtqbYxwV0aOJRQ9SEiyGIbeniUku9Jip8km9KYkvuLDoqu1BkvtUsWRSMajOI t6NS4dz6/Awxg1ZAtRTaGXmdgP8iHS6pmDkHSn0qFC79i6VTzPWfs1V1ZWvywdeRDhg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795983728; 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=wJjuq1kkMmQOQBcMYFDoKI1dEo9GqJKIxvqJwIH4KhOoMev6XjjCUppHhpu17R07e4jq wtji7cCkhpeyU269VGrJwBbh5gTFsHNHCrjDi12PCLbipOUmawoKWSfXDI9cNlMOjNJyu PmFpE/vZVhbDlfpLnTfyZ4Bpv7lGxJozqgXQiNcfk2YNnOc20+Y8e7ZbrmYvi5YdHwhlr g4NDGtfX2bHcsxgItyNP3RHC8k/org9/NYrct484ZVnG/W9rhJ2kIEL850RUcAbROlesq o5D+q7rAeIbCOeEeu95J444SPmk/M+I75VhX8Ehj+jrD3Sy4vYgIA0PUkhD6vpeNnvQ== 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.70 Received: from mail-dl1-f70.google.com (mail-dl1-f70.google.com [74.125.82.70]) (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 DDE27606A31C for ; Sun, 29 Nov 2026 20:22:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DDE27606A31C 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, unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=B9KfPMH4 Received: by mail-dl1-f70.google.com with SMTP id a92af1059eb24-1b3b45597c7so2543601c88.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=W4Msh663oZCvM9u00jTNGmuUSXQAkbjiJ8dKtBipDzriwD8XCOy/FmGFSFIHv7Sa7O +xrO5PWvg6D3tLoQlSW3dyOUyZ/+Y8E4hRlQwX31WNubpuX7clzaAAi3HcChwdOjglPj Qdo8XYLORr9MveoG0CpfW5rNDOZXrbyH/CsgLvnsPOH5M16SuqqpKVdwH5zqbpeOoK8J Xi9xo8Mr8ywArBcAyEGEwhHh6wrLBNZ9lW4q4+b37nGLy6Y0wlvjxq9r5XSXE8yPbamx VqBUFtZnDwE3NVNdtwqJDDfs5bdoSifOGabQ7EWJzlyce2h6VqVDn8EM7n8sTlrHHoDJ Io8A== X-Forwarded-Encrypted: i=1; AL+hErFOsNIKr95sFe4NUcE9aH17KRnbL4O+SM+pyeItOy/+2pmfWt8PlG/BmZvph6O8DpT5GmYmCv/CrJPJCp8=@vger.kernel.org X-Gm-Message-State: APuU4Z90UHa9Gx2gv6+a8K0pNO8lgj+7uy7rCWj0o5EYSM1L22n1X2Ls ZZk3vIdb2Q2ZNFaJzkBYOouTa+FZ/NRgcedsTEbO545NR20XDrUHLKwc1bCvIvRPqMmXi8L2eGD aeYZ3zg== 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-kernel@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