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=-4.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, 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 00628C4346E for ; Sun, 27 Sep 2020 18:45:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4E23421D95 for ; Sun, 27 Sep 2020 18:45:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="BqNVX6Og" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4E23421D95 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=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 69B836B005C; Sun, 27 Sep 2020 14:45:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 625238E0001; Sun, 27 Sep 2020 14:45:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4EC216B0068; Sun, 27 Sep 2020 14:45:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0112.hostedemail.com [216.40.44.112]) by kanga.kvack.org (Postfix) with ESMTP id 392896B005C for ; Sun, 27 Sep 2020 14:45:51 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id DDE128249980 for ; Sun, 27 Sep 2020 18:45:50 +0000 (UTC) X-FDA: 77309720460.06.sleep51_30060e92717b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id BE59F1004DB23 for ; Sun, 27 Sep 2020 18:45:50 +0000 (UTC) X-HE-Tag: sleep51_30060e92717b X-Filterd-Recvd-Size: 5512 Received: from mail-lf1-f65.google.com (mail-lf1-f65.google.com [209.85.167.65]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Sun, 27 Sep 2020 18:45:50 +0000 (UTC) Received: by mail-lf1-f65.google.com with SMTP id x69so8546183lff.3 for ; Sun, 27 Sep 2020 11:45:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HXbBaZxONg8BBAGgxG9uroKUYXpPci8VT24wKfZAHcM=; b=BqNVX6Og/7MJqL+uGc4Tn1aIhplzn+9dXtqbLqfHVzvhPcCAyk/NAqTMdz3VyJChWf UQy8RSXWzY1mFmi4PwmJEkCVJQBH/24apYcwKpgx73X0VIEp6D8lw5H933o53NDzOImf CUH+TBXPlcio3GBoEZ1U/BE/1kJypHqJXlJm0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HXbBaZxONg8BBAGgxG9uroKUYXpPci8VT24wKfZAHcM=; b=MIL7lqWzMMW2rvA4nLzfjJzXvHrpQ+s8d3apDGoLdpm3VDMEbpDcDkpXXhDp+IyXwq 6aqAzPF0gpssDG7ezYks0tQyXo03v4QSNRHZhbqdc1vxdoSPM46arZWUdjcIHOhVwtai 7sJFUSo/FomZ//eo5BYfHmiBHKPD0imn4YtsPFH7BOt5I5btJQF5KPHbXj/zrl+fuS7Z LpdfLSRnTn2b5sMmHe02TzLbFFME+MzGeJRLrQ3Lrlvl2L4E1YP63PDxG+Rd2xxCf/Zu DYdDsRFlINTdsDnSfGNU/Aks/YN0KRCMiSDtRrpBvFdOuKtlJpVVbPcnCmdB/kLSWoJe HGIQ== X-Gm-Message-State: AOAM533/FrjRwhOEuzf3QaH2LXDoGdrdjCe7XQTMQJASOGnfMw0PBNGA ehoO8O8IGirX+ypVLeRj7jFpEKt0SYfWIw== X-Google-Smtp-Source: ABdhPJxbT7deFVZIwhgMqOSUyrPUsjWWdSRbQoEzo4UokawRcrgdIlSRh6dJQ0bT3QXazzkie/JeTQ== X-Received: by 2002:a19:c608:: with SMTP id w8mr2623837lff.88.1601232348211; Sun, 27 Sep 2020 11:45:48 -0700 (PDT) Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com. [209.85.167.51]) by smtp.gmail.com with ESMTPSA id 201sm5725361ljf.75.2020.09.27.11.45.46 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 27 Sep 2020 11:45:46 -0700 (PDT) Received: by mail-lf1-f51.google.com with SMTP id x69so8546026lff.3 for ; Sun, 27 Sep 2020 11:45:46 -0700 (PDT) X-Received: by 2002:ac2:4a6a:: with SMTP id q10mr2513864lfp.534.1601232346153; Sun, 27 Sep 2020 11:45:46 -0700 (PDT) MIME-Version: 1.0 References: <20200924175531.GH79898@xz-x1> <20200924181501.GF9916@ziepe.ca> <20200924183418.GJ79898@xz-x1> <20200924183953.GG9916@ziepe.ca> <20200924213010.GL79898@xz-x1> <20200926004136.GJ9916@ziepe.ca> <20200927062337.GE2280698@unreal> In-Reply-To: From: Linus Torvalds Date: Sun, 27 Sep 2020 11:45:30 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/5] mm: Introduce mm_struct.has_pinned To: Leon Romanovsky Cc: Jason Gunthorpe , Peter Xu , John Hubbard , Linux-MM , Linux Kernel Mailing List , Andrew Morton , Jan Kara , Michal Hocko , Kirill Tkhai , Kirill Shutemov , Hugh Dickins , Christoph Hellwig , Andrea Arcangeli , Oleg Nesterov , Jann Horn Content-Type: text/plain; charset="UTF-8" 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 Sun, Sep 27, 2020 at 11:16 AM Linus Torvalds wrote: > > Btw, I'm not convinced about the whole "turn the pte read-only and > then back". If the fork races with another thread doing a pinning > fast-GUP on another CPU, there are memory ordering issues etc too. > That's not necessarily visible on x86 (the "turn read-only being a > locked op will force serialization), but it all looks dodgy as heck. .. looking at it more, I also think it could possibly lose the dirty bit for the case where another CPU did a HW dirty/accessed bit update in between the original read of the pte, and then us writing back the writable pte again. Us holding the page table lock means that no _software_ accesses will happen to the PTE, but dirty/accessed bits can be modified by hardware despite the lock. That is, of course, a completely crazy case, and I think that since we only do this for a COW mapping, and only do the PTE changes if the pte was writable, the pte will always have been dirty already. So I don't think it's an _actual_ bug, but it's another "this looks dodgy as heck" marker. It may _work_, but it sure ain't pretty. But despite having looked at this quite a bit, I don't see anything that looks actively wrong, so I think the series is fine. This is more of a note for people to perhaps think about. Linus