From patchwork Tue Nov 12 19:46:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13872896 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 C5AF9D32D97 for ; Tue, 12 Nov 2024 19:47:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 584676B00D2; Tue, 12 Nov 2024 14:47:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 534BB6B00D3; Tue, 12 Nov 2024 14:47:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3D69C6B00D4; Tue, 12 Nov 2024 14:47:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 1D7886B00D2 for ; Tue, 12 Nov 2024 14:47:04 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 9CA4FC0161 for ; Tue, 12 Nov 2024 19:47:03 +0000 (UTC) X-FDA: 82778475066.30.D47B39B Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf10.hostedemail.com (Postfix) with ESMTP id 299FDC0008 for ; Tue, 12 Nov 2024 19:46:43 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=vzQsPCWF; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf10.hostedemail.com: domain of 3tLAzZwYKCCUTVSFOCHPPHMF.DPNMJOVY-NNLWBDL.PSH@flex--surenb.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3tLAzZwYKCCUTVSFOCHPPHMF.DPNMJOVY-NNLWBDL.PSH@flex--surenb.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731440759; a=rsa-sha256; cv=none; b=DoNafKy2W/vpVetqzDDCV6Jw2pERCRwveCNLCILa3A7ZqntytKDoi40PDMm5XA3McKzRSH rXBVHUgjiPAbxDwaEydHlc8uJh2Q4SJ/1POSPWmoTMX2u3CkW4b6VDRdvRTEZofF2b1JyU koKvSuVE4eYohlUCQ14SIUKPp5u+uFo= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=vzQsPCWF; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf10.hostedemail.com: domain of 3tLAzZwYKCCUTVSFOCHPPHMF.DPNMJOVY-NNLWBDL.PSH@flex--surenb.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3tLAzZwYKCCUTVSFOCHPPHMF.DPNMJOVY-NNLWBDL.PSH@flex--surenb.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731440759; 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=wUwaf5ZgB/1FQH1yPsvN8djw+8+0TDY9z5rOH6D3QU0=; b=4Q6FJzBwGT/vn0R87qwfOzTruKYEagyzYoFOKzxc6AgZ9+n/em8x9q9MAatyInOi2nAjc4 0HEwQkSSlgC74FBIfWnGisVcRdHOIvbCjqheXVxzdLxzp4tfH5//0QJbuXkUFZA2dh2fDd 7EvbPIfueQ9v9hVus2pqziUJnWxXhcw= Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6ea33140094so106910187b3.1 for ; Tue, 12 Nov 2024 11:47:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1731440821; x=1732045621; 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=wUwaf5ZgB/1FQH1yPsvN8djw+8+0TDY9z5rOH6D3QU0=; b=vzQsPCWFaaIO5MQ3FMvCDNfYFfXV7odskEeh7ilR5TN9ixn4MR+7p0xLvdLV2ap8Gs s+2LCleAnZ3wyB4eGOTJhm3/sijF2HW1KGsshCKYlN1rXIuxQ6wpOwqIWiR+ws154joA s5eJdOoar7WH882A4nrZFxdynlIb1F41RPaTUVCg6AJKQ9rgHmPO7tY62htSDiSk2XiP MdZQ1HGkjtLPGekageY/CM0N4WZ2DrDiRO5Fuyr3eZpYOpi8WhJ9LnKHIxymO6B9moaw EqYQjhVt0S9d0j97X627138uin9Agap80V1vNsTBSQMMgJ7a52/4NNwO3spV8ZYE+7ET uB9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731440821; x=1732045621; 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=wUwaf5ZgB/1FQH1yPsvN8djw+8+0TDY9z5rOH6D3QU0=; b=LYHi9KrHNiMeCdTrjOW28kfQ4oUWx70e4XjALQEOmY/tI/+m+GnAc77eko+pVeZWNq rrBzA4SUI88FG8GH8pDkEYmWmX6YDsjilE316gRyqloc6Mv8eNcpRn8PS3Eqp/IOyDaT rM2rIlOqeL5sc0wtKJFHEWkIc0+9xVqlyGPL77yIEgKuZ842BKb5NvYtUPHrsensAYBN xBY/GeZUVNImQxCIUaV7JoxivXt2aJp928rQZS0SURnkGBFNP1gb3j7aXYXzADRj77/k 6vqsgT8NwjUiLtMBjaE42Mkwmnq+tyrt7KirpZFZgEKnmUuV7mSgImIZqkSo538CSaba cghQ== X-Forwarded-Encrypted: i=1; AJvYcCW4kEKoL2C3+7vKPg5mmJfTiSFupIWnewEoJU7nzrb3mADAqQrCtQ4gGTEkYitlvaaWVNZ8X9KJ3g==@kvack.org X-Gm-Message-State: AOJu0YwLaCZP48fvgKLkOQQjgvxJGsNTF1864c8QV5NZA7++/fZyAJB8 qc2o2eJHD9hxKIEq2PTw0yHZihh49A616RjAr74GKNXwX+J3Vmg9bkN5KT2WK28Em87/M6HkCoU Cdw== X-Google-Smtp-Source: AGHT+IGaC6PuAhu3pWt6DipZ12u32jxx/tWme6oiVJjTtPaAPq0Tli46qIKCkEtg3rNyPGo2HA9JrDSEFng= X-Received: from surenb-desktop.mtv.corp.google.com ([2a00:79e0:2e3f:8:cad5:5dc6:1298:ec42]) (user=surenb job=sendgmr) by 2002:a05:690c:6608:b0:6de:19f:34d7 with SMTP id 00721157ae682-6ecb31b51f7mr2737b3.2.1731440820935; Tue, 12 Nov 2024 11:47:00 -0800 (PST) Date: Tue, 12 Nov 2024 11:46:35 -0800 In-Reply-To: <20241112194635.444146-1-surenb@google.com> Mime-Version: 1.0 References: <20241112194635.444146-1-surenb@google.com> X-Mailer: git-send-email 2.47.0.277.g8800431eea-goog Message-ID: <20241112194635.444146-6-surenb@google.com> Subject: [PATCH v2 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, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@android.com, surenb@google.com X-Rspam-User: X-Rspamd-Queue-Id: 299FDC0008 X-Rspamd-Server: rspam01 X-Stat-Signature: ghn1drwum375f5fd1g9mtb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znT6i0gd2VOnqItJNejy2jemcPInDDmpigezTiXOiF66bVsH3tEssvPF/0rIfIocH/RfQTMoXOWSG0sMATtXx+fN7PHAYKMp3mWXJqrH+9sAphtJWXQOPxDljChvrZy8yHsuKpT00YM9I6BxBn68w/gegid99RmuI3U/GjggVqvo0dhYhCzEY2rJlqW7CuUOmf8kD8hjyC8VjZq1m1B/efcx8D7krHdAmAwjMZ2q6LrSxLfkP62ngGV7ZHFQy6Xc4kBPZp0F6N5bVtaNMqbj48RjV4WqQf0cbWyizsMB9WlSUmnA2RUflk4b0xSQtIUjDqNI5Hb2GNDj3mHjOjRsjk9yBGms2LrXvPeQB7xyKPvP1LKcQNEH7JUUhGXpgZGp5rAW/VikwIbwSZK2TEETsJycGzSJatAjM7QOaA2JdkEb8TG2/mBpRArP/Dl8VM8IaYY5TNc7Rbf9AsGozwWwOTrBVovo/KsB/y6OjkXb5G+8Msv+bAqiVC8CELlfGABDKd3D1b9RuIa+gRpAiNM+N/ybIFxtH4SMAMAzUJlzlw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000085, 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 ed74685ffbf2..c8935509173e 100644 --- a/Documentation/mm/process_addrs.rst +++ b/Documentation/mm/process_addrs.rst @@ -675,7 +675,11 @@ 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`. @@ -739,7 +743,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 @@ -749,7 +753,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.