From patchwork Fri Dec 6 22:52:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13897902 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1A03E77179 for ; Fri, 6 Dec 2024 22:52:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7E84E6B0311; Fri, 6 Dec 2024 17:52:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7993C6B0313; Fri, 6 Dec 2024 17:52:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 611316B0314; Fri, 6 Dec 2024 17:52:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 3E0E86B0311 for ; Fri, 6 Dec 2024 17:52:22 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id F2A22AF050 for ; Fri, 6 Dec 2024 22:52:21 +0000 (UTC) X-FDA: 82866034104.05.8F51081 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) by imf09.hostedemail.com (Postfix) with ESMTP id 4260E140002 for ; Fri, 6 Dec 2024 22:52:08 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=ExttRgZa; spf=pass (imf09.hostedemail.com: domain of 3IoBTZwYKCLEjliVeSXffXcV.TfdcZelo-ddbmRTb.fiX@flex--surenb.bounces.google.com designates 209.85.210.201 as permitted sender) smtp.mailfrom=3IoBTZwYKCLEjliVeSXffXcV.TfdcZelo-ddbmRTb.fiX@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733525532; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=j6wEf3Fj/sCIHriciJDFTmwIAy5yi6AjoE4yT83zSv8=; b=754rc+oN6ilJK5N2N1Ci9HO6ghA5GtbbvQMNlPbtmDP4yJSNy75ty0F4P+oFPdUXWwEAPr WPDf8Uk1h0erzqt9zgRu5S+4Y8EIfrKmrUTN711DaVmAZIiWVjeDAnC54uZ7uQ9xWRIbzZ 1W+57pUnb26aOhdlishhFZnCyXFGP6I= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=ExttRgZa; spf=pass (imf09.hostedemail.com: domain of 3IoBTZwYKCLEjliVeSXffXcV.TfdcZelo-ddbmRTb.fiX@flex--surenb.bounces.google.com designates 209.85.210.201 as permitted sender) smtp.mailfrom=3IoBTZwYKCLEjliVeSXffXcV.TfdcZelo-ddbmRTb.fiX@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733525532; a=rsa-sha256; cv=none; b=XLWl6bztjLV7m04s3dEwYLHspjtqCDKdywKgihIr5oyxRvbqa66KTa7+PYczqY6NEiDGuU fCzNRHIs4FfoGGYPYxe1637NAXxGoZtC+5oc+EOlJJV9dfAYbTTuFzcWh/I6oT6QSM4yQq C6nb5IMRZBYPd0LpGw8sSaEg7PAujno= Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-72527c426a2so2078205b3a.2 for ; Fri, 06 Dec 2024 14:52:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733525539; x=1734130339; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=j6wEf3Fj/sCIHriciJDFTmwIAy5yi6AjoE4yT83zSv8=; b=ExttRgZagR66HuAV5D0+V7dZel1+C/jAZ3J/lMkKpPuLXvXGRuXd3b6xU7+cSBiA0h UVjGNaEVfX4V4H6Aaq9BHOisu6ZWdE+/jV+cx3TLDQe3kJXgvIWxlcP7z8ZqbbXPDBrG muMhg4kvpPomEoUmcJ5YgLLKpGteaJKmAGAW6oqRgkmKVf0umbA4bR4cwGca546j6Xc/ r/3f7HgZoQr+sXRPKQXizrQiLr90LviSuocDtZRu4Vj8JoYroIU0PxMCeoTex6IsdxSL 2GsxA0HQgBwWWKjerzqLu5/N3POw+sRLwS/QrtzbOocNZ/8/oEJw93I/ZBubh0pIWBmc eXnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733525539; x=1734130339; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=j6wEf3Fj/sCIHriciJDFTmwIAy5yi6AjoE4yT83zSv8=; b=leCkF00cYnbSqynxpbWWhf/jX7A4n+hp3EQnRYma0cyc0ZkNhZcZlz2zAxwqfwvBD3 DoT5LJqprBr01lFmoBo2AsEQkQEreb6TsEUvHUv2FHbWmf/5NYVx8TxR9CWK8ZUev6qI Y3YEV4o0ZSXSTG8Ea2AeZw6iNQSf5/v8p4/byn3dzwC2ARpVslBtXab2hIuuQXcL8fMk Ln2q2MKayB+gboXoDBIDbf0vOWkMh5jLxNF01Zun5cRhcUfAJfgIZOJeZxIr/l29k6on aLVZrHLvthtZkQyQ+5JnmjiteQdWzbXdw3y+CZ5z8EYwvklvEn7bMPpjy84z8ncAQrW1 t0qA== X-Forwarded-Encrypted: i=1; AJvYcCWOofvWEteZ7nn80vkCrqzCX2oFvvHUN5RU+isLt4m4lD23wAyluy+xo0F1AitZwLuGFU7Z1tLTPw==@kvack.org X-Gm-Message-State: AOJu0YxuTqs2GzK6e+w0jeo6Het9u+CkDkMr5MRzXOyiXZWreO5LyGvk gqH1mktnDkUx46zBZE7wotgFHZHSE/dkUCodoHMb9GR78Bt6T1rdCoLkiz4/JBXCl+uESXRLeh8 tWw== X-Google-Smtp-Source: AGHT+IF/E1FLpmQ9hujXfDz8ah1g4xzG4PooG2XovTR77om7ynRlxwPBbvaTMprv3cmEsfAU/D0wit+tFCw= X-Received: from pfbeg17.prod.google.com ([2002:a05:6a00:8011:b0:724:edad:f712]) (user=surenb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:cc2:b0:71e:55e2:2c58 with SMTP id d2e1a72fcca58-725b812e375mr6388253b3a.15.1733525538875; Fri, 06 Dec 2024 14:52:18 -0800 (PST) Date: Fri, 6 Dec 2024 14:52:03 -0800 In-Reply-To: <20241206225204.4008261-1-surenb@google.com> Mime-Version: 1.0 References: <20241206225204.4008261-1-surenb@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241206225204.4008261-7-surenb@google.com> Subject: [PATCH v5 6/6] docs/mm: document latest changes to vm_lock From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: willy@infradead.org, liam.howlett@oracle.com, lorenzo.stoakes@oracle.com, mhocko@suse.com, vbabka@suse.cz, hannes@cmpxchg.org, mjguzik@gmail.com, oliver.sang@intel.com, mgorman@techsingularity.net, david@redhat.com, peterx@redhat.com, oleg@redhat.com, dave@stgolabs.net, paulmck@kernel.org, brauner@kernel.org, dhowells@redhat.com, hdanton@sina.com, hughd@google.com, minchan@google.com, jannh@google.com, shakeel.butt@linux.dev, souravpanda@google.com, pasha.tatashin@soleen.com, corbet@lwn.net, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@android.com, surenb@google.com X-Rspamd-Queue-Id: 4260E140002 X-Stat-Signature: fpx69kf78k6kfb97qrwr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+piLP+uEZTbKzOnCwM1uVuiRyrByDobRMGPhawpC5dEgdX5VeZz17OQYq++kJtI/NVGuhcz33UVGReTEwrgSuy2w3kKShKQ4pSvCra1CFSLciW03rJNoqNdU4kNxH6BdyPPxYNMniC/WRLmxLCBVz2Ys4weq+NqGypXL/YMgnJpfNoXokxPsjKlGM1CwrlGzgQbCRsDH78ChLgLdhTd1s7W+bZk1b46HRXe/6akAzDNH3ni65uF2FHwuRuPv+cDV29ViDqbWXwYb7NLigVyg6zS9VbDgYosJwWtq5h0JdU5dbHCVKBYGJqezkYBlCW7+O1BgiRYOVo4GS/7yuwARJ6uh6FxFPD2du2dotUwNVvpEQKizPBfHKahyvsPvt0IlFrxVoG/OIaGhpQHwBwTAQCw2AswfQ27+IfjfBuip17tl+XlrrqqyHD9KOXV5sgj6xHu5NNW2ji9nP0+6UMlHkf00eI+9YE1Hu2bsyA9wTPGlj++TlW8FOVPTr7Xf8jnI9ntwxqrGgsCv7mYGQ9wtHykL1N8rLydC/36O2Y2fvfddQZ/OlmS3c4RyNNqJMpiLI5YxTiA= X-Bogosity: Ham, tests=bogofilter, spamicity=0.003399, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Change the documentation to reflect that vm_lock is integrated into vma. Document newly introduced vma_start_read_locked{_nested} functions. Signed-off-by: Suren Baghdasaryan Reviewed-by: Lorenzo Stoakes --- Documentation/mm/process_addrs.rst | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Documentation/mm/process_addrs.rst b/Documentation/mm/process_addrs.rst index 81417fa2ed20..92cf497a9e3c 100644 --- a/Documentation/mm/process_addrs.rst +++ b/Documentation/mm/process_addrs.rst @@ -716,7 +716,11 @@ calls :c:func:`!rcu_read_lock` to ensure that the VMA is looked up in an RCU critical section, then attempts to VMA lock it via :c:func:`!vma_start_read`, before releasing the RCU lock via :c:func:`!rcu_read_unlock`. -VMA read locks hold the read lock on the :c:member:`!vma->vm_lock` semaphore for +In cases when the user already holds mmap read lock, :c:func:`!vma_start_read_locked` +and :c:func:`!vma_start_read_locked_nested` can be used. These functions always +succeed in acquiring VMA read lock. + +VMA read locks hold the read lock on the :c:member:`!vma.vm_lock` semaphore for their duration and the caller of :c:func:`!lock_vma_under_rcu` must release it via :c:func:`!vma_end_read`. @@ -780,7 +784,7 @@ keep VMAs locked across entirely separate write operations. It also maintains correct lock ordering. Each time a VMA read lock is acquired, we acquire a read lock on the -:c:member:`!vma->vm_lock` read/write semaphore and hold it, while checking that +:c:member:`!vma.vm_lock` read/write semaphore and hold it, while checking that the sequence count of the VMA does not match that of the mm. If it does, the read lock fails. If it does not, we hold the lock, excluding @@ -790,7 +794,7 @@ Importantly, maple tree operations performed in :c:func:`!lock_vma_under_rcu` are also RCU safe, so the whole read lock operation is guaranteed to function correctly. -On the write side, we acquire a write lock on the :c:member:`!vma->vm_lock` +On the write side, we acquire a write lock on the :c:member:`!vma.vm_lock` read/write semaphore, before setting the VMA's sequence number under this lock, also simultaneously holding the mmap write lock.