Re: [RFC PATCH 2/3] mm: provide rmap_wrprotect_file_page() function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux