From patchwork Sun Nov 17 08:09:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13877800 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 AF9A9D68BDD for ; Sun, 17 Nov 2024 08:09:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 472A66B00C3; Sun, 17 Nov 2024 03:09:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 422CF6B00C4; Sun, 17 Nov 2024 03:09:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2C5626B00C5; Sun, 17 Nov 2024 03:09:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 085286B00C3 for ; Sun, 17 Nov 2024 03:09:58 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id B1278140193 for ; Sun, 17 Nov 2024 08:09:57 +0000 (UTC) X-FDA: 82794862290.12.AB5766E Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf10.hostedemail.com (Postfix) with ESMTP id D7549C000F for ; Sun, 17 Nov 2024 08:09:34 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="zJ/mJpqQ"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf10.hostedemail.com: domain of 30qQ5ZwYKCEMxzwjsglttlqj.htrqnsz2-rrp0fhp.twl@flex--surenb.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=30qQ5ZwYKCEMxzwjsglttlqj.htrqnsz2-rrp0fhp.twl@flex--surenb.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731830930; a=rsa-sha256; cv=none; b=y8I4dnkx98keVSu56I1qb2BY14sRUZvTIyspjQel3qKWXpEJGFrHsoWVrnUXITKFpM/AKy FtKuzr43vUe/nMuuqlmsuc7FXUr5jzSsekk8esLn56Zg3VMt6UwEu2GDSbGsK6wuJTWvtH EGUZIlFjf+8tEbZo5riCPkH54NQK+hM= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="zJ/mJpqQ"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf10.hostedemail.com: domain of 30qQ5ZwYKCEMxzwjsglttlqj.htrqnsz2-rrp0fhp.twl@flex--surenb.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=30qQ5ZwYKCEMxzwjsglttlqj.htrqnsz2-rrp0fhp.twl@flex--surenb.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731830930; 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=zl4EwbYWjmb9bOVWlwW6No5gLVWg2UpIpABslli/f89PNh5b9wEJHuwjjZxrq8EMuo0nps 5NVSa1ZF6DHDiRgryvDTZC5oPZHvhL/XHvuhXJGLd3GuYMzdcxGJRZYesEQ7RjQNFZCnTG xxraLDXBpsIwuMJZdoni3vHSFUP1+h4= Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e3877744e45so2332838276.1 for ; Sun, 17 Nov 2024 00:09:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1731830995; x=1732435795; 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=zJ/mJpqQTL6PP4Pux5OIcOShfLrf/GAzByQkE/B+BqpFVIJDVoFbo8pt2zjmITBBZE UFx0SItp/Z+5U5FKqiSxU9FUXgjPoXTQmJG1i3D4taQ2baekeKfycm48z+vjKAHJEg/9 WJ/nouUzkVUB2WkvmcNbt2NT2yhnxfjojDZeBBS7p2Uw8KmioKZMz5I2dCUyfdcPZCtS nFczZop27OXPWSvC61CiqgJyHFPfvwUii0+zwD68D/Gtu4BpNN/6+fOvZ1ow5PF5ghbD l2QX1sL4S2G3/n/uwUS2kS21ahblapPcMtRjuMej+GSE96pINtsJK3bLSXN68DWQD83L jOHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731830995; x=1732435795; 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=Y7rA6ylFHorPBg1s+QTrW8ZrIrx7FSwNU83JPjJhDXNMTnrgSr8nWhButFuWatJmzo TyPNy9VP0TGmXsN4GqYdWRrW/3XwoWeJpcT2H/295FqdRYv6oHsM7nnCZa5sKjZ3T4J3 Qr7ULy4mxirNT67/KtK3bu/0OjYkAcZuYOluaHA9OuPelfcOA7LbEbmcz+3TxY4JQitR UmeAyB3CnN4oIQ5364ZOb2Xw4sX4AHgqYxNCcpJgOH2vP3YaDzQX8mmg//15OQpOCz1B dGv73h4A5E0ojCkGEM588SPd/z/4r7I3nG34CEOR/M5o9yPlw0oVx11Py2FAtyW+MWWU VSIg== X-Forwarded-Encrypted: i=1; AJvYcCUGmw00YeqlhxuA/w8bSqIsh2t8wc91Ux2vt2KxCCsYvWqf+u3RELdKdEcUV4URTquCvqzifxnJGQ==@kvack.org X-Gm-Message-State: AOJu0Yz3+R1MFpPjdxcUzJXNx1q9EbLPNBDhkMdkvWPQvFGDI/CsTBZ1 pxfXpshYM6wZojy7HfdtGQLHssDQ919muBjyi7uQKSapLSl/fZdjK62eR7Y1DeKKTxoV8e3efbv kiw== X-Google-Smtp-Source: AGHT+IHOo0SNvb429sH9y3xLmKrGp2y4SlbBBZl72lF8+egqZzHX2n9q6YU+duTw+pCfixwfbSLpKdu+Ko4= X-Received: from surenb-desktop.mtv.corp.google.com ([2a00:79e0:2e3f:8:bafc:6633:f766:6415]) (user=surenb job=sendgmr) by 2002:a25:aa8b:0:b0:e38:816c:df18 with SMTP id 3f1490d57ef6-e38816cec5dmr3614276.4.1731830994994; Sun, 17 Nov 2024 00:09:54 -0800 (PST) Date: Sun, 17 Nov 2024 00:09:31 -0800 In-Reply-To: <20241117080931.600731-1-surenb@google.com> Mime-Version: 1.0 References: <20241117080931.600731-1-surenb@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241117080931.600731-6-surenb@google.com> Subject: [PATCH v3 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-Rspam-User: X-Rspamd-Queue-Id: D7549C000F X-Rspamd-Server: rspam01 X-Stat-Signature: bf7f9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UbHYUzeHCsxfoWonSMtu3ydtqUdr8qmdzNOLIne15QxLCS1bqXuMEAv06xlyiRNf+Dtk8t2ih1tYIXbjfTq0Ehg8wps3Mi3jcABTfDuo3UsvyWmWxrKKh7KExiZP5fzYxGzyphWfG9cGqrI39jYCKptLEjC3bGEtpf0Er9eivC+2t2afh40zPGUNt56d1GzyEGopKbpi4hx5YoQNn5a/tMHOgD6PcFCLwZ8NZ9cNCv6toT7CVbNu2iQlV6W1tEyn1uzl7eDlsY3vj8zQlWv2RHBdpVc9o9icBt9XcbHsFETQLSiX0Lve+M2kt7eg4jw+Y3rZHIf0+NjbwGT6jLHYlQe1dPpcBf/JDzll8EMSh8SaAPNBwTzvQH1ghr5RyXP6CNcyLkLRT6FJTZ2WyveVAnysWO8sbBZV8cFS/3lf9lT1NEIH+zkxfOA82JP6+HD3dXsjqDCAywOojGdPlJoUYnqegowhvCurF4OeHBwppsQhE0D3N29taSOYjBLl7JmpShk/RFz5FxzRpmcg3N8W+klmMHAZ7JY0fGzOzDNfAMDgYzkIErNbDulYS+7huBoBoU8= 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.