From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Jaya Kumar <jayalk@intworks.biz>, Simona Vetter <simona@ffwll.ch>,
Helge Deller <deller@gmx.de>,
linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
David Hildenbrand <david@redhat.com>
Subject: Re: [RFC PATCH 2/3] mm: provide rmap_wrprotect_file_page() function
Date: Wed, 8 Jan 2025 19:35:12 +0000 [thread overview]
Message-ID: <9dceb81e-ca46-4dce-962f-af2962f78266@lucifer.local> (raw)
In-Reply-To: <Z3607T2A-pukkuQj@casper.infradead.org>
On Wed, Jan 08, 2025 at 05:25:01PM +0000, Matthew Wilcox wrote:
> On Wed, Jan 08, 2025 at 04:18:41PM +0000, Lorenzo Stoakes wrote:
> > +++ b/include/linux/rmap.h
> > @@ -754,6 +754,26 @@ unsigned long page_address_in_vma(const struct folio *folio,
> > */
> > int folio_mkclean(struct folio *);
> >
> > +/**
>
> The kerneldoc comment should be with the implementation, not the
> prototype.
>
> > + * rmap_wrprotect_file_page() - Traverses the reverse mapping, finding all VMAs
> > + * which contain a shared mapping of the single page at PFN @pfn in @mapping at
> > + * offset @pgoff and write-protecting the mappings.
>
> After the '-' should come a _short_ description ... maybe "Write protect
> all mappings of this page".
As you _well_ know Matthew, brevity is not my strong suite ;)
But sure, will cut this down to size...
>
> > + * The PFN mapped does not have to be a folio, but rather can be a kernel
> > + * allocation that is mapped into userland. We therefore do not require that the
> > + * PFN maps to a folio with a valid mapping or index field, rather these are
> > + * specified in @mapping and @pgoff.
> > + *
> > + * @mapping: The mapping whose reverse mapping should be traversed.
> > + * @pgoff: The page offset at which @pfn is mapped within @mapping.
> > + * @nr_pages: The number of physically contiguous base pages spanned.
> > + * @pfn: The PFN of the memory mapped in @mapping at @pgoff.
>
> The description of the params comes between the short and full
> description of the function.
Ack
>
> > + * Return the number of write-protected PTEs, or an error.
>
> colon after Return: so it becomes a section.
Ack will do
>
> > +int rmap_wrprotect_file_page(struct address_space *mapping, pgoff_t pgoff,
> > + unsigned long nr_pages, unsigned long pfn)
> > +{
> > + struct wrprotect_file_state state = {
> > + .cleaned = 0,
> > + .pgoff = pgoff,
> > + .pfn = pfn,
> > + .nr_pages = nr_pages,
> > + };
> > + struct rmap_walk_control rwc = {
> > + .arg = (void *)&state,
> > + .rmap_one = rmap_wrprotect_file_one,
> > + .invalid_vma = invalid_mkclean_vma,
> > + };
> > +
> > + if (!mapping)
> > + return 0;
>
> Should it be valid to pass in NULL?
>
I think it's ok for it to be, as in that case it's valid to say 'ok we
write-protected everything mapped by mapping - which was nothing'.
It's a bit blurry though.
next prev parent reply other threads:[~2025-01-08 19:35 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-08 16:18 [RFC PATCH 0/3] expose mapping wrprotect, fix fb_defio use Lorenzo Stoakes
2025-01-08 16:18 ` [RFC PATCH 1/3] mm: refactor rmap_walk_file() to separate out traversal logic Lorenzo Stoakes
2025-01-08 16:38 ` Matthew Wilcox
2025-01-08 19:23 ` Lorenzo Stoakes
2025-01-08 16:18 ` [RFC PATCH 2/3] mm: provide rmap_wrprotect_file_page() function Lorenzo Stoakes
2025-01-08 17:25 ` Matthew Wilcox
2025-01-08 19:35 ` Lorenzo Stoakes [this message]
2025-01-08 16:18 ` [RFC PATCH 3/3] fb_defio: do not use deprecated page->mapping, index fields Lorenzo Stoakes
2025-01-08 17:32 ` Matthew Wilcox
2025-01-08 19:41 ` Lorenzo Stoakes
2025-01-13 23:01 ` Lorenzo Stoakes
2025-01-08 20:14 ` David Hildenbrand
2025-01-08 20:54 ` Matthew Wilcox
2025-01-08 21:12 ` David Hildenbrand
2025-01-08 21:55 ` Matthew Wilcox
2025-01-08 22:02 ` David Hildenbrand
2025-01-13 17:18 ` Lorenzo Stoakes
2025-01-13 17:48 ` Lorenzo Stoakes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9dceb81e-ca46-4dce-962f-af2962f78266@lucifer.local \
--to=lorenzo.stoakes@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=deller@gmx.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=jayalk@intworks.biz \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=simona@ffwll.ch \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox