Message ID | 20220829212531.3184856-18-surenb@google.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 8D969ECAAD4 for <linux-mm@archiver.kernel.org>; Mon, 29 Aug 2022 21:26:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 49A07940015; Mon, 29 Aug 2022 17:26:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 41B3C940008; Mon, 29 Aug 2022 17:26:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 26E9F940015; Mon, 29 Aug 2022 17:26:08 -0400 (EDT) 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 02F92940008 for <linux-mm@kvack.org>; Mon, 29 Aug 2022 17:26:08 -0400 (EDT) Received: from smtpin31.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id CB9CCAAA1B for <linux-mm@kvack.org>; Mon, 29 Aug 2022 21:26:07 +0000 (UTC) X-FDA: 79853913174.31.114DBF2 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) by imf14.hostedemail.com (Postfix) with ESMTP id 881A2100040 for <linux-mm@kvack.org>; Mon, 29 Aug 2022 21:26:07 +0000 (UTC) Received: by mail-pj1-f73.google.com with SMTP id a17-20020a17090abe1100b001fda49516e2so3659650pjs.2 for <linux-mm@kvack.org>; Mon, 29 Aug 2022 14:26:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc; bh=+ZeFgC+onLi5H2Gk/r+wfB2lUIAEpTgiMaISz2j8Yh8=; b=sfdQ+2NyYwxA7WE4W+U26tjnRsGpTwH+W4yCMsULIhDPYOMjHM3COZzPg/S6KTqrLL mCgPnd6W8rrgwvL37XiGeYHG8ArgrFQG0UGf2gLsolv/ME8hJmTyRg7Fg1LBPlsPaNI3 te4whtYEHF8c2GeRvQHa/rDrJjk62KSTUlVEPYqGvjKgQGKn8f4Dp8C4KiASRefP1Qh1 bQmVBjd8KI32N8+vGT1M5VRcf57cOjajmNaLyJUUpin1ccvlQLSGjkUAJOTaDxWOJrJ5 Pk3cN7LOZgsgUwKnowGjucplCuekHbu//K343iXFhb3F2AjszKhuURdvTUr7Fsy7vLjJ fKug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc; bh=+ZeFgC+onLi5H2Gk/r+wfB2lUIAEpTgiMaISz2j8Yh8=; b=2XJJBIbCjFH9CXpyHrb8Irbio6bX5aLp9OMPYlyOj+XAnY1Jjth+9cpMY15lR/p03M 46w9J5iYu9PSgPDYpb3UItAD9imvm706h8qws2wNhvI+9SmAd8NkX3slUAlPydnqNpXz cnLOzJIioiasvu5M44JhgBswy7Ij7mfWeoQ0PQMzljRzh+TgcH8Igw7ogKBvOCKOqgNU FrBE3ucQ0xMQEA5xww59l8jU0iXQvSrO6uHVrHHosqsVVZqwjOYB+MvDx9RxiGH+iQCP Tv25tx+JadUtvQDUlyXehYVpbpUTTh4eZHNRZ1oXu2NiEMiry0i0Ng4dIG1BgJj2nI1M pLMA== X-Gm-Message-State: ACgBeo0VPh7LydpLNQbxtYAuId5g1EcU+1379Y6WAIxuOcwTcjF9RxaZ ImJgpo3rKiYLQzI+sG3Qk6jptEgfhwE= X-Google-Smtp-Source: AA6agR60gqv1XJF9S7yhKpnItHkmCdUjQh3CpTVXyWE3xiDHKhNiTBjmbY9F8YGX1B9vpUO9txTmTcIisVc= X-Received: from surenb-spec.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e30]) (user=surenb job=sendgmr) by 2002:a17:902:6b88:b0:173:c1:691b with SMTP id p8-20020a1709026b8800b0017300c1691bmr18372367plk.18.1661808366708; Mon, 29 Aug 2022 14:26:06 -0700 (PDT) Date: Mon, 29 Aug 2022 21:25:20 +0000 In-Reply-To: <20220829212531.3184856-1-surenb@google.com> Mime-Version: 1.0 References: <20220829212531.3184856-1-surenb@google.com> X-Mailer: git-send-email 2.37.2.672.g94769d06f0-goog Message-ID: <20220829212531.3184856-18-surenb@google.com> Subject: [RFC PATCH 17/28] mm/mmap: prevent pagefault handler from racing with mmu_notifier registration From: Suren Baghdasaryan <surenb@google.com> To: akpm@linux-foundation.org Cc: michel@lespinasse.org, jglisse@google.com, mhocko@suse.com, vbabka@suse.cz, hannes@cmpxchg.org, mgorman@techsingularity.net, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, peterz@infradead.org, ldufour@linux.ibm.com, laurent.dufour@fr.ibm.com, paulmck@kernel.org, riel@surriel.com, luto@kernel.org, songliubraving@fb.com, peterx@redhat.com, david@redhat.com, dhowells@redhat.com, hughd@google.com, bigeasy@linutronix.de, kent.overstreet@linux.dev, rientjes@google.com, axelrasmussen@google.com, joelaf@google.com, minchan@google.com, surenb@google.com, kernel-team@android.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=sfdQ+2Ny; spf=pass (imf14.hostedemail.com: domain of 37i4NYwYKCJ8RTQDMAFNNFKD.BNLKHMTW-LLJU9BJ.NQF@flex--surenb.bounces.google.com designates 209.85.216.73 as permitted sender) smtp.mailfrom=37i4NYwYKCJ8RTQDMAFNNFKD.BNLKHMTW-LLJU9BJ.NQF@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661808367; a=rsa-sha256; cv=none; b=Jyt3AN2urC0w/EYjAiRHDBrC7ug5D2KVKwVUM/2olO/qrUQIWF4/ONC6m4cISOCkmrTUSp ZGDBVuhF9CIVn3gHhLovwBLFKDdpq0GqA+VdQVNNLaoiBmY/KTQOBF+ijkHb/YJb+JTlRi zNFLd1P/0bina8XDV0B9poeOqWGYpgk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661808367; 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=+ZeFgC+onLi5H2Gk/r+wfB2lUIAEpTgiMaISz2j8Yh8=; b=bzA58Enu9P3klH+pg3cej+KufkTTCK1PNcKGYJBAlDcVzuld0gBcV2dGVVmZXatw60YknI GE2mxssQog5A41eX5MLvaM0ueKsag9bvc0p9j2fpASbjDpMN+pbjsyImY5YDRqSgVFNsUd YtH2HlCndvhzQZA9xXTMWc6VVxxbRWQ= X-Rspamd-Queue-Id: 881A2100040 X-Rspam-User: Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=sfdQ+2Ny; spf=pass (imf14.hostedemail.com: domain of 37i4NYwYKCJ8RTQDMAFNNFKD.BNLKHMTW-LLJU9BJ.NQF@flex--surenb.bounces.google.com designates 209.85.216.73 as permitted sender) smtp.mailfrom=37i4NYwYKCJ8RTQDMAFNNFKD.BNLKHMTW-LLJU9BJ.NQF@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam02 X-Stat-Signature: 4tnx7uwmwm4jkdjtoduqsqzufmrm6r4x X-HE-Tag: 1661808367-152644 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> |
Series |
per-VMA locks proposal
|
expand
|
diff --git a/mm/mmap.c b/mm/mmap.c index b31cc97c2803..1edfcd384f5e 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -3538,6 +3538,7 @@ static void vm_lock_mapping(struct mm_struct *mm, struct address_space *mapping) * hugetlb mapping); * - all i_mmap_rwsem locks; * - all anon_vma->rwseml + * - all vmas marked locked * * We can take all locks within these types randomly because the VM code * doesn't nest them and we protected from parallel mm_take_all_locks() by @@ -3579,6 +3580,7 @@ int mm_take_all_locks(struct mm_struct *mm) if (vma->anon_vma) list_for_each_entry(avc, &vma->anon_vma_chain, same_vma) vm_lock_anon_vma(mm, avc->anon_vma); + vma_mark_locked(vma); } return 0; @@ -3636,6 +3638,7 @@ void mm_drop_all_locks(struct mm_struct *mm) mmap_assert_write_locked(mm); BUG_ON(!mutex_is_locked(&mm_all_locks_mutex)); + vma_mark_unlocked_all(mm); for (vma = mm->mmap; vma; vma = vma->vm_next) { if (vma->anon_vma) list_for_each_entry(avc, &vma->anon_vma_chain, same_vma)
Pagefault handlers might need to fire MMU notifications while a new notifier is being registered. Modify mm_take_all_locks to mark all VMAs as locked and prevent this race with fault handlers that would hold VMA locks. Signed-off-by: Suren Baghdasaryan <surenb@google.com> --- mm/mmap.c | 3 +++ 1 file changed, 3 insertions(+)