From patchwork Wed Nov 20 00:08:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13880642 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 9F4D8D6C2B9 for ; Wed, 20 Nov 2024 00:08:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 462D26B0096; Tue, 19 Nov 2024 19:08:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3C4456B0099; Tue, 19 Nov 2024 19:08:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 240866B009A; Tue, 19 Nov 2024 19:08:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id EE75F6B0096 for ; Tue, 19 Nov 2024 19:08:44 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9C05B160880 for ; Wed, 20 Nov 2024 00:08:44 +0000 (UTC) X-FDA: 82804535436.25.6EE07C8 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf11.hostedemail.com (Postfix) with ESMTP id AB58E40004 for ; Wed, 20 Nov 2024 00:07:39 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=qgU2cnhc; spf=pass (imf11.hostedemail.com: domain of 3iSg9ZwYKCBA8A7u3rw44w1u.s421y3AD-220Bqs0.47w@flex--surenb.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3iSg9ZwYKCBA8A7u3rw44w1u.s421y3AD-220Bqs0.47w@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=1732061231; 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=TVe9xIxnbmkl7SmN6iZyRrlBkQz17Arq0DLY4ssSJic=; b=YHM0/r0TPO85k6WrOZe4yS0aQ/wybX56oisWoku7aOVOUx+0Lp7TxZmKxeybqjtOkIeVqr I3PJEUaUL6Q/XMiDCapI8byJrHd2ML7QVJ/n4R2AAIHx1DVp8SsEJ7eqgjGMqm9W/1kpqK S/JY/PhgCP1RqZCp3gGfocPDz+PGLTs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732061231; a=rsa-sha256; cv=none; b=1iG4cPZWtTzMvC78rDKFZOn7q1PDvvYbp7rU74ixxFUL5MvkGTUx4uTEnzIF9NtLeIFQ5y 5UGoLSfnGoMtW2VcfY19rFKmRmNrQZi2YfklC6AeYYcFkRXK7tXz9EYF4FERCOL6kY963Q Zuo8zsc2gRbFxnAHcq4X2LjpTjT9thA= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=qgU2cnhc; spf=pass (imf11.hostedemail.com: domain of 3iSg9ZwYKCBA8A7u3rw44w1u.s421y3AD-220Bqs0.47w@flex--surenb.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3iSg9ZwYKCBA8A7u3rw44w1u.s421y3AD-220Bqs0.47w@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e02fff66a83so5947248276.0 for ; Tue, 19 Nov 2024 16:08:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1732061322; x=1732666122; 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=TVe9xIxnbmkl7SmN6iZyRrlBkQz17Arq0DLY4ssSJic=; b=qgU2cnhc6iOk/2CejGbHayR1G3tYeWIaOsy37T0TYneskDK3+yiNlyk8XizKH+AYto +l9xdZVMkjqLVPxy3XfGC42rIfYoq+QacSB2yxm0lZTN8E8XCrQDZNSscZa2atgsXtGo QhKVjHsV1gRoUsFNYHtlCp8Ac1JbbyD8xUCRBK3XBlX/BjpTD+ZmzZXHU+r/3pb2WcIl tE3s51UV55UoTzcUeL+RnkweuEQaoQIyyxlA9ErC8Fsv4IMWnaInf8W+7pb0CfYZqf2k EuTWeGaFP8kwkzZQcYzOqdmFLXy7PJIdtL4pG5mEk+NF5WacMU3EvKkCvf1vg8PM+uRx zgmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732061322; x=1732666122; 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=TVe9xIxnbmkl7SmN6iZyRrlBkQz17Arq0DLY4ssSJic=; b=C/d3cABynI41DEHcUVlBoLLHVWQ4v2ETElmTDYl35Ww+d9ewiE/nQ2MT0nRSXsvZCK Yiht4IgeLo9kVsm+T8GDNH6LLt/iJWVQD7bx8JdoDNvXFOE4+PgF7nFeOoyOatXDn4+1 7zmYaR2KcM4K5oqjVzp6uUPEjk8z3nFt7Sowr4E/7+g+uZZfq+5qEnJFkrAmGz3ZUJPX UD0IcgzwJioqX9vCb9U3BUIOcW6zfvMJewKXAwKa7fFhiM0fQKfTvRZs5xBuPqcwGFmx kmxa9UfcJpNmM5qMNwQSAErITkme1Jy8/e/wWJwb8WxU90FXi2Fyw+VcIYSTd+mFvuzW 9moA== X-Forwarded-Encrypted: i=1; AJvYcCWBdkWmFlZM/hYd7WOyk8JLpQD5olMOce+W1dpqr/W4dTyxLyaQTjvqWDODmFPIZW5NPism2dDJ7A==@kvack.org X-Gm-Message-State: AOJu0YyW1kqhQ9Zplqh1amcYtjlk/QdVsjV1Y1SlMYCik5hnQfuWwd4d ZE5pXuW5WE919QRp7+1YBLisO8SiCTcwAPVmRMIo2iNWFnlMmqQNQuWEiKu2rsAdbtTcrYTiYnL 8EQ== X-Google-Smtp-Source: AGHT+IFNThkOcHUKsCtTkSyc+T5kvPSN7H0YRbmdu7qNTw5Do0Nv7SXuJL8X2fZ3WwFBn19KFwdE3O6n0sE= X-Received: from surenb-desktop.mtv.corp.google.com ([2a00:79e0:2e3f:8:af45:bbc1:fc75:e695]) (user=surenb job=sendgmr) by 2002:a25:aa50:0:b0:e2b:da82:f695 with SMTP id 3f1490d57ef6-e38cb5f8230mr276276.6.1732061321895; Tue, 19 Nov 2024 16:08:41 -0800 (PST) Date: Tue, 19 Nov 2024 16:08:26 -0800 In-Reply-To: <20241120000826.335387-1-surenb@google.com> Mime-Version: 1.0 References: <20241120000826.335387-1-surenb@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241120000826.335387-6-surenb@google.com> Subject: [PATCH v4 5/5] 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-Server: rspam10 X-Stat-Signature: qe7uwzh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CYdGSSonBzdzgYCirYyLn0kHeUSP+IGmX4O7YwWZ1w7r+Bo6UrHM78iUH92nLjxVWP4pZZmlGighxqmDJIPXO+/uFHGhfuAfPQk+En3IWNdHNawgG34EoZs5DYanm8AGzkpt5Ekr66HHH6NDtspeXNoB7ignWULzg/jhXFcAyuvoNmCHetmawUqSxDl0Dle0EL64wT9cx79N/q0DNkywWqds+zeKtsHf63u5GzPYxbf93gDNTlCdTKBwdE8yLMTKflcI7z5Ar3n9rXW3skFp8mgh4o4hZ81lA1maCeztTbi/mH816vVEheSCPlVwpl0SASF2bIoe7PNPla4Qs0bH0u9/Irjkdbtzwn5HXobqbNi6ydhsFxl6jS2efG3piVOY8sH9H+WFnG2zjhVsC+B+AZt63CjaYCCfJVOgomtKQw2HCEb7yCMrA+Ybl0uC1BZ/vmRHPgDOmeiyYR5+eHg2+9Vft/v5peV4xTN3JNgxOhAT28tlVloQPt/evGSyJ6TsqYU9Z2p5WxxBdXPzoqyfqowVhnKr79xQiw4BqfTHAhn63h7bbZ06ClFdj6Cyz1/8z4hCit9DOIv9CQLHSucTL4w+bSI1qVfwO3BP2oYF8A= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, 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 1bf7ad010fc0..a18450b6496d 100644 --- a/Documentation/mm/process_addrs.rst +++ b/Documentation/mm/process_addrs.rst @@ -686,7 +686,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`. @@ -750,7 +754,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 @@ -760,7 +764,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.