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.8 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 AAAF6C2D0E2 for ; Tue, 22 Sep 2020 18:02:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2D29F23787 for ; Tue, 22 Sep 2020 18:02:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nvidia.com header.i=@nvidia.com header.b="groaZUA+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2D29F23787 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 70F026B0003; Tue, 22 Sep 2020 14:02:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 697A86B0037; Tue, 22 Sep 2020 14:02:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 511328E0001; Tue, 22 Sep 2020 14:02:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0098.hostedemail.com [216.40.44.98]) by kanga.kvack.org (Postfix) with ESMTP id 366CB6B0003 for ; Tue, 22 Sep 2020 14:02:07 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E11BD8249980 for ; Tue, 22 Sep 2020 18:02:06 +0000 (UTC) X-FDA: 77291466252.14.sleet74_5b096102714f Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id CC82318229818 for ; Tue, 22 Sep 2020 18:02:06 +0000 (UTC) X-HE-Tag: sleet74_5b096102714f X-Filterd-Recvd-Size: 5092 Received: from hqnvemgate25.nvidia.com (hqnvemgate25.nvidia.com [216.228.121.64]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Tue, 22 Sep 2020 18:02:06 +0000 (UTC) Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Tue, 22 Sep 2020 11:01:18 -0700 Received: from [10.2.52.174] (172.20.13.39) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 22 Sep 2020 18:02:04 +0000 Subject: Re: [PATCH 1/5] mm: Introduce mm_struct.has_pinned To: Peter Xu CC: , , Jason Gunthorpe , Andrew Morton , Jan Kara , Michal Hocko , Kirill Tkhai , Kirill Shutemov , Hugh Dickins , Christoph Hellwig , Andrea Arcangeli , Oleg Nesterov , Leon Romanovsky , Linus Torvalds , "Jann Horn" References: <20200921211744.24758-1-peterx@redhat.com> <20200921211744.24758-2-peterx@redhat.com> <224908c1-5d0f-8e01-baa9-94ec2374971f@nvidia.com> <20200922151736.GD19098@xz-x1> From: John Hubbard Message-ID: <3d17619c-36b4-b080-08ff-26b3e9acb616@nvidia.com> Date: Tue, 22 Sep 2020 11:02:03 -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: <20200922151736.GD19098@xz-x1> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [172.20.13.39] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1600797678; bh=f5HBlmgjNz3J2e1EmpuzWn7tl8jPNjkQlDmEc1IEB1Y=; 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=groaZUA+qmBF2rUoWrmkRYVpMU0YkBRICplXas67ZSE9T/rX3VSAXlXyWFxX0NfYl Hd8EJrp6xfKWCRpGgcXOic5poE0nXuCtiCB+CAQKOVzfHx1hoIGzeVRwFqbAmTfZ54 JzzM5cSw83VGErCbXpgLmdCqDCJFeiSfwPx5UbfMseX9yfG0PzokPxQ1nUsX2hVfKg SWXGaKi1rVmQZ7lvKuZ1jQQOWOPFvySWH+km/nYy0h/HDfLJT6l9EcxkmKavbTjiW4 8nz+7HPoKQsFO1oCykWfJugPI90CXkfzAsu8wS/qXT65twuVMP5/RAS+ZpiOkFbAoX AFBIwS/wbBBxQ== 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/22/20 8:17 AM, Peter Xu wrote: > On Mon, Sep 21, 2020 at 04:53:38PM -0700, John Hubbard wrote: >> On 9/21/20 2:17 PM, Peter Xu wrote: >>> (Commit message collected from Jason Gunthorpe) >>> >>> Reduce the chance of false positive from page_maybe_dma_pinned() by keeping >> >> Not yet, it doesn't. :) More: >> >>> track if the mm_struct has ever been used with pin_user_pages(). mm_structs >>> that have never been passed to pin_user_pages() cannot have a positive >>> page_maybe_dma_pinned() by definition. This allows cases that might drive up >>> the page ref_count to avoid any penalty from handling dma_pinned pages. >>> >>> Due to complexities with unpining this trivial version is a permanent sticky >>> bit, future work will be needed to make this a counter. >> >> How about this instead: >> >> Subsequent patches intend to reduce the chance of false positives from >> page_maybe_dma_pinned(), by also considering whether or not a page has >> even been part of an mm struct that has ever had pin_user_pages*() >> applied to any of its pages. >> >> In order to allow that, provide a boolean value (even though it's not >> implemented exactly as a boolean type) within the mm struct, that is >> simply set once and never cleared. This will suffice for an early, rough >> implementation that fixes a few problems. >> >> Future work is planned, to provide a more sophisticated solution, likely >> involving a counter, and *not* involving something that is set and never >> cleared. > > This looks good, thanks. Though I think Jason's version is good too (as long > as we remove the confusing sentence, that's the one starting with "mm_structs > that have never been passed... "). Before I drop Jason's version, I think I'd > better figure out what's the major thing we missed so that maybe we can add > another paragraph. E.g., "future work will be needed to make this a counter" > already means "involving a counter, and *not* involving something that is set > and never cleared" to me... Because otherwise it won't be called a counter.. > That's just a bit of harmless redundancy, intended to help clarify where this is going. But if the redundancy isn't actually helping, you could simply truncate it to the first half of the sentence, like this: "Future work is planned, to provide a more sophisticated solution, likely involving a counter." thanks, -- John Hubbard NVIDIA