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=-6.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,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 7FAF1C4727E for ; Wed, 23 Sep 2020 20:19:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D1F27206DB for ; Wed, 23 Sep 2020 20:19:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nvidia.com header.i=@nvidia.com header.b="aINlxSKQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D1F27206DB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nvidia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E84886B0003; Wed, 23 Sep 2020 16:19:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E33CF6B0037; Wed, 23 Sep 2020 16:19:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D49426B005A; Wed, 23 Sep 2020 16:19:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0067.hostedemail.com [216.40.44.67]) by kanga.kvack.org (Postfix) with ESMTP id BE29A6B0003 for ; Wed, 23 Sep 2020 16:19:11 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 7B350181AE861 for ; Wed, 23 Sep 2020 20:19:11 +0000 (UTC) X-FDA: 77295440502.10.sense66_08148ab27159 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id 51D3416A4AB for ; Wed, 23 Sep 2020 20:19:11 +0000 (UTC) X-HE-Tag: sense66_08148ab27159 X-Filterd-Recvd-Size: 5585 Received: from hqnvemgate25.nvidia.com (hqnvemgate25.nvidia.com [216.228.121.64]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Wed, 23 Sep 2020 20:19:10 +0000 (UTC) Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Wed, 23 Sep 2020 13:18:22 -0700 Received: from [10.2.55.40] (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 23 Sep 2020 20:19:08 +0000 Subject: Re: [PATCH 5/5] mm/thp: Split huge pmds/puds if they're pinned when fork() To: Peter Xu , Jan Kara CC: , , Linus Torvalds , Michal Hocko , "Kirill Shutemov" , Jann Horn , Oleg Nesterov , Kirill Tkhai , Hugh Dickins , Leon Romanovsky , Christoph Hellwig , Andrew Morton , Jason Gunthorpe , Andrea Arcangeli References: <20200921211744.24758-1-peterx@redhat.com> <20200921212031.25233-1-peterx@redhat.com> <5e594e71-537f-3e9f-85b6-034b7f5fedbe@nvidia.com> <20200922103315.GD15112@quack2.suse.cz> <4a65586e-9282-beb0-1880-1ef8da03727c@nvidia.com> <20200923092205.GA6719@quack2.suse.cz> <20200923135004.GB59978@xz-x1> <20200923140114.GA15875@quack2.suse.cz> <20200923154418.GE59978@xz-x1> From: John Hubbard Message-ID: Date: Wed, 23 Sep 2020 13:19:08 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200923154418.GE59978@xz-x1> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1600892302; bh=r5vR4RQQYYxj0hqrOK7ZHOkTc2Yiu8s3wqtDVwwvNL4=; h=Subject:To:CC:References:From:Message-ID:Date:User-Agent: MIME-Version:In-Reply-To:Content-Type:Content-Language: Content-Transfer-Encoding:X-Originating-IP:X-ClientProxiedBy; b=aINlxSKQL25fqxpGaypjwiVEleTXGmWDHe4uaqSx5Zhy9Eza52rh/BxF2pdMFfSo9 IwhmwtKexbNgraIGKpehrR0Deck4v1nqyllHbwSEvt4NaNCf5rxTOwyi9saA/Y/wRs WdmV6DAxtgVZKIi9Wd7FRleB3QV9xp1ICnJY8EFstOKUO4h1ws8kL9sACBwVPu3vcx 295WTE/EnHfA3mrqxDGpVhnMboS3mISrkRDJAw4t38MQrc1M77hLkurruikHXifw78 HOm4DShuOKh4vvjxsqptSU0YliDL60qgFHxril23S8wuZb5jNNDlfiODHmN0sW6qY7 HmOIDTddktiGw== 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 9/23/20 8:44 AM, Peter Xu wrote: > On Wed, Sep 23, 2020 at 04:01:14PM +0200, Jan Kara wrote: >> On Wed 23-09-20 09:50:04, Peter Xu wrote: ... >>>> But the problem is that if you apply mm->has_pinned check on file pages, >>>> you can get false negatives now. And that's not acceptable... >>> >>> Do you mean the case where proc A pinned page P from a file, then proc B >>> mapped the same page P on the file, then fork() on proc B? >> >> Yes. aha, thanks for spelling out the false negative problem. >> >>> If proc B didn't explicitly pinned page P in B's address space too, >>> shouldn't we return "false" for page_likely_dma_pinned(P)? Because if >>> proc B didn't pin the page in its own address space, I'd think it's ok to >>> get the page replaced at any time as long as the content keeps the same. >>> Or couldn't we? >> >> So it depends on the reason why you call page_likely_dma_pinned(). For your >> COW purposes the check is correct but e.g. for "can filesystem safely >> writeback this page" the page_likely_dma_pinned() would be wrong. So I'm >> not objecting to the mechanism as such. I'm mainly objecting to the generic >> function name which suggests something else than what it really checks and >> thus it could be used in wrong places in the future... That's why I'd >> prefer to restrict the function to PageAnon pages where there's no risk of >> confusion what the check actually does. > > How about I introduce the helper as John suggested, but rename it to > > page_maybe_dma_pinned_by_mm() > > ? > > Then we also don't need to judge on which is more likely to happen (between > "maybe" and "likely", since that will confuse me if I only read these words..). > You're right, it is too subtle of a distinction after all. I agree that sticking with "_maybe_" avoids that confusion. > I didn't use any extra suffix like "cow" because I think it might be useful for > things besides cow. Fundamentally the new helper will be mm-based, so "by_mm" > seems to suite better to me. > > Does that sound ok? > Actually, Jan nailed it. I just wasn't understanding his scenario, but now that I do, and considering your other point about wording, I think we end up with: anon_page_maybe_pinned() as a pretty good name for a helper function. (We don't want "_mm" because that refers more to the mechanism used internally, rather than the behavior of the function. "anon_" adds more meaning.) ...now I better go and try to grok what Jason is recommending for the new meaning of FOLL_PIN, in another tributary of this thread. I don't *think* it affects this naming point, though. :) thanks, -- John Hubbard NVIDIA