Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1099032pxy; Sun, 1 Aug 2021 12:34:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxG/dCX8Q16ZIotJFj8Mibcwbus1aTh9WdyBVI0xAC/HGetYBNOANohp3yzCnk7UTTME/sw X-Received: by 2002:a92:dad0:: with SMTP id o16mr2424969ilq.65.1627846469136; Sun, 01 Aug 2021 12:34:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627846469; cv=none; d=google.com; s=arc-20160816; b=E+Zdo4HBZhU8FELYNKbONQUJkQI54ds916Ww2qkkCmvwMqAvPt/aJRckFSf0jOW4oR FX3B1a5HQ70xDUnaJXs/mBLmGh9IqoptvsBYJqjYh/bDzKVhvB2HIo1BsoMDj3y9NmxY IKtYa8dSvO8/MrM7DbEE4dQDk/F1bTekwTe1cKRV5abP4cDpgq4ZNaiOZx358Kru1zZO yaUgHAI5OEBOvT459UKENWMQsI7TX3wD3hRJiefCaWfBoGLOi3uwhkN53mHNng6GmxUK d6xioWnZjUIXl45NVFlCxw9JcgDSK3Sr/bAmIYwYgwfIHmYfA4QF7LQI8rE3ywaAWbSH dSUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=p650LxmCfUaeJtD+3MbfrWYm925uWRmSFG+o+2LUSzs=; b=ehD5tIv5Ys1WY/zSZSRYiIe3IC682QPfEjij6A7qSOV6tTGWBL3TMGiHIBkI6L7mvm uwAm3hsuX5IK15RokEen7NuaDriP2Y87JYSih+zwU9sS+Kghh7at1HRzmxWi+DZLyzrR zrRZca+HKoeFgMlahooPz1O5YupxsUsCF038mhVF8EYUMoO/ILjyaSsk6rX6n77OTWKh TgcUqEvFGTe/MnJH6U+R3akIVW3XCVeYGVPDe+W64P7OFWFoA8J2yBq1hnx/VdqEUfKa Ms0o6d4PCB6HEC2TAXBQcqgSGFlrgKq6SD8IF0J/Cpmw+W1y64lfktEh165bfTr85DsI LQmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=CNIq9NY4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w5si10426560ilu.14.2021.08.01.12.34.17; Sun, 01 Aug 2021 12:34:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=CNIq9NY4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229915AbhHATdq (ORCPT + 99 others); Sun, 1 Aug 2021 15:33:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:54998 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229529AbhHATdp (ORCPT ); Sun, 1 Aug 2021 15:33:45 -0400 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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?