From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4786235F615 for ; Tue, 14 Jul 2026 22:21:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784067693; cv=none; b=Pya9MilYlm5+X+nBVobpf72IMRFW5tqo0zD4/oH1XGL5892tvZH6y1fHG1EUolFIe/x205qqbbEmQILWNqIDiHilql5OOjNNLY8Gk0q77T9Rs/p4ZL0Kjb/d2FP69hIS2VTZ+Rkrq4kZS9A2fgYRsBIszDM0LhGwyAVxg8aiyBo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784067693; c=relaxed/simple; bh=bwr01/9WY7csMe3oixAvNcmOUvWfBdhgJjR3WJyG5E4=; h=Subject:From:To:Cc:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hvc0lP0JUVptMIOf6i8CyoK3VQ3SSSZ3UBGHja4OEJ6dL5ZoIfdPi+Sfuc4nkWFuX9qfa8nbc3836PAFX4jOu/m0Y8ROp7NC83KzIVrskDKIBXrgRcjU32denFJ7AVc954lbEKLkDuromLguBneNhmhaHTDOZTDfLReET1+8J94= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=pFM+hxXf; arc=none smtp.client-ip=209.85.216.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pFM+hxXf" Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-383adaa461fso1100676a91.3 for ; Tue, 14 Jul 2026 15:21:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784067691; x=1784672491; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:user-agent :references:in-reply-to:message-id:date:cc:to:from:subject:from:to :cc:subject:date:message-id:reply-to:content-type; bh=Vc1a4EA+CKVDZWmxoam2W7gn+VW7+IE4FDUnuymM6t4=; b=pFM+hxXfzFnja+aVqNPW9SovupETbvBAdQAZy9VjiPEUkx+xPnbeFY8Sy9DLT8l+RG UYtifsORQ6WeMVOcakDxYKwXZk6YM6vujXJyeQGm/Jozr4apH4pwDR0VUQuyYt/m55VG 4880/fqC2MmP58/NWVVgs6N9dCIIuFF2hcNVU16N2rnbeBCrFvQGVA0zR99UFV/BEqm4 8RmPxacetvCIjf9FAsfnQH2IoxGUphSZkxRXsaGgXXmh/OS9wS6Pn/9TprTwzTqvBKht QI4LCVXsje05oyOd4LlLa/rtoMj10S1a8n58Z8697TLf5jb3SaJ6uCRXhW188Fxc2Ilf 3YQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784067691; x=1784672491; h=content-transfer-encoding:content-type:mime-version:user-agent :references:in-reply-to:message-id:date:cc:to:from:subject:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Vc1a4EA+CKVDZWmxoam2W7gn+VW7+IE4FDUnuymM6t4=; b=IAD62SpgiHWWmGLcqR06EThdR57hcm79Ko6D9EAmZ/19EQM/HNlampfYtZ5cWCzoOw zrursAoLlvP1lacBoD6wRMIST/iSjB+BlOXp4l0hMXOTE2FTyk0bwePTBIiIlI++5dxf IKU4FPHoWhx5kdFN6QPdMQlkXenLRL5J7Q496eUx8GFUj4ZSodZxUB9gJ46d7rQwzZ+Z a8knnzV088GIIfQ/Rk3J6tMP/+/V1xRYklyO3nLAkbS7h9dOz6+KPm8SyOperQvb73fK nxZfVaaTrPKW/p9YJ+Gy5X4H5VJ9U62/Llbgsrx7aGvRg3MZsu4LJPS26IXNfWml94wh dcqg== X-Forwarded-Encrypted: i=1; AHgh+RrDVGFQOvmI59eINLnaUKWn+7Nrh3PUD683jPLl6c8SXH3s+PELXysFHmNCIflYvFNqLoh6iHRiFwTGaRs=@vger.kernel.org X-Gm-Message-State: AOJu0Yx1wI5A4Gk7vQ3HQFbsbl8sYsqTlxNfo1XNntGuA4pPcoREYYT/ 8sR7WsP3kvh7XsB5zw/WNcqKlnqLO5fa3ZTBdxebrkA3ObnlOy1ZCQ5v X-Gm-Gg: AfdE7clwR7xJ1rNvV4z3Y260drSnlcTaUr4dzH7uB2Tn4t11D+Ul+jk9YXhBoszEMzb rI6FrvmiSVOaXTzkkMRV3Xmne+n50PYWd6nZHGxF5yPqf9DstkQutVnUAJ2Ob8/6ZhXxM0Ctf1s KcPWKDUKntylpaV9zsdi1QyMaL+DXD/xtt/V8Tt3b/Cq7gpjOBoIRzJrjohNH6S1RXjMw1y8yXL kn6czMyOLtuQci+nq3PNG/+Qb8MKs76oW0nap2C/FZbJIgb9pylUZ0DHVr+x+wcfKkRCv+HbO1c +JXPGVgLcxULfRQ6uTRk/6PZI4Dc2LmNm6qUVeP/ekn9DXTzWUkjAuucj0rGC/5125d4Je9vFlu xBXg+F/ZZXA4w+biyxmpz+DW5ymn0BB6SV2Ak8sGfBCs4mlGBemoL4zWJNnKRTuBL0893gMDOxH nlASgU0SnbLFkGltqhkbCVPjynFDuuPx+U/mZytc1JiMSfENzQUGaC4rQhKYc= X-Received: by 2002:a17:90b:3d4b:b0:381:1f51:1ff0 with SMTP id 98e67ed59e1d1-38dc782ab85mr13404006a91.2.1784067690606; Tue, 14 Jul 2026 15:21:30 -0700 (PDT) Received: from [192.168.0.160] (c-98-225-44-182.hsd1.wa.comcast.net. [98.225.44.182]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-38e172b6d08sm2132074a91.2.2026.07.14.15.21.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2026 15:21:30 -0700 (PDT) Subject: [PATCH v2 1/4] fixup! mm/hmm: add hmm_range_fault_unlocked_timeout() for mmap lock-drop support From: Stanislav Kinsburskii To: airlied@gmail.com, akhilesh@ee.iitb.ac.in, akpm@linux-foundation.org, corbet@lwn.net, dakr@kernel.org, david@kernel.org, jgg@ziepe.ca, kees@kernel.org, leon@kernel.org, liam@infradead.org, lizhi.hou@amd.com, ljs@kernel.org, lyude@redhat.com, maarten.lankhorst@linux.intel.com, mamin506@gmail.com, mhocko@suse.com, mripard@kernel.org, nouveau@lists.freedesktop.org, ogabbay@kernel.org, oleg@redhat.com, rppt@kernel.org, shuah@kernel.org, simona@ffwll.ch, skhan@linuxfoundation.org, skinsburskii@gmail.com, surenb@google.com, tzimmermann@suse.de, vbabka@kernel.org Cc: dri-devel@lists.freedesktop.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-rdma@vger.kernel.org Date: Tue, 14 Jul 2026 15:21:28 -0700 Message-ID: <178406768885.1106335.9955379956617151440.stgit@skinsburskii> In-Reply-To: <178406760622.1106335.2379450382728057793.stgit@skinsburskii> References: <178406760622.1106335.2379450382728057793.stgit@skinsburskii> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The hmm_range_fault_unlocked_timeout() example checks for a concurrent mmu_interval_notifier invalidation after the HMM fault has succeeded. The sequence number used for that check is stored in range->notifier_seq by hmm_range_fault_unlocked_timeout(), so the retry check should use the same notifier stored in range as well. Update the example to pass range.notifier to mmu_interval_read_retry(), and spell out that the retry check uses the notifier and sequence number stored in range by the HMM fault helper. This makes the relationship between the HMM walk and the later invalidation check explicit. Signed-off-by: Stanislav Kinsburskii --- Documentation/mm/hmm.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Documentation/mm/hmm.rst b/Documentation/mm/hmm.rst index 5c88d2cf0818..fc1b8dc19825 100644 --- a/Documentation/mm/hmm.rst +++ b/Documentation/mm/hmm.rst @@ -206,7 +206,7 @@ The usage pattern is:: goto out_put; take_lock(driver->update); - if (mmu_interval_read_retry(&interval_sub, range.notifier_seq)) { + if (mmu_interval_read_retry(range.notifier, range.notifier_seq)) { release_lock(driver->update); goto again; } @@ -225,7 +225,8 @@ The usage pattern is:: The driver->update lock is the same lock that the driver takes inside its invalidate() callback. That lock must be held before calling mmu_interval_read_retry() to avoid any race with a concurrent CPU page table -update. +update. The retry check must use the same notifier and sequence number stored +in ``range`` by ``hmm_range_fault_unlocked_timeout()``. Holding the mmap lock across HMM faults =======================================