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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B567C433EF for ; Fri, 17 Dec 2021 20:40:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 83A136B0073; Fri, 17 Dec 2021 15:40:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7BDFD6B0074; Fri, 17 Dec 2021 15:40:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 636D16B0075; Fri, 17 Dec 2021 15:40:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0056.hostedemail.com [216.40.44.56]) by kanga.kvack.org (Postfix) with ESMTP id 4D0866B0073 for ; Fri, 17 Dec 2021 15:40:21 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 10A5D180DD58D for ; Fri, 17 Dec 2021 20:40:11 +0000 (UTC) X-FDA: 78928453422.06.0E50BA5 Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) by imf19.hostedemail.com (Postfix) with ESMTP id AF0551A002D for ; Fri, 17 Dec 2021 20:40:10 +0000 (UTC) Received: by mail-lj1-f180.google.com with SMTP id i63so5188892lji.3 for ; Fri, 17 Dec 2021 12:40:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1fFYHj/85wq9sp2q1J+u1Ml7YxuIRP5NvJyUtf+MXyA=; b=cJw7R6IKrWDvsdo4quNKJl7yowzlSAHbDI1qyzLRE08kUlNHdph4InZjJ8Da37rlMW TYTu57W8GfVaR3uyaMrsqy6OJvP+dnCqaEhL+vDOl/t5etD3LFAphX+fle4Z+4q5JUHs HptT4U/SfI31C1p3odw09uIZxNiTnn51wMLzY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1fFYHj/85wq9sp2q1J+u1Ml7YxuIRP5NvJyUtf+MXyA=; b=pQNxSV0eUhSSGAiI2Yl0WLFQBNd09UPRqMngcY+l1mu/+xS9ykuPruYf3VUSYlKEtL KplI9Cis1pBl/TwCEoXjxKhEBm0ZJkS0E8NYxonUhdZQJEQn27VAFJMgaHBkYKYKhmn0 u/T9fQBlrLU/v66t9L5QaKQ8cht4WbKeBDaHUhZbC/gDxHHB3EqZsyDy27xf+PGfNwOp N9aZACpH8hk088C9c76h2Fj16EJFSf1cbBLc9fAPLInjb1Or1DpPTnOJM63yzpYjBsnU hZYxyjSnEdQsL47ZiQXFP170OASV++a18O7sV8YD0bu9u9QAQe3PeJF8xSUS2nIhWref JBgw== X-Gm-Message-State: AOAM532C2Iq4bHLlmb0AxYDZ0LouwqbACXV1ZIOGt89yVqZ48KoOo1Yb m1ddGC2HEVSnIKskuk3ln6bwCJMgtCWCJKMmnvY= X-Google-Smtp-Source: ABdhPJw71FP+e205roYgC6RmzJVisL3tVmgtf6wS3evhE9+Pd2I7/r7X3FEsmnCzFdQNPwTgnGlhXA== X-Received: by 2002:a05:651c:1054:: with SMTP id x20mr3988660ljm.445.1639773609254; Fri, 17 Dec 2021 12:40:09 -0800 (PST) Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com. [209.85.167.48]) by smtp.gmail.com with ESMTPSA id j15sm1509658lfe.157.2021.12.17.12.40.08 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 Dec 2021 12:40:09 -0800 (PST) Received: by mail-lf1-f48.google.com with SMTP id d10so7060253lfg.6 for ; Fri, 17 Dec 2021 12:40:08 -0800 (PST) X-Received: by 2002:adf:f54e:: with SMTP id j14mr3847861wrp.442.1639773598131; Fri, 17 Dec 2021 12:39:58 -0800 (PST) MIME-Version: 1.0 References: <20211217113049.23850-1-david@redhat.com> <20211217113049.23850-7-david@redhat.com> <54c492d7-ddcd-dcd0-7209-efb2847adf7c@redhat.com> In-Reply-To: From: Linus Torvalds Date: Fri, 17 Dec 2021 12:39:41 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v1 06/11] mm: support GUP-triggered unsharing via FAULT_FLAG_UNSHARE (!hugetlb) To: David Hildenbrand Cc: Linux Kernel Mailing List , Andrew Morton , Hugh Dickins , David Rientjes , Shakeel Butt , John Hubbard , Jason Gunthorpe , Mike Kravetz , Mike Rapoport , Yang Shi , "Kirill A . Shutemov" , Matthew Wilcox , Vlastimil Babka , Jann Horn , Michal Hocko , Nadav Amit , Rik van Riel , Roman Gushchin , Andrea Arcangeli , Peter Xu , Donald Dutile , Christoph Hellwig , Oleg Nesterov , Jan Kara , Linux-MM , "open list:KERNEL SELFTEST FRAMEWORK" , "open list:DOCUMENTATION" Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b=cJw7R6IK; spf=pass (imf19.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.208.180 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org; dmarc=none X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: AF0551A002D X-Stat-Signature: a8tmkfwkkkm4nqi6zk4ekomr4aji4w7g X-HE-Tag: 1639773610-347427 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 Fri, Dec 17, 2021 at 12:36 PM Linus Torvalds wrote: > > > > > 5. Take a R/O pin (RDMA, VFIO, ...) > > -> refcount > 1 > > > > 6. memset(mem, 0xff, pagesize); > > -> Write fault -> COW > > I do not believe this is actually a bug. > > You asked for a R/O pin, and you got one. If you want a shared pin that actually follows the changes of your process around, then that is what you should have asked for. At the time of such a shared pin, you can do what we already do: re-use the page if it has a refcount of 1. Or do an early COW event (feel free to avoid the "mark it writable and dirty"). But note: *refcount* of 1. Not "mapcount". Because mapcount would be broken garbage. Linus