From patchwork Fri Apr 26 14:45:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13644922 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 4CF77C04FFE for ; Fri, 26 Apr 2024 14:45:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BBC596B009C; Fri, 26 Apr 2024 10:45:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B6CAE6B009D; Fri, 26 Apr 2024 10:45:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A36876B009E; Fri, 26 Apr 2024 10:45:24 -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 7FF5C6B009C for ; Fri, 26 Apr 2024 10:45:24 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 32824120970 for ; Fri, 26 Apr 2024 14:45:24 +0000 (UTC) X-FDA: 82051956168.13.6D0A480 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf09.hostedemail.com (Postfix) with ESMTP id B535B14001C for ; Fri, 26 Apr 2024 14:45:22 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=RyyF7zdw; spf=none (imf09.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714142722; 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:in-reply-to:references:references:dkim-signature; bh=WfdYXkl3VmeSNFl8CeYkQkRSot5hSq2wAYXQXVO2q28=; b=O6lj6WBflZGSPkYaYJrPWXJbC4kkHfBri75RsXshQsSWKNYUMKLhRSJMSO64JtEJ/uss3Q J6AM8M9OHrXGmMrEkV01kun7u+fJ7hZCyD0fEt22zss+NUZ5YBxVDr4Tk8/kGWZJpbGO1m BfwwYWrPB4mj+qXahKP3gUm6OhYOCGg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714142722; a=rsa-sha256; cv=none; b=wtOfK2FQKS9LghzHLuc0ILrjvGtYOCaGeQ9yU7/wl5Gcj1iqZPt7oaQ2NDKINXgH0dz+3k mWasVvFfIGnBVvRwMZE6ZhytFQCdVG1OxqXH2LFdzm88eZSbORFyC8RBKfV785k8eFToG9 J6CvU66hsvtPLxnUIZR3F35IpdKbbsU= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=RyyF7zdw; spf=none (imf09.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=WfdYXkl3VmeSNFl8CeYkQkRSot5hSq2wAYXQXVO2q28=; b=RyyF7zdwWk9nDa97+eyubbdcGh /w28kPOhTqJkoKMGtwC13r+m64VxEWsAi8TiLuVDtxQS2gSkWj39hwiAkuY0x1wxCTh45vs8B9FTn sD30juuwToyG9roIfdS9dV8KS47Mv8h4eldpZC0MIv0XWa+zSjDgFtCb0N0CH3m5CjLA6W/+Ermsv vCRso3N6rfSCVH2Va/m/EBte6Z/aKqUBvmbYVHj936Hjj3wYAuJc77vTg2oam8yNVg16gv4t17js7 4OfTtjSbHss3Gw2WztfJrsDnkdMN5ObcpwwKZPNiMEVbnV6Pcu+aigMm//iKd9fRHCaGg13oL7Du/ /4x72pfw==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1s0Mp2-00000005Pl0-0bLw; Fri, 26 Apr 2024 14:45:08 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan , Peter Xu Subject: [PATCH 1/4] mm: Assert the mmap_lock is held in __anon_vma_prepare() Date: Fri, 26 Apr 2024 15:45:00 +0100 Message-ID: <20240426144506.1290619-2-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240426144506.1290619-1-willy@infradead.org> References: <20240426144506.1290619-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: B535B14001C X-Stat-Signature: in4dudizmhq56w1qqx7nhst47ke6cxci X-Rspam-User: X-HE-Tag: 1714142722-632503 X-HE-Meta: U2FsdGVkX1/4RuKLQXPuiSvUII3+swJDxT8kDH1CxJJau+ltmJ7ZUCRrgtENYFvtaA2uK4vOGLUjqNdzYq77sbzd2qmQEKzUlfPKu7Zj8zvKg1Gm3kQ7r7VtZ489cdqqF4C7lnAgC2WH9hjZ/MtrZT/BYC2S0LM5C0VKKI7jjdXUQApL8ZzvHjGaYR5Fro6McepPSrwsa7tHd6CbMnJRyoDHRFcHS+Xh9ZdlaoBEuVEjcJsZ4ehTaJcmOeINymXrxJSt6FdqmMmIu9uUxtBAUko3CZHYtAZ1VgKYgH0Nf6PxJyV0B41nTHKZLj1k2G2/8Iugq1PacuM7Sa0TJOR8F/qliVnWSrqfpv5je2VCnsLscxN9OsHw42GeIfMuO298Zkj9ANo+iYCyzIVA00sIXnGJMJl/c95B4cps7BKa+wtRoT5T5xk8FP0wsLrzyc9KLSRrUErhb19dPDSSnHuZmlWGA7POUaU545SRkr5r2rEg9Tq38JpOWnSlXGITkxiZAdev1YShPuWweHyQevF2mHl4KJn4dXcFXJrxW69GLe1Xb2qu9avaQzwm9zehTmnTNwfup3Vr1ZEkw0go+lLvVySsQJcnMAsKbOO7fzcyIFNphtJ/7pthgxMsXoJghwWfjk08MFgxe5M1udWo5fYxJF3sDEIkdlPuDY5R+NC4+6WtmxR6z8fxVAfD4+3s+JGU5kQ3N3xoKl3cO6/x0Rl9v5mT2jA+hNPYodNIeFaZ8cgB+to1oHFOzPKAE1c4iko59FZzDVuev278b4cXK8eGtQd62DdnfQ38OwmJBnbRzosZ3Za2J0j87zlR4A5yP/h7X5iev++AJ0XxAeUlI3gj0OWkOs+OpUgTVeHyO9+KkIT64ufKKS1GZh6GCp56SyqhFrX735Q5V6HS20kJI5FyyZyQ00NeGh9R 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: Convert the comment into an assertion. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Suren Baghdasaryan Reviewed-by: David Hildenbrand --- mm/rmap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mm/rmap.c b/mm/rmap.c index 2608c40dffad..619d4d65d99b 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -182,8 +182,6 @@ static void anon_vma_chain_link(struct vm_area_struct *vma, * for the new allocation. At the same time, we do not want * to do any locking for the common case of already having * an anon_vma. - * - * This must be called with the mmap_lock held for reading. */ int __anon_vma_prepare(struct vm_area_struct *vma) { @@ -191,6 +189,7 @@ int __anon_vma_prepare(struct vm_area_struct *vma) struct anon_vma *anon_vma, *allocated; struct anon_vma_chain *avc; + mmap_assert_locked(mm); might_sleep(); avc = anon_vma_chain_alloc(GFP_KERNEL);