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=-11.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL 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 84148C4727D for ; Mon, 21 Sep 2020 22:28:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 26E9E23A63 for ; Mon, 21 Sep 2020 22:28:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="kRn/Tsc4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 26E9E23A63 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 676A790000B; Mon, 21 Sep 2020 18:28:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5FFE7900007; Mon, 21 Sep 2020 18:28:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4C89490000B; Mon, 21 Sep 2020 18:28:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0074.hostedemail.com [216.40.44.74]) by kanga.kvack.org (Postfix) with ESMTP id 33231900007 for ; Mon, 21 Sep 2020 18:28:04 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E97E73628 for ; Mon, 21 Sep 2020 22:28:03 +0000 (UTC) X-FDA: 77288507646.19.fuel90_42163fd27148 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id BE3BB1AD1B9 for ; Mon, 21 Sep 2020 22:28:03 +0000 (UTC) X-HE-Tag: fuel90_42163fd27148 X-Filterd-Recvd-Size: 5008 Received: from mail-ej1-f68.google.com (mail-ej1-f68.google.com [209.85.218.68]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Mon, 21 Sep 2020 22:28:03 +0000 (UTC) Received: by mail-ej1-f68.google.com with SMTP id e23so20040459eja.3 for ; Mon, 21 Sep 2020 15:28:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kM6XzhJJTngcIIzefpQFOgDA2+BF/Ae7nqpjlvmm9QY=; b=kRn/Tsc43tCRa7uA/MUO1KALZMdYG7hOnA+kndhviJ5CRXnhvTY7ZHpKRpGZrNNBC1 gCrAvfcS1zCCclZyNeidP67cLdDgqT7TU1yLEoOhQcFfsN+fyptJ88HT0bbTAmd7wUMH HyM4c7va/CdxQtHBLeW0+KWWdetakCqR94qTg4+ArKEfAoE/L+BhR0ckCrRvM9JPSH/x W48syV78YHrEIm6efqGPnYlQ49uCD+HhDnZ7dkTZt/j7gSIbXTAYgtRT478Sg5v7Oof3 Vfkfy38fjj9Ky4AR590IKenOZm49jukkIYUBVH82TWQxmfxNbydy1gVNh+s6pS+9eCp4 rKRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kM6XzhJJTngcIIzefpQFOgDA2+BF/Ae7nqpjlvmm9QY=; b=XdCBtJnNSYH8dplQkt/feVR1eIPo818mkGbhRH1gNmZVPCZvmJhf3oT10144W2DmIq LgJxo8VkKNaFHIQf9nre6N0sstUJoRVHgaK5ORwrb/cWWjcuS4pC1p8KvvuIkZkbcRdn H2eatiwpLr1ePLvWkcpK5setXSpEZ5c8U6/PGmrrxxqLvmQzndZQzL/aa+Mlwtd+pWQ2 40ZUc/pG6pbaBYqj4duRw8ycXS/HbseaeYcBo3JM8wPV1kiRTiTaDlNDByXxPxbQhvPP bXuquBlK47gXzJopLL5Ab4Fg26V/dyYhbg/Z/mHmgRe+U+S+nd+FuYue+vLMy094OmLj AUvQ== X-Gm-Message-State: AOAM530X26zhbslK7xhWylkXiUvBSvciS22S+LDW2UOKJFGdepu0xDtp sWdjUnzlsMs5Ah1Rz9hYtOcguTlSS3qo6B1AxJ+Gp/hZBWE= X-Google-Smtp-Source: ABdhPJxLDKLQe/ZVz6jB0RLtkFvXY+Fh007M1Kp5WpliEi2wLaAHVpyExx3WKXhfuMXUu9OwcEk+2uyQo9xwg/hxf+c= X-Received: by 2002:a17:907:64d:: with SMTP id wq13mr1669531ejb.513.1600727281873; Mon, 21 Sep 2020 15:28:01 -0700 (PDT) MIME-Version: 1.0 References: <20200921211744.24758-1-peterx@redhat.com> <20200921212028.25184-1-peterx@redhat.com> <07bc5f59-74ae-73e8-2616-f11712c27b58@nvidia.com> In-Reply-To: <07bc5f59-74ae-73e8-2616-f11712c27b58@nvidia.com> From: Jann Horn Date: Tue, 22 Sep 2020 00:27:35 +0200 Message-ID: Subject: Re: [PATCH 4/5] mm: Do early cow for pinned pages during fork() for ptes To: John Hubbard Cc: Peter Xu , Linux-MM , kernel list , Linus Torvalds , Michal Hocko , Kirill Shutemov , Oleg Nesterov , Kirill Tkhai , Hugh Dickins , Leon Romanovsky , Jan Kara , Christoph Hellwig , Andrew Morton , Jason Gunthorpe , Andrea Arcangeli Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, 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 12:18 AM John Hubbard wrote: > On 9/21/20 2:55 PM, Jann Horn wrote: > > On Mon, Sep 21, 2020 at 11:20 PM Peter Xu wrote: > ... > > I dislike the whole pin_user_pages() concept because (as far as I > > understand) it fundamentally tries to fix a problem in the subset of > > cases that are more likely to occur in practice (long-term pins > > overlapping with things like writeback), and ignores the rarer cases > > ("short-term" GUP). > > > > Well, no, that's not really fair. pin_user_pages() provides a key > prerequisite to fixing *all* of the bugs in that area, not just a > subset. The 5 cases in Documentation/core-api/pin_user_pages.rst cover > this pretty well. Or if they don't, let me know and I'll have another > pass at it. > > The case for a "pin count" that is (logically) separate from a > page->_refcount is real, and it fixes real problems. An elevated > refcount can be caused by a lot of things, but it can normally be waited > for and/or retried. The FOLL_PIN pages cannot. > > Of course, a valid remaining criticism of the situation is, "why not > just *always* mark any of these pages as "dma-pinned"? In other words, > why even have a separate gup/pup API? And in fact, perhaps eventually > we'll just get rid of the get_user_pages*() side of it. But the pin > count will need to remain, in order to discern between DMA pins and > temporary refcount boosts. Ah... the documentation you linked implies that FOLL_WRITE should more or less imply FOLL_PIN? I didn't realize that. Whoops, and actually, process_vm_writev() does use FOLL_PIN already, and I just grepped the code the wrong way. Thanks for the enlightenment; I take back everything I said.