From patchwork Tue Dec 10 00:06:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Malat X-Patchwork-Id: 13900514 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 1C7DDE7717D for ; Tue, 10 Dec 2024 00:06:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E9B4F6B00C8; Mon, 9 Dec 2024 19:06:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E4B196B00CA; Mon, 9 Dec 2024 19:06:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D13846B00CB; Mon, 9 Dec 2024 19:06:16 -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 AA6BB6B00C8 for ; Mon, 9 Dec 2024 19:06:16 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 2E5FF1A0B9A for ; Tue, 10 Dec 2024 00:06:16 +0000 (UTC) X-FDA: 82877106144.19.4359DA7 Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) by imf05.hostedemail.com (Postfix) with ESMTP id A0B1E100009 for ; Tue, 10 Dec 2024 00:05:33 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=malat-biz.20230601.gappssmtp.com header.s=20230601 header.b=LLUVJrfR; spf=none (imf05.hostedemail.com: domain of oss@malat.biz has no SPF policy when checking 209.85.218.50) smtp.mailfrom=oss@malat.biz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733789160; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=41hc5tS4HZmxnByPa4dK5S63watiBp+zc1UGXD2a7wg=; b=G3sM87M3HxynqrgscPE5cNHrmDcgRoDC5d3AeNB8TAAEMuKIfeILCCaZsxlBDxOgftSijw apyyH3JPV5rA4qhw1oGVJaqjZ6GQbHagN/hXhrQsp7zktmzrOw9z9LoJL2MOW0gAU33VD0 OQmo7qla/Lru+7TlApullqiCIuLIfZA= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=malat-biz.20230601.gappssmtp.com header.s=20230601 header.b=LLUVJrfR; spf=none (imf05.hostedemail.com: domain of oss@malat.biz has no SPF policy when checking 209.85.218.50) smtp.mailfrom=oss@malat.biz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733789160; a=rsa-sha256; cv=none; b=RvfxScaSoyRdyXuxhAu9nTMv04qZM79b40j+0TUjapnYGgOkm6ZD/FHar0abSK3i5tI5fs I0BNYpfghL//6B8VsDEdTtEATgjJbkmzWP3FL94JP5yigaZ2u+eJGZEUc688jnwZf0ihxY pvtR4/H95QCXzwWVmjAikOBLtr867OU= Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-aa5f1909d6fso944185766b.3 for ; Mon, 09 Dec 2024 16:06:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=malat-biz.20230601.gappssmtp.com; s=20230601; t=1733789172; x=1734393972; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=41hc5tS4HZmxnByPa4dK5S63watiBp+zc1UGXD2a7wg=; b=LLUVJrfRIEnxploh1+7JeFlnvxx6221vEfr94uTKf24Jh7JO4iNalVea/OtisMFjlh qr+YM5XT+LcW94cl9byU+vYHw4Vj9uZjK1Fhh5ER6u3jjoz7hwOojcncJ2+3npJhe1Ga YS+Ck1dQ7H7SapbSPLPPifGi5/EF5eE40/mkHfEl5llTKLdd9X8pgwkC6Py2XauInVv+ 81VOg76UDfmcFsLLqN8m2YKBP2VJrsR9EIuJCNRDwMrlNfKMw+0S15wH3iSh6XaTELik UAW4PUh/FxqCk0EhDJrGoisfs0jQDs/Z3OhNODKnRJ8enByIrvFZhYJz0WU0H8yS4MoJ grCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733789172; x=1734393972; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=41hc5tS4HZmxnByPa4dK5S63watiBp+zc1UGXD2a7wg=; b=aT2U9betB4EabxBVX7p8lo0fs9mvOQz6jxPv7mtxtcffXRLHdL6Ac0/kp/qUpQnsmH GmPt1VWyJcU7Mj8PJok74/CFXvwVPw/rCe/Lh+qUvMfCUCPVIIyyykElJXoPt4OB4odV lDskSrViunUSQjpZXHiIYop/pXjZoo8H+HE9kPZzQcnGBm0iGwYyttAcfJVOLe+SE06U 9frpNB2iQgPGHetp3ouB34YH0fwoKS1sP+8ZFtXW6Z5oB7el+xqJuWobyZjax4bFMZOE /m7yRn0/GwRNv2b5UwilQ98RqT9jnh7vmMgyAavgiXzINzHJKKkMuvrRZnqs2zHL34Oq NGsA== X-Gm-Message-State: AOJu0YxrVmJHbBJQ77ZEoYLQ4sAeLDWduHdCIyXKAmlJg1gCukRsTs4q sCsk3oLqFK/A3pL+IRlIQrQYGJ6HlKtJdwOXWs6a8pEBrUNHNOgQmor6boazKFpehwAsXXdseMj a5eNK X-Gm-Gg: ASbGncucpEMqXesIaXhMR1nbn6fruZ6kUY8FlmvhqZSX6VhEIzmFmJvbOm9oNCH3piW yP428lcOeD50XyMnKsEGZKOdRjvHxgvedKa1E29xZrgcPzmhSPBnGkGx6yMt54vZvwCq5K5ez0P Z5bUSa0iN8ZB1iRSjRGQg/59ObhZNngxT2d6uSRM8xC1TZOUcaX1sevHduVS9HGwvI3H4ZipBdz R+N69x0f0eTIEooV1NLWfHk1L4b4mUKJ1f2CWa5JpwqLgSYp/N3XBXPog== X-Google-Smtp-Source: AGHT+IGbSuTwklXUl5768RBICTxahHTO7eYGLhWxugXi5DMTHD0I480uhynpfT40f6lqzF9gYtkxvw== X-Received: by 2002:a17:906:1bb2:b0:aa5:4982:abc8 with SMTP id a640c23a62f3a-aa69cd5376emr224116466b.22.1733789172144; Mon, 09 Dec 2024 16:06:12 -0800 (PST) Received: from localhost.localdomain ([193.86.118.65]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-aa6964b7c64sm139083866b.95.2024.12.09.16.06.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2024 16:06:11 -0800 (PST) From: Petr Malat To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, Petr Malat Subject: [PATCH] mm: Add RCU annotation to pte_offset_map(_lock) Date: Tue, 10 Dec 2024 01:06:04 +0100 Message-Id: <20241210000604.700710-1-oss@malat.biz> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Stat-Signature: 4i7khexdahnr8trwqjshb7tc35zc134a X-Rspamd-Queue-Id: A0B1E100009 X-Rspam-User: X-HE-Tag: 1733789133-858732 X-HE-Meta: U2FsdGVkX18k88ixwlrwljON2/CZkWS0/zvnx82s9Ub9SUfEMH3rzIi3WkOswgLRHc3g34FI59V4AQySOWJd0GEaLlGh4ngJU0k/lKgS7etRCrhZFO7psiWOOjG4dEYJLPVwkceeiXMejaUTkMjOUs51Tl0FlBp4bUsV5laOrHP/DcemINa2DW9MzgZSW4w2mhZoeevTDvomOGEG9QlRgXYgMtk6S8sNof/WUGE1c9rOqgEYZhUsl3WzJRN8bCIdchMjfzIP3ML1FXzKtWmkpGD7d7ocaCrNq3Qgpz0q5eQ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= X-Bogosity: Ham, tests=bogofilter, spamicity=0.073102, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: RCU lock is taken by ___pte_offset_map() unless it returns NULL. Add this information to its inline callers to avoid sparse warning about context imbalance in pte_unmap(). Signed-of-by: Petr Malat --- include/linux/mm.h | 13 +++++++++++-- mm/pgtable-generic.c | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index c39c4945946c..3a6ee6a05aa0 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3010,7 +3010,15 @@ static inline void pagetable_pte_dtor(struct ptdesc *ptdesc) lruvec_stat_sub_folio(folio, NR_PAGETABLE); } -pte_t *__pte_offset_map(pmd_t *pmd, unsigned long addr, pmd_t *pmdvalp); +pte_t *___pte_offset_map(pmd_t *pmd, unsigned long addr, pmd_t *pmdvalp); +static inline pte_t *__pte_offset_map(pmd_t *pmd, unsigned long addr, + pmd_t *pmdvalp) +{ + pte_t *pte; + + __cond_lock(RCU, pte = ___pte_offset_map(pmd, addr, pmdvalp)); + return pte; +} static inline pte_t *pte_offset_map(pmd_t *pmd, unsigned long addr) { return __pte_offset_map(pmd, addr, NULL); @@ -3023,7 +3031,8 @@ static inline pte_t *pte_offset_map_lock(struct mm_struct *mm, pmd_t *pmd, { pte_t *pte; - __cond_lock(*ptlp, pte = __pte_offset_map_lock(mm, pmd, addr, ptlp)); + __cond_lock(RCU, __cond_lock(*ptlp, + pte = __pte_offset_map_lock(mm, pmd, addr, ptlp))); return pte; } diff --git a/mm/pgtable-generic.c b/mm/pgtable-generic.c index 5297dcc38c37..5a882f2b10f9 100644 --- a/mm/pgtable-generic.c +++ b/mm/pgtable-generic.c @@ -279,7 +279,7 @@ static unsigned long pmdp_get_lockless_start(void) { return 0; } static void pmdp_get_lockless_end(unsigned long irqflags) { } #endif -pte_t *__pte_offset_map(pmd_t *pmd, unsigned long addr, pmd_t *pmdvalp) +pte_t *___pte_offset_map(pmd_t *pmd, unsigned long addr, pmd_t *pmdvalp) { unsigned long irqflags; pmd_t pmdval;