From mboxrd@z Thu Jan 1 00:00:00 1970 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 2E5D3CF9C71 for ; Tue, 24 Sep 2024 06:25:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9C7136B00A8; Tue, 24 Sep 2024 02:25:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 976956B00AA; Tue, 24 Sep 2024 02:25:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 865DD6B00AB; Tue, 24 Sep 2024 02:25:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 675436B00A8 for ; Tue, 24 Sep 2024 02:25:15 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 17C2B1217B0 for ; Tue, 24 Sep 2024 06:25:15 +0000 (UTC) X-FDA: 82598644590.13.8C7B18A Received: from out-185.mta0.migadu.com (out-185.mta0.migadu.com [91.218.175.185]) by imf03.hostedemail.com (Postfix) with ESMTP id 1D7AB20013 for ; Tue, 24 Sep 2024 06:25:12 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=vTZjTUVf; spf=pass (imf03.hostedemail.com: domain of muchun.song@linux.dev designates 91.218.175.185 as permitted sender) smtp.mailfrom=muchun.song@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727158994; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/aYhado5OwzZFYPAS8E74g3IrdHqPgkubeEg7xLGfQY=; b=IMHvr/EzljHclikfUe8zQNXg/OHVfrsftS60C7ubxwvVtAoH0JNWn00TZsBxrVMnTf4D2o 74zB9C3wIvqk31d5r7ZYCt/X/NH6UDqK8elKoppkCY0u0GP4//TSMcCG2khKb0QBGMtpfk AOJq6iooFXitv0gIkSGTnG+eJdo938o= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727158994; a=rsa-sha256; cv=none; b=ey41087MjMe4kVkrWtHhUhB3Auaui1Uajqg45aOZkvqz7zfIEuqzHRM2kFV/HAEl/UGg7J v6boc0N2VkTjzNeA6p6nVv+BlqnoG9FZb5hjl5pVzRbC/4Uy+Bbys1LYotncOtZAMS9v1n eOqcYLAb+U3atw8YY8vjUOcCQdBA7YE= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=vTZjTUVf; spf=pass (imf03.hostedemail.com: domain of muchun.song@linux.dev designates 91.218.175.185 as permitted sender) smtp.mailfrom=muchun.song@linux.dev; dmarc=pass (policy=none) header.from=linux.dev Content-Type: text/plain; charset=us-ascii DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1727159110; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/aYhado5OwzZFYPAS8E74g3IrdHqPgkubeEg7xLGfQY=; b=vTZjTUVfu5HZHc+3wl9pLaAy6KGDor9B0L2oxER/ntkzITpVy7bWliohhRheobOThq/tnF HL4sONWWsPMW0ncQWMe9LLqRPKyHktICgGU+zUczbRyzISml4fMsH0chtX9RyvIJ4B26wX MZMt2nLfnJDnEtbaottDuuXxiTsw1nk= Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3818.100.11.1.3\)) Subject: Re: [PATCH v4 01/13] mm: pgtable: introduce pte_offset_map_{ro|rw}_nolock() X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: <1a4fea06f8cada72553a8d8992a92e9c09f2c9d4.1727148662.git.zhengqi.arch@bytedance.com> Date: Tue, 24 Sep 2024 14:24:27 +0800 Cc: david@redhat.com, hughd@google.com, willy@infradead.org, vbabka@kernel.org, akpm@linux-foundation.org, rppt@kernel.org, vishal.moola@gmail.com, peterx@redhat.com, ryan.roberts@arm.com, christophe.leroy2@cs-soprasteria.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org Content-Transfer-Encoding: 7bit Message-Id: <4D6AAB88-6BA9-4F7E-9EEA-829640D1BDDF@linux.dev> References: <1a4fea06f8cada72553a8d8992a92e9c09f2c9d4.1727148662.git.zhengqi.arch@bytedance.com> To: Qi Zheng X-Migadu-Flow: FLOW_OUT X-Stat-Signature: fuu69j1xux87m4caf8ex53q97exiqn7o X-Rspamd-Queue-Id: 1D7AB20013 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1727159112-956627 X-HE-Meta: U2FsdGVkX1/yuL9l/m6I/ETPF8zDv5X8oYgt+iGlMuSgP6c2vlzTUAMSdD5U7vxGK0Q+dk6f5fKS0PBnP9pwCuAI3OIxdxMCbYNqsKle6SmAWAf/S8snexSUM8Pb60lkFGrlkoh15Xpho0zxD8QbLukJ0lia4gV8oxfskvNwKwOtiOmyilmzpQKeZ9lgYeNKdWWRCNFK8BsZvcrroa8AYEwGmFtX370BA2rkASODp62N9fE+S2PxTF002xWVVoSmfq3/hjOKmh+5DucHJWUDhdnST96A2LC/eT/lNG7yszoHE+j4FdfHTbp78/d02boTGx3qibI2bs8MzffgccQoS7GKl/BY9WzJtq517yPb9K/FSBnlFtbqqf0jwmUB/GPlKBH5l+ccjE2yzmB2JQCqSIDOZBjQ4G/3zOgh6hMDCi/X/eI3e/f4i6V5nO076DVXC2pASWderXdKuMiUlt+6JDNhzTf7tgihAxKEQDQyv0+kgABLFHBYxtdoTM/dQ0fFsbqU2CN0fy71udgYFFrWO5LgiG5DCWRkPWIWJ6bASSsLN55corbz4iqJEYldBk46h3Hm2rId9iQLUJVBh3LdvdBcnHf/YxlGaN5P9RCK28sq3mGUL2pMSswlvAnRM6J9P91Y63I3J2I2aH0VwhoA9qlUGcb6mw9tmFN2ETbz6G/HTyd9wBeVlVWYTQmedlw1bfEsrWKgAp58sR2319Xs3uwvJCbrtSDXmPBROvIWFqVeu1/dMUWNvFtJpMnMtuyTYAbRfq1x8vJsK8cyZkBIXiFEhpWHY1O+mUDkVu0ZmY9BLOEAegmNNDrNCcKD9jsScGmo7m2A4is3xUNyChCXSuf9ov3Qvr2/58CB0EAxQSYwSjuuDZ1LzcYjGT0ejYJtVJzQ8BQGlKK2VUlUmP6bt3wjMrYYss+rpV08XFD5K4RapdHIxBLYUDdZhq6Jq2K86x9GLfuBJofOgQdjotB RRlgcpvi E09taty6idf0wabINRJMluKnUhKUIlUIhNdlKr5NGkIWcBlH0r3OyPbDXlCP+GoDoUA4jYrH7+6DzPZPhs1/q2FRzhZFKe/VIegZKMzQjES2ThYOJX3R/QCj2VGfeDOlqdKp75w9Z1JgShF/w3LFf4FuoboDTD3ZdE8qtdn/Tsdx5Dti+HWMklgj3YcRgbkg9ftajetlBydenwoRE5ezYyNbRFffpiTPznbJyHzS7Xh0iHkTOPZ0yne9tBs/zENojjqEKd0Zr90FOCSIu8biX4wi5kB2BeSZUmhUpX31YArHN8eIuQzFJypomnhY6I1bxtv0YyxcX0nPqhx3+7PwGQ4ueZB3U3+/2/hho 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: > On Sep 24, 2024, at 14:09, Qi Zheng wrote: > > Currently, the usage of pte_offset_map_nolock() can be divided into the > following two cases: > > 1) After acquiring PTL, only read-only operations are performed on the PTE > page. In this case, the RCU lock in pte_offset_map_nolock() will ensure > that the PTE page will not be freed, and there is no need to worry > about whether the pmd entry is modified. > > 2) After acquiring PTL, the pte or pmd entries may be modified. At this > time, we need to ensure that the pmd entry has not been modified > concurrently. > > To more clearing distinguish between these two cases, this commit > introduces two new helper functions to replace pte_offset_map_nolock(). > For 1), just rename it to pte_offset_map_ro_nolock(). For 2), in addition > to changing the name to pte_offset_map_rw_nolock(), it also outputs the > pmdval when successful. It is applicable for may-write cases where any > modification operations to the page table may happen after the > corresponding spinlock is held afterwards. But the users should make sure > the page table is stable like checking pte_same() or checking pmd_same() > by using the output pmdval before performing the write operations. > > Note: "RO" / "RW" expresses the intended semantics, not that the *kmap* > will be read-only/read-write protected. > > Subsequent commits will convert pte_offset_map_nolock() into the above > two functions one by one, and finally completely delete it. > > Signed-off-by: Qi Zheng Reviewed-by: Muchun Song