From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 AF02B606A331 for ; Sun, 29 Nov 2026 20:22:13 +0000 (UTC) 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=KjLb83Vo Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4jcz8g5Ttqz2yDc; Mon, 30 Nov 2026 07:22:11 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip="2607:f8b0:4864:20::1245" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1795983731; cv=none; b=hFAvFD3mvdL9wDyGS+5zkYOxpt/YkTxFzI2SE7YzmqYu5bQBnXXIskRYLNjbNpcwK1s6wqomi7UQcebw6S0vg88tt+J5tl9c99vu28+2xiHHTNruR6x3fB0/kUeBmq7BfHSQewtT/xma9giYfqCvVAnZX1Kb7fCdRMMWbnarZ86XCuCoTrTd0KnP5sC3ipR45HPdT2hWCtkWd6KuEjGarEbz2h5QmFitDLj15cPwmWOJ9cFah/11v5RfgXgD5B41xbdBTq0cZ8UofhxK/1kPfQMm7a6F7L93hBNGkBPo+aqDyUofjIn0QUXI7NkU7FSyMrWN4a4J/ZLeOk8b8wfrdQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1795983731; c=relaxed/relaxed; bh=msyIQ0zByGrOualZNhJ148I8FSacYFmBKjOmZVvRDzM=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=Lcd+dukf4K+rRqOwTw3HeRT/n2TZUUBO/p+eXP+ZHEYxUMO2u7OqA7yOjNrnWhlmVzYLe08b9w7u+eknMktNKANndTfFO0T1njCj7k53UhIMbnqgH3FeHKX1vr1MRhFKwaN/tlWR31vpcTkCPJawL4A9kF3mdjg8pJ7MG2CHavhsmZvE3Vm2X+32vuXIytEMOmMAh1Jd9a0umf1UgAPB7uQ6Y97ybYArni8F+Se3MHpHzKSKnwYTJbx9bszcp7S3xTEjsaaztJRXB3Ho69xGqFHghGJbCaVQMiv9kgnJ4sT4f14LOGtY5tNP7V8SqM6VVJijf1maXpb5xygDgQptcw== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=KjLb83Vo; dkim-atps=neutral; spf=pass (client-ip=2607:f8b0:4864:20::1245; helo=mail-dl1-x1245.google.com; envelope-from=3bokmawykdbmbdax6uz77z4x.v75416dg88v-wxe41bcb.7i4tub.7az@flex--surenb.bounces.google.com; receiver=lists.ozlabs.org) smtp.mailfrom=flex--surenb.bounces.google.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=KjLb83Vo; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=flex--surenb.bounces.google.com (client-ip=2607:f8b0:4864:20::1245; helo=mail-dl1-x1245.google.com; envelope-from=3bokmawykdbmbdax6uz77z4x.v75416dg88v-wxe41bcb.7i4tub.7az@flex--surenb.bounces.google.com; receiver=lists.ozlabs.org) Received: from mail-dl1-x1245.google.com (mail-dl1-x1245.google.com [IPv6:2607:f8b0:4864:20::1245]) (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 4jcz8f1TJ2z2xGF for ; Mon, 30 Nov 2026 07:22:09 +1100 (AEDT) Received: by mail-dl1-x1245.google.com with SMTP id a92af1059eb24-154e9d2d94fso2631116c88.0 for ; Sun, 29 Nov 2026 12:22:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1795983727; x=1796588527; darn=lists.ozlabs.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=KjLb83Vo2NaBxmZ0zuM4+whVrfyxft4dB/h9DVmqbIyjk5DcEPBv6Ry1D8/yJfwEie V+auXrasaQtab8HIdTwZ+EqDqkeBQuPLBfh4nGRR0O2WftAU9ygD07C9GXNgrKWSV++p qhh+7tz8FyB/H1Fi8dJUH5ZA3iIRg8SmXUevPl5yHRZnLd1z2gI1WF6mCivOMtalT8sq j6sWhZWSIrG6i04MYp44cBfnbFe+VudYt1+s9nGBQtmLWymdSwUXLZh7fa+geZ16MJlD Nu5lNvMDYBPGbGvrkG8EyIt3sY82AAsQyYeFu61s9wACqsbWMBNJYHGaUj064ZN4ujyh W60w== 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=wADVzJi0rNjdOvjQucuv1gyvHq/wRzh7OX5DgyMV1x5DgSxiY+TB+4+r8xDK1bCwDM aM7MQChuNTLnbSlzSPoTU5YXn091PqTTmfxZwoQz7NwozMqQ0SOT+1LtQHhVQOSuYqy4 /gQW80JUVhIhV2lE9ZneLSQ4jiC5jYnD2U88I/hb6so4UAqPCJAC9AQ57qpKWqX3G55W gwR6T2fP3M9xBchrsADVw+15WAuF86LzQQ7QM2VeOejf6Xq1aVm2LpU9PK3CL0yy8Cek PPcp7mGbetxt33r/UpIvonId7X/W/IX2F1TEDyFPUFPbSnAGMqvfON2HlZjH70Zwxi7h NPRg== X-Forwarded-Encrypted: i=1; AL+hErEVFkPYxgN9jkA16qgV2cxrGZR5tLIe/1h8qtsPEvzdq6qeqyjssLCFhglD0wxEeoccORaoynLAtbBQciw=@lists.ozlabs.org X-Gm-Message-State: APuU4Z+iOWRgsB43634kxVNLgicLZwJ4FjEo28BhwIlsK6tvvsZwdQ1T GGzHSboF1TGJO53/4ot6roFwL0aRnpQwfKTIhY9zYY6SlqfAvOz8WU0m0EOwAzgasqpcVpqwmcE pJFbrwQ== 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: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , Precedence: list 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-21.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=unavailable 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