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 X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0B60C4320A for ; Sun, 1 Aug 2021 19:33:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 61DDD60F36 for ; Sun, 1 Aug 2021 19:33:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 61DDD60F36 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 9C0AF6B0033; Sun, 1 Aug 2021 15:33:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 970098D0001; Sun, 1 Aug 2021 15:33:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 886756B005D; Sun, 1 Aug 2021 15:33:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0179.hostedemail.com [216.40.44.179]) by kanga.kvack.org (Postfix) with ESMTP id 6D61B6B0033 for ; Sun, 1 Aug 2021 15:33:39 -0400 (EDT) Received: from smtpin39.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 1A072181AEF1A for ; Sun, 1 Aug 2021 19:33:39 +0000 (UTC) X-FDA: 78427511358.39.AD54712 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf14.hostedemail.com (Postfix) with ESMTP id A7128600BF0A for ; Sun, 1 Aug 2021 19:33:38 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 932CB6024A; Sun, 1 Aug 2021 19:33:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1627846417; bh=ag97U05m+dlz24Ct0ed4Y5I6gEAxYpIm0JpcOvq/BwY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=CNIq9NY4c6JZNHKpZZ7SpHhq5+7iSGQzYwcZ+fA2m3Adxo6J5hC/GEQufdmrtdrOP Dosb4E5Gbp7lJoGLIRyxQ+uIs2f/oXsrKA7qcHpJejJFz7yGlDVLtYuhD9rejo9i8G iX5J/yyrc2FFaWAGKBeEcrvOpHLjqeHYAmdCCXO0= Date: Sun, 1 Aug 2021 12:33:35 -0700 From: Andrew Morton To: Luigi Rizzo Cc: linux-kernel@vger.kernel.org, David Rientjes , linux-mm@kvack.org Subject: Re: [PATCH] Add mmap_assert_locked() annotations to find_vma*() Message-Id: <20210801123335.6a7f8e1ee1e52ea64db80323@linux-foundation.org> In-Reply-To: <20210731175341.3458608-1-lrizzo@google.com> References: <20210731175341.3458608-1-lrizzo@google.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=CNIq9NY4; spf=pass (imf14.hostedemail.com: domain of akpm@linux-foundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: A7128600BF0A X-Stat-Signature: xwgeufy8aka4uxrrjtkj3z8xb9aocnmo X-HE-Tag: 1627846418-640167 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: On Sat, 31 Jul 2021 10:53:41 -0700 Luigi Rizzo wrote: > find_vma() and variants need protection when used. > This patch adds mmap_assert_lock() calls in the functions. > > To make sure the invariant is satisfied, we also need to add a > mmap_read_loc() around the get_user_pages_remote() call in > get_arg_page(). The lock is not strictly necessary because the mm > has been newly created, but the extra cost is limited because > the same mutex was also acquired shortly before in __bprm_mm_init(), > so it is hot and uncontended. > Well, it isn't cost-free. find_vma() is called a lot and a surprising number of systems apparently run with CONFIG_DEBUG_VM. Why do you think this cost is justified?