From patchwork Tue Jun 20 07:40:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13285272 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 BC136EB64D8 for ; Tue, 20 Jun 2023 07:40:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 55A298D0002; Tue, 20 Jun 2023 03:40:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 509D28D0001; Tue, 20 Jun 2023 03:40:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3D0D58D0002; Tue, 20 Jun 2023 03:40:16 -0400 (EDT) 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 29DA88D0001 for ; Tue, 20 Jun 2023 03:40:16 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id F1C771C83EC for ; Tue, 20 Jun 2023 07:40:15 +0000 (UTC) X-FDA: 80922327990.26.075CA41 Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173]) by imf29.hostedemail.com (Postfix) with ESMTP id 23C6E120012 for ; Tue, 20 Jun 2023 07:40:13 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b="0LMD2/Bp"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf29.hostedemail.com: domain of hughd@google.com designates 209.85.128.173 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687246814; 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=2Xgtva00uaRjPQjQYWCbyYlUVerqtzlz4H3/JM5nRsA=; b=w+puEa2BnVkW/BzDxfDCIfFqreC1A1h8oWKIfVwoIrq8gNaee6AappgWNQFoADYcXv6nup ZyFh2o4hrsxx/pPwKn70yJQqWkETCusAcbhokTd6be5fF86qBsv8NpOUJyMH8mf9Fbj605 2Zhy4RC4qnKXJYqdSLFeaaNDV8AItxs= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b="0LMD2/Bp"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf29.hostedemail.com: domain of hughd@google.com designates 209.85.128.173 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687246814; a=rsa-sha256; cv=none; b=ubx7yOeaCqVCqXGN7aaqYPE4L6aJCcfmpwlBebqkqDtTynB80xBdlzt8LRLq3rLkXQaslS ETmA+wg+1GifaENEwWcFJw5IUgfT/cie4XFFR5ocDYmghVsaBHuUf7oPCXnY68a5CWZfT0 X9avVteeLJPIPvnW3cjCR7sZJxn07GA= Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-5701e8f2b79so49562297b3.0 for ; Tue, 20 Jun 2023 00:40:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687246813; x=1689838813; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=2Xgtva00uaRjPQjQYWCbyYlUVerqtzlz4H3/JM5nRsA=; b=0LMD2/Bp9LkZIBYgPbN4jKWx5l3xqsV5p+9EAezDq6xR/SWmyYTEAe1FdDy1xbMmRb H8PBsbrNU4fYI4mKZfhyMwB/CU4nG5b31JuXXrIAyWt0sajI0olzTibXN+ktWNYF0oep x0ccngPNp6kQepRw/XRcKOWVrIwm+WEupexqrFO6FFWjiu1SlHy8yMCBdGb2CGeJXPQe rQ6klP2gqbiJAoxVWslA7bD8MQXYp6OVctc8Pm9x7E9rZqqXloCfaCSI/DExJxOsqSJT 4d6fjthovhopd44fEKacEstPh46MmIG/u5ZNkKED0IyMDYNloqJ4rKSwMXR8oHsnZsZm /6EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687246813; x=1689838813; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2Xgtva00uaRjPQjQYWCbyYlUVerqtzlz4H3/JM5nRsA=; b=bkA24V+KS+/sW/gt2eS+c4sEOs3D1Un7xHak3cZwO+2A65lqwaSe+r/prJO8zt6eXu w2lL4utpedGosdMcNep+ONCgTyV65UtDHLuBfQg2YqAjmzGGAY5dGYXnhixSH5K8FI/m HAdEJdLkEs0SK+CxJKeFH4LEmK06zRCNvF+zGW0/srg/1ja3TNZx+FcWaJTAR8exuYo5 /UXz7Q6m6SQx5PbDaIVPJwF8JN3TjiDCEEwLZvdcrT9NptbTyjW2k0OoPJc7DFc05nYQ FlSJCi6fl3eu9L9RLhdli0gEKHmH0xQTKT2BLIgVgrVxWzIxfazOI4aCDt0rvpAm2Zrv 6eQg== X-Gm-Message-State: AC+VfDzZp9qanDifULUbPfCq5S3fihXhflT/5TkTyWnRz4YC0I6+ZXto RJDq+WiQVKrGiodczaJGK361fg== X-Google-Smtp-Source: ACHHUZ75OBuUzMptMwBPGDkg2ahPnjw/MJzrATJW6OVlCqaB4pyoJIMCLPp7Z4SL32qkhEKJol5B6w== X-Received: by 2002:a81:75d6:0:b0:56d:b98:cc16 with SMTP id q205-20020a8175d6000000b0056d0b98cc16mr13330173ywc.45.1687246813120; Tue, 20 Jun 2023 00:40:13 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id x8-20020a817c08000000b005623ae13106sm368166ywc.100.2023.06.20.00.40.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 00:40:12 -0700 (PDT) Date: Tue, 20 Jun 2023 00:40:00 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Gerald Shaefer , Vasily Gorbik , Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Yang Shi , Mel Gorman , Peter Xu , Peter Zijlstra , Will Deacon , Yu Zhao , Alistair Popple , Ralph Campbell , Ira Weiny , Steven Price , SeongJae Park , Lorenzo Stoakes , Huang Ying , Naoya Horiguchi , Christophe Leroy , Zack Rusin , Jason Gunthorpe , Axel Rasmussen , Anshuman Khandual , Pasha Tatashin , Miaohe Lin , Minchan Kim , Christoph Hellwig , Song Liu , Thomas Hellstrom , Russell King , "David S. Miller" , Michael Ellerman , "Aneesh Kumar K.V" , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , Jann Horn , Vishal Moola , Vlastimil Babka , linux-arm-kernel@lists.infradead.org, sparclinux@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 01/12] mm/pgtable: add rcu_read_lock() and rcu_read_unlock()s In-Reply-To: <54cb04f-3762-987f-8294-91dafd8ebfb0@google.com> Message-ID: <53514a65-9053-1e8a-c76a-c158f8965@google.com> References: <54cb04f-3762-987f-8294-91dafd8ebfb0@google.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 23C6E120012 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: bm1rz6re5e5aurwyd3g7amsuh7tu3p6u X-HE-Tag: 1687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FGH1992VGfbVR4b+3la6kAUiTZULdmC5rUgx1OEBwbyaT5VpbioUW+OqcS3iZ5lWnLIX6K9AShinykJoNoh4Fbz6Uw1uu/LDKZdbeB3RdteWbBOL5s3ZHduHMMIf2I+VXcH9ayPaxMdpcqqkRy9DZM9QvfULnGivhnR56fwwBs72U/jdf0wLMTgk6JNmz8xsXA3DKL5zQDkEbynUdLokHFKw5eQrSvh+B9VJP6Wat6mK6bfQXeoNGmZzhmOoKAacdDQ+40EJlMv22HDbCZ/JDCfEPS6sNqypNpUB6Pd12KG5akyIwY69OZ/otX4oac+AjEbcy5BvMEm1NuuGFYggH8vsOok2G2oOKRpofPaFWC++Rih5dbscNxpAOq8UO42416T5M/r7omlpyqKu7JFtlLaDzj63vWjEiuPxm6E4EkpL1eg6szf8xw0FzC+VK2Gmer76Nd 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: Before putting them to use (several commits later), add rcu_read_lock() to pte_offset_map(), and rcu_read_unlock() to pte_unmap(). Make this a separate commit, since it risks exposing imbalances: prior commits have fixed all the known imbalances, but we may find some have been missed. Signed-off-by: Hugh Dickins --- include/linux/pgtable.h | 4 ++-- mm/pgtable-generic.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index a1326e61d7ee..8b0fc7fdc46f 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -99,7 +99,7 @@ static inline pte_t *pte_offset_kernel(pmd_t *pmd, unsigned long address) ((pte_t *)kmap_local_page(pmd_page(*(pmd))) + pte_index((address))) #define pte_unmap(pte) do { \ kunmap_local((pte)); \ - /* rcu_read_unlock() to be added later */ \ + rcu_read_unlock(); \ } while (0) #else static inline pte_t *__pte_map(pmd_t *pmd, unsigned long address) @@ -108,7 +108,7 @@ static inline pte_t *__pte_map(pmd_t *pmd, unsigned long address) } static inline void pte_unmap(pte_t *pte) { - /* rcu_read_unlock() to be added later */ + rcu_read_unlock(); } #endif diff --git a/mm/pgtable-generic.c b/mm/pgtable-generic.c index c7ab18a5fb77..674671835631 100644 --- a/mm/pgtable-generic.c +++ b/mm/pgtable-generic.c @@ -236,7 +236,7 @@ pte_t *__pte_offset_map(pmd_t *pmd, unsigned long addr, pmd_t *pmdvalp) { pmd_t pmdval; - /* rcu_read_lock() to be added later */ + rcu_read_lock(); pmdval = pmdp_get_lockless(pmd); if (pmdvalp) *pmdvalp = pmdval; @@ -250,7 +250,7 @@ pte_t *__pte_offset_map(pmd_t *pmd, unsigned long addr, pmd_t *pmdvalp) } return __pte_map(&pmdval, addr); nomap: - /* rcu_read_unlock() to be added later */ + rcu_read_unlock(); return NULL; }