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=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 6A9FDC2D0BF for ; Tue, 10 Dec 2019 15:26:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1D316206D5 for ; Tue, 10 Dec 2019 15:26:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1D316206D5 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A78E26B2CFA; Tue, 10 Dec 2019 10:26:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A2A556B2CFB; Tue, 10 Dec 2019 10:26:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 93EDF6B2CFC; Tue, 10 Dec 2019 10:26:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0170.hostedemail.com [216.40.44.170]) by kanga.kvack.org (Postfix) with ESMTP id 781D36B2CFA for ; Tue, 10 Dec 2019 10:26:44 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 352AA5010 for ; Tue, 10 Dec 2019 15:26:44 +0000 (UTC) X-FDA: 76249609128.11.spy14_57d8cf0c2eb01 X-HE-Tag: spy14_57d8cf0c2eb01 X-Filterd-Recvd-Size: 2397 Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Tue, 10 Dec 2019 15:26:43 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A41ADACF1; Tue, 10 Dec 2019 15:26:41 +0000 (UTC) Subject: Re: Splitting the mmap_sem To: Jerome Glisse , Matthew Wilcox Cc: linux-mm@kvack.org, Laurent Dufour , David Rientjes , Hugh Dickins , Michel Lespinasse , Davidlohr Bueso References: <20191203222147.GV20752@bombadil.infradead.org> <20191205172150.GD5819@redhat.com> From: Vlastimil Babka Message-ID: <16178c54-2884-667b-7ae9-814ff4eeed1b@suse.cz> Date: Tue, 10 Dec 2019 16:26:40 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <20191205172150.GD5819@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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 12/5/19 6:21 PM, Jerome Glisse wrote: >> >> So calling mmap() looks like this: >> >> 1 allocate a new VMA >> 2 update pointer(s) in maple tree >> 3 sleep until old VMAs have a zero refcount >> 4 synchronize_rcu() >> 5 free old VMAs >> 6 flush caches for affected range >> 7 return to userspace >> >> While one thread is calling mmap(MAP_FIXED), two other threads which are >> accessing the same address may see different data from each other and >> have different page translations in their respective CPU caches until >> the thread calling mmap() returns. I believe this is OK, but would >> greatly appreciate hearing from people who know better. > > I do not believe this is OK, i believe this is wrong (not even considering > possible hardware issues that can arise from such aliasing). But is it true that the races can happen in the above such that multiple CPU's have different translations? I think it's impossible to tell from above - there are no details about when and which pte modifications happen, where ptl lock is taken... perhaps after filling those details, we could be able to see that there's no race.