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.1 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 C20C7C2D0A8 for ; Wed, 23 Sep 2020 13:50:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0E48C21BE5 for ; Wed, 23 Sep 2020 13:50:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XQgnBCkw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0E48C21BE5 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 70DE96B0062; Wed, 23 Sep 2020 09:50:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6BEDA6B0068; Wed, 23 Sep 2020 09:50:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5866F6B006C; Wed, 23 Sep 2020 09:50:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0233.hostedemail.com [216.40.44.233]) by kanga.kvack.org (Postfix) with ESMTP id 3EAC96B0062 for ; Wed, 23 Sep 2020 09:50:13 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id EF66E180AD804 for ; Wed, 23 Sep 2020 13:50:12 +0000 (UTC) X-FDA: 77294460264.28.bread36_410ef3927156 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id C90FE6C04 for ; Wed, 23 Sep 2020 13:50:12 +0000 (UTC) X-HE-Tag: bread36_410ef3927156 X-Filterd-Recvd-Size: 6630 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Wed, 23 Sep 2020 13:50:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600869011; 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=cBbOOKO0ucHd2rpc+S+Efks0E+NiERhRTxqZGrwQ8go=; b=XQgnBCkwqgfcCDWiukUrj61r0gP8WTk9+FricE9l/L1ALeTNZmWkpXwDuAdm2+USGroJCJ odZCNnBDxw9Hy8/cQmOi6NiQxM1VJqeAW+TkL2VtURJCkjqbAVIc3Eg5rKZ9koQfdnOypj lqoArmpXH4N4YWmn8+nIxYy4dgqy8ak= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-558-b9vnYSQnMaKBF_MhFakkrQ-1; Wed, 23 Sep 2020 09:50:08 -0400 X-MC-Unique: b9vnYSQnMaKBF_MhFakkrQ-1 Received: by mail-qv1-f71.google.com with SMTP id k14so32195qvw.20 for ; Wed, 23 Sep 2020 06:50:07 -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=cBbOOKO0ucHd2rpc+S+Efks0E+NiERhRTxqZGrwQ8go=; b=Y4KfNRl/S12UutpR1TlmlqPlXYOhSIGvFIZ9QluA9qhtB1UKA3B4HE76jzlXjVT1mJ ce0fLArF5Zz8Si5VcABxNY+ilZzyV8pz+MIkd35h0ZkrOVTgKw2EguxL8mNt9zqRGeXc ii0QLa2WLx1l1UauhePkcRcTPtkXDmLSTL7hksuxNUzrJRgLAO++kjTZtfzIN0BBuFio Y1mEUu+WuQhiZhBCHxO13X23Sa3hVy78QrLiFiZ52imPu2RHzaQS7Y7cS7CEZXroOz4i i9wB7jE8ZYHi7qNM6SGE5pb0m/w2ZRG1YfGDpwRMDIK+HuyNbLVyYhSZFmMKFmaCQ5BE OyFw== X-Gm-Message-State: AOAM5332qszDh7nUNi878Od0wxDCPqL5dWxv78eA2L1vBSEUe8mXN7ol Q219FZfDaxY9hdEJL/cZb02aFA5/EkjbzIB5SvUv0vx4HfYepHfwq6rR83Rpp6UZEtafREJJU6u nfNu2/TLq/ZI= X-Received: by 2002:ac8:4784:: with SMTP id k4mr94268qtq.266.1600869007127; Wed, 23 Sep 2020 06:50:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymluAocXlZKNKvjSQP1X70AcJPuQ7HzHich5liwak0L/3clODl36dmZDmKsXiVxH3joTCAnw== X-Received: by 2002:ac8:4784:: with SMTP id k4mr94229qtq.266.1600869006828; Wed, 23 Sep 2020 06:50:06 -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 z2sm11400qkg.40.2020.09.23.06.50.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 06:50:06 -0700 (PDT) Date: Wed, 23 Sep 2020 09:50:04 -0400 From: Peter Xu To: Jan Kara Cc: John Hubbard , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Linus Torvalds , Michal Hocko , Kirill Shutemov , Jann Horn , Oleg Nesterov , Kirill Tkhai , Hugh Dickins , Leon Romanovsky , Christoph Hellwig , Andrew Morton , Jason Gunthorpe , Andrea Arcangeli Subject: Re: [PATCH 5/5] mm/thp: Split huge pmds/puds if they're pinned when fork() Message-ID: <20200923135004.GB59978@xz-x1> 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> MIME-Version: 1.0 In-Reply-To: <20200923092205.GA6719@quack2.suse.cz> 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 Wed, Sep 23, 2020 at 11:22:05AM +0200, Jan Kara wrote: > On Tue 22-09-20 13:01:13, John Hubbard wrote: > > On 9/22/20 3:33 AM, Jan Kara wrote: > > > On Mon 21-09-20 23:41:16, John Hubbard wrote: > > > > On 9/21/20 2:20 PM, Peter Xu wrote: > > > > ... > > > > > + if (unlikely(READ_ONCE(src_mm->has_pinned) && > > > > > + page_maybe_dma_pinned(src_page))) { > > > > > > > > This condition would make a good static inline function. It's used in 3 > > > > places, and the condition is quite special and worth documenting, and > > > > having a separate function helps with that, because the function name > > > > adds to the story. I'd suggest approximately: > > > > > > > > page_likely_dma_pinned() > > > > > > > > for the name. > > > > > > Well, but we should also capture that this really only works for anonymous > > > pages. For file pages mm->has_pinned does not work because the page may be > > > still pinned by completely unrelated process as Jann already properly > > > pointed out earlier in the thread. So maybe anon_page_likely_pinned()? > > > Possibly also assert PageAnon(page) in it if we want to be paranoid... > > > > > > Honza > > > > The file-backed case doesn't really change anything, though: > > page_maybe_dma_pinned() is already a "fuzzy yes" in the same sense: you > > can get a false positive. Just like here, with an mm->has_pinned that > > could be a false positive for a process. > > > > And for that reason, I'm also not sure an "assert PageAnon(page)" is > > desirable. That assertion would prevent file-backed callers from being > > able to call a function that provides a fuzzy answer, but I don't see > > why you'd want or need to do that. The goal here is to make the fuzzy > > answer a little bit more definite, but it's not "broken" just because > > the result is still fuzzy, right? > > > > Apologies if I'm missing a huge point here... :) > > 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? 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? Thanks, -- Peter Xu