[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211222144255.GE685@quack2.suse.cz>
Date: Wed, 22 Dec 2021 15:42:55 +0100
From: Jan Kara <jack@...e.cz>
To: David Hildenbrand <david@...hat.com>
Cc: Jan Kara <jack@...e.cz>, Jason Gunthorpe <jgg@...dia.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Nadav Amit <namit@...are.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Hugh Dickins <hughd@...gle.com>,
David Rientjes <rientjes@...gle.com>,
Shakeel Butt <shakeelb@...gle.com>,
John Hubbard <jhubbard@...dia.com>,
Mike Kravetz <mike.kravetz@...cle.com>,
Mike Rapoport <rppt@...ux.ibm.com>,
Yang Shi <shy828301@...il.com>,
"Kirill A . Shutemov" <kirill.shutemov@...ux.intel.com>,
Matthew Wilcox <willy@...radead.org>,
Vlastimil Babka <vbabka@...e.cz>, Jann Horn <jannh@...gle.com>,
Michal Hocko <mhocko@...nel.org>,
Rik van Riel <riel@...riel.com>,
Roman Gushchin <guro@...com>,
Andrea Arcangeli <aarcange@...hat.com>,
Peter Xu <peterx@...hat.com>,
Donald Dutile <ddutile@...hat.com>,
Christoph Hellwig <hch@....de>,
Oleg Nesterov <oleg@...hat.com>, Linux-MM <linux-mm@...ck.org>,
"open list:KERNEL SELFTEST FRAMEWORK"
<linux-kselftest@...r.kernel.org>,
"open list:DOCUMENTATION" <linux-doc@...r.kernel.org>
Subject: Re: [PATCH v1 06/11] mm: support GUP-triggered unsharing via
FAULT_FLAG_UNSHARE (!hugetlb)
On Wed 22-12-21 14:09:41, David Hildenbrand wrote:
> >> IIUC, our COW logic makes sure that a shared anonymous page that might
> >> still be used by a R/O FOLL_GET cannot be modified, because any attempt
> >> to modify it would result in a copy.
> >
> > Well, we defined FOLL_PIN to mean the intent that the caller wants to access
> > not only page state (for which is enough FOLL_GET and there are some users
> > - mostly inside mm - who need this) but also page data. Eventually, we even
> > wanted to make FOLL_GET unavailable to broad areas of kernel (and keep it
> > internal to only MM for its dirty deeds ;)) to reduce the misuse of GUP.
> >
> > For file pages we need this data vs no-data access distinction so that
> > filesystems can detect when someone can be accessing page data although the
> > page is unmapped. Practically, filesystems care most about when someone
> > can be *modifying* page data (we need to make sure data is stable e.g. when
> > writing back data to disk or doing data checksumming or other operations)
> > so using FOLL_GET when wanting to only read page data should be OK for
> > filesystems but honestly I would be reluctant to break the rule of "use
> > FOLL_PIN when wanting to access page data" to keep things simple and
> > reasonably easy to understand for parties such as filesystem developers or
> > driver developers who all need to interact with pinned pages...
>
> Right, from an API perspective we really want people to use FOLL_PIN.
>
> To optimize this case in particular it would help if we would have the
> FOLL flags on the unpin path. Then we could just decide internally
> "well, short-term R/O FOLL_PIN can be really lightweight, we can treat
> this like a FOLL_GET instead". And we would need that as well if we were
> to keep different counters for R/O vs. R/W pinned.
Well, I guess the question here is: Which GUP user needs only R/O access to
page data and is so performance critical that it would be worth it to
sacrifice API clarity for speed? I'm not aware of any but I was not looking
really hard...
Honza
--
Jan Kara <jack@...e.com>
SUSE Labs, CR
Powered by blists - more mailing lists