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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CBD80C433F5 for ; Tue, 3 May 2022 23:45:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C8326B0071; Tue, 3 May 2022 19:45:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 376E56B0073; Tue, 3 May 2022 19:45:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 240256B0074; Tue, 3 May 2022 19:45:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 140546B0071 for ; Tue, 3 May 2022 19:45:17 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id DA48F29BE0 for ; Tue, 3 May 2022 23:45:16 +0000 (UTC) X-FDA: 79426065432.29.33F1E90 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf16.hostedemail.com (Postfix) with ESMTP id 30FF8180089 for ; Tue, 3 May 2022 23:45:10 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id BC5FF1F38D; Tue, 3 May 2022 23:45:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651621514; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=l/BREnaAXdAKe0vrIPYORr32m/YY/Iq3Nvp33ZXNrj8=; b=H7CUqco8iD8mefJQVMQjSB1rkfaBzCu+oUuGkvz1EFL5I82jqSkjOOctlUAFI8H7kyevBR F7+pEbGr9A+0+NlVlCjkY40XwiN2d2JgLtnVWVwUfzJpg+crySzvV6iJxQDg7eFmYjFY0I myprnhN8wxtnsiIxY8icA8om8z5ZqVM= Received: from suse.cz (unknown [10.100.201.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id F02352C141; Tue, 3 May 2022 23:45:13 +0000 (UTC) Date: Wed, 4 May 2022 01:45:11 +0200 From: Michal Hocko To: Suren Baghdasaryan Cc: Matthew Wilcox , "Paul E. McKenney" , "Liam R. Howlett" , Michel Lespinasse , Johannes Weiner , linux-mm , LKML , David Hildenbrand , Davidlohr Bueso Subject: Re: Memory allocation on speculative fastpaths Message-ID: References: <20220503155913.GA1187610@paulmck-ThinkPad-P17-Gen-1> <20220503163905.GM1790663@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 30FF8180089 X-Stat-Signature: ynfo9d1q5easwan7pdg6tsbaynh7qmjr Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=H7CUqco8; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf16.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1651621510-22854 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 Tue 03-05-22 16:15:46, Suren Baghdasaryan wrote: > On Tue, May 3, 2022 at 11:28 AM Matthew Wilcox wrote: [...] > > rcu_read_lock(); > > vma = vma_lookup(); > > if (down_read_trylock(&vma->sem)) { > > rcu_read_unlock(); > > } else { > > rcu_read_unlock(); > > mmap_read_lock(mm); > > vma = vma_lookup(); > > down_read(&vma->sem); > > } > > > > ... and we then execute the page table allocation under the protection of > > the vma->sem. > > > > At least, that's what I think we agreed to yesterday. > > Honestly, I don't remember discussing vma->sem at all. This is the rangelocking approach that is effectivelly per-VMA. So that should help with the most simplistic case where the mmap contention is not on the same VMAs which should be the most common case (e.g. faulting from several threads while there is mmap happening in the background). There are cases where this could be too coarse of course and RCU would be a long term plan. The above seems easy enough and still probably good enough for most cases so a good first step. -- Michal Hocko SUSE Labs