Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4132879pxk; Tue, 22 Sep 2020 11:03:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+GT43UGwrh17NIvOe1V+ma9QkQIFuBmhdxZfu+grNJ/CmjMkwczOiEUVwYmEOE+ujAqE+ X-Received: by 2002:a17:906:35d5:: with SMTP id p21mr6300575ejb.194.1600797824175; Tue, 22 Sep 2020 11:03:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600797824; cv=none; d=google.com; s=arc-20160816; b=a5h9AsVkeyHoZ1790bv5zfNzhtADc6WWl0HbQIMJo9tG4kFApQbUhFG2R5tew8L+sE SSF499SHYbCaHJ9ftrddHfkWnhrnP6hCqW10WAJdL6F0Bl8EHxe101DSF41P/72TS+rG +zPtpaODyWf4TmgpaWTczWXN0phpJlRD8oPd762TcDInx50/Ym1jlIKBKyqGiK12m1VP 28zqV85yaXENBFhgtjkPV9sl7TCHLQfTQfj0kTPWPM+HhSUSIKK8r4H42cmCJ0jundbz QsEKsbbGFv1TMMV0APWQY+p6umEJtpBOc8TZlo2o+S8ACEsmBqnYj6kNVVEN2a09qN+K ft1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=f5HBlmgjNz3J2e1EmpuzWn7tl8jPNjkQlDmEc1IEB1Y=; b=bbPTzqhAMM8KhUk4iNh2ADduHoR7Nqr2k/7NJ2VLUc3Cz+LPgWNNzV0WnWbM9g3Syo 1DN95TVZXknmyqg64FZYvKFc8YGyYCjwS4oYivEqcrKVCABLbLmmC3qZnguA47m9vs9V 96UZtSeBNngjrsnyImn2drhJv9oifHyu31XzoU+KO1WpfSCpjLsPMwpK4mhfaG4MS4Iz fz3K2Lco9wMxs8ObUqHwUy6tJcf+8PNlrWeIhWdwBam4/2ezJQMDkszVhqmXFNjsFKlD 5wxpfEwZlmL50Vr0z16oxvcmKGKOYj5LDcZYv3VOWcRZuXlBNxA3yoagfJ7lZ9Stf0KC tuhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=groaZUA+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mb18si12670961ejb.680.2020.09.22.11.03.16; Tue, 22 Sep 2020 11:03:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=groaZUA+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726655AbgIVSCF (ORCPT + 99 others); Tue, 22 Sep 2020 14:02:05 -0400 Received: from hqnvemgate25.nvidia.com ([216.228.121.64]:18391 "EHLO hqnvemgate25.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726526AbgIVSCF (ORCPT ); Tue, 22 Sep 2020 14:02:05 -0400 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== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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