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 2213FC433EF for ; Tue, 21 Dec 2021 18:31:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 742276B0074; Tue, 21 Dec 2021 13:31:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6F0986B007E; Tue, 21 Dec 2021 13:31:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 592B26B0080; Tue, 21 Dec 2021 13:31:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0041.hostedemail.com [216.40.44.41]) by kanga.kvack.org (Postfix) with ESMTP id 47BC86B0074 for ; Tue, 21 Dec 2021 13:31:28 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 06B198A3E2 for ; Tue, 21 Dec 2021 18:31:28 +0000 (UTC) X-FDA: 78942644256.25.392D203 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) by imf15.hostedemail.com (Postfix) with ESMTP id 754FCA003E for ; Tue, 21 Dec 2021 18:31:20 +0000 (UTC) Received: by mail-ed1-f48.google.com with SMTP id f5so32423825edq.6 for ; Tue, 21 Dec 2021 10:31:27 -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=Kr2TxL6wnne8Q9bYsPk7XLye7r5BDis7uMpH40CjpuM=; b=UMZi0Hx4yN8uS8EBWgD+gNYmL13lzK1vKaY6zW2PFGKQwwgxzxKbuKQjiUmhtbIulS rmztzOpTqtEghOW6rMW16mKk1ILe+hsFn7rh5L+vQygm5jShj6QoCzImZ8AR3odal/hZ X3poz6NiOlDdXIa9nYc39Mc7M1gNl6Suze1pw= 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=Kr2TxL6wnne8Q9bYsPk7XLye7r5BDis7uMpH40CjpuM=; b=W9L2l6qvfDtTg15mC0DGT3+vEY2ZSjwP1uJ4iiTa9aiELiLOdy1U02FSktUqk8Xi8a mub25t+DAeJPn0XHc3kTCeDSrYUtu9TCO4er6WDFCj1GpsVGe1y2pNhdv0X1ZEBKOyaB +K0UqCr/ssBKZ2/inKs5rjEjKHbpGkpeQvmmxuDB+DaWzU50r7Y7mfugK0er6Ecs7VFY S19exXUKmhWzEB4sDYP6ic1pHHfsDR2bp3+zCaOCYxuSqfRXdIw7+BCUsGnQZRibco5N z9m+aUr8ekjifm0pS3L/NebsCvQLI/K3Q/fu2knOVBXb3o+Jyp4RiV+O2EWyiDpFlWRP rOmA== X-Gm-Message-State: AOAM532KNQAiDu9vD8HpqGYWUeLzKqBfjSHVi9LKy9ZiRx5hFewQ2JFl XmSawstaiLbIu66tXvLH8jmxN7qlC2HyRSPic+E= X-Google-Smtp-Source: ABdhPJwkh3KgA0vubbJZqiiPtOx0jKo+CFIqs0hEfh75AWoKOP+RlsawKK++BaBGOxoqdYpTTl0Hsg== X-Received: by 2002:a17:907:3e0b:: with SMTP id hp11mr3023997ejc.584.1640111486250; Tue, 21 Dec 2021 10:31:26 -0800 (PST) Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com. [209.85.221.50]) by smtp.gmail.com with ESMTPSA id h10sm2407932ejx.115.2021.12.21.10.31.26 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Dec 2021 10:31:26 -0800 (PST) Received: by mail-wr1-f50.google.com with SMTP id r17so28366684wrc.3 for ; Tue, 21 Dec 2021 10:31:26 -0800 (PST) X-Received: by 2002:a05:6000:10d2:: with SMTP id b18mr3617856wrx.193.1640111475384; Tue, 21 Dec 2021 10:31:15 -0800 (PST) MIME-Version: 1.0 References: <4D97206A-3B32-4818-9980-8F24BC57E289@vmware.com> <5A7D771C-FF95-465E-95F6-CD249FE28381@vmware.com> <20211221010312.GC1432915@nvidia.com> <900b7d4a-a5dc-5c7b-a374-c4a8cc149232@redhat.com> <20211221180705.GA32603@quack2.suse.cz> In-Reply-To: <20211221180705.GA32603@quack2.suse.cz> From: Linus Torvalds Date: Tue, 21 Dec 2021 10:30:59 -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: Jan Kara Cc: David Hildenbrand , Jason Gunthorpe , Nadav Amit , Linux Kernel Mailing List , Andrew Morton , Hugh Dickins , David Rientjes , Shakeel Butt , John Hubbard , Mike Kravetz , Mike Rapoport , Yang Shi , "Kirill A . Shutemov" , Matthew Wilcox , Vlastimil Babka , Jann Horn , Michal Hocko , Rik van Riel , Roman Gushchin , Andrea Arcangeli , Peter Xu , Donald Dutile , Christoph Hellwig , Oleg Nesterov , Linux-MM , "open list:KERNEL SELFTEST FRAMEWORK" , "open list:DOCUMENTATION" Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 754FCA003E X-Stat-Signature: zn9qzauhhzj3g7g9qre44rkxjne9if5g Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b=UMZi0Hx4; dmarc=none; spf=pass (imf15.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.208.48 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org X-HE-Tag: 1640111480-637501 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, Dec 21, 2021 at 10:07 AM Jan Kara wrote: > > For record we always intended (and still intend) to make O_DIRECT use > FOLL_PIN. Just it is tricky because some users mix pages pinned with GUP > and pages acquired through get_page() in a single bio (such as zero page) > and thus it is non-trivial to do the right thing on IO completion (unpin or > just put_page). Side note: the new "exclusive VM" bit wouldn't _solve_ this issue, but it might make it much easier to debug and catch. If we only set the exclusive VM bit on pages that get mapped into user space, and we guarantee that GUP only looks up such pages, then we can also add a debug test to the "unpin" case that the bit is still set. And that would catch anybody who ends up using other pages for unpin(), and you could have a WARN_ON() for it (obviously also trigger on the page count being too small to unpin). That way, at least from a kernel debugging and development standpoint it would make it easy to see "ok, this unpinning got a page that wasn't pinned", and it would help find these cases where some situation had used just a get_page() rather than a pin to get a page pointer. No? Linus