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=-5.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, 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 0BC97C4363D for ; Tue, 22 Sep 2020 18:15:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 95236238A1 for ; Tue, 22 Sep 2020 18:15:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VtPX8bgE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 95236238A1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 05C1A900002; Tue, 22 Sep 2020 14:15:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 00CC66B0055; Tue, 22 Sep 2020 14:15:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E47C16B0003; Tue, 22 Sep 2020 14:15:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0180.hostedemail.com [216.40.44.180]) by kanga.kvack.org (Postfix) with ESMTP id CE99A6B0003 for ; Tue, 22 Sep 2020 14:15:28 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 807EB3634 for ; Tue, 22 Sep 2020 18:15:28 +0000 (UTC) X-FDA: 77291499936.22.fall59_5d152242714f Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id 55A8718038E67 for ; Tue, 22 Sep 2020 18:15:28 +0000 (UTC) X-HE-Tag: fall59_5d152242714f X-Filterd-Recvd-Size: 6669 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf20.hostedemail.com (Postfix) with ESMTP for ; Tue, 22 Sep 2020 18:15:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600798527; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=a3l0rBljR/kZ/ov9FS2rhng6LmUSlhlNsXbHtLgNw0c=; b=VtPX8bgEnf7jZCkrOJ+oF7D0OfheAT15srEAqZyEPvwrSFGZt1QxO+mVDnqbIHzTEGyo19 dQYqWeUfOKoSa1sS4cIMXsCBNzCiXxjNZYhCfFie0FJzY6G63aILaDtjtnh8ZpFHphOp8i nQ6azOmboC4G9s3zTmyLSDHujVi6vjE= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-400-QrN7sS1gO5i2OJ9TJN4EJA-1; Tue, 22 Sep 2020 14:15:25 -0400 X-MC-Unique: QrN7sS1gO5i2OJ9TJN4EJA-1 Received: by mail-qk1-f200.google.com with SMTP id a2so14411827qkg.19 for ; Tue, 22 Sep 2020 11:15:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=a3l0rBljR/kZ/ov9FS2rhng6LmUSlhlNsXbHtLgNw0c=; b=OtuqQ8SckeHNoR5KZ2OkmLozx/VD6ZXetbbd0IGSSkUP1JLUpvF15al+55AI/1BGX2 QCc7hLQsbfhX9wsk8wj2vhgyKoByG/S85SUHQ61z0t046QC/GIvWc8wHfeY7YGXi0n6e qkN9Y8Gk55lQSP1SfgUQ07BC1QnecA57NCtgfX63hr/f9EfRNt/JpVkJUkw7fOJvxlEi +LetvaRcnNIhlsgKZvpLjldGstR14+oV8BuTEPpFiW6rbXKPNPZyx38HBo/HCjQJ5iC0 YAILw7XlVQVgPU2L0vn/JW4NLGXI89Y92wjBY7gaV6afDVrJLj0MP3UFam8Y1R6wdA6d AHFg== X-Gm-Message-State: AOAM530bX52TMIn8uEbklNRvrzQ9ygA8txzVpR5rj/rcy0Taxmuj255i vxoJvrhG349lcCExCkeQGuJPyKAqt71zGv8TTvPzdLho7MvFTpYc5jRycUP11Wg9euK44xpzTrV s108A+k3V6xo= X-Received: by 2002:ac8:12c1:: with SMTP id b1mr6193360qtj.148.1600798524742; Tue, 22 Sep 2020 11:15:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5RZxf+jdVFnmcfF4QmpuiQvcdBFQtD/E68HLrbqxk5hc3ELvpCf5wLHsz32pseUsijk2RIA== X-Received: by 2002:ac8:12c1:: with SMTP id b1mr6193332qtj.148.1600798524459; Tue, 22 Sep 2020 11:15:24 -0700 (PDT) Received: from xz-x1 (bras-vprn-toroon474qw-lp130-11-70-53-122-15.dsl.bell.ca. [70.53.122.15]) by smtp.gmail.com with ESMTPSA id 5sm12146971qkj.135.2020.09.22.11.15.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2020 11:15:23 -0700 (PDT) Date: Tue, 22 Sep 2020 14:15:22 -0400 From: Peter Xu To: John Hubbard Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, 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 Subject: Re: [PATCH 1/5] mm: Introduce mm_struct.has_pinned Message-ID: <20200922181522.GK19098@xz-x1> References: <20200921211744.24758-1-peterx@redhat.com> <20200921211744.24758-2-peterx@redhat.com> <224908c1-5d0f-8e01-baa9-94ec2374971f@nvidia.com> <20200922151736.GD19098@xz-x1> <3d17619c-36b4-b080-08ff-26b3e9acb616@nvidia.com> MIME-Version: 1.0 In-Reply-To: <3d17619c-36b4-b080-08ff-26b3e9acb616@nvidia.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline 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 Tue, Sep 22, 2020 at 11:02:03AM -0700, John Hubbard wrote: > 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." Will do. Thanks. -- Peter Xu