lkml.org 
[lkml]   [2020]   [Feb]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 02/25] mm: Optimise find_subpage for !THP
On Wed, Feb 12, 2020 at 05:02:00AM -0800, Matthew Wilcox wrote:
> > Can you add comments describing the use case of this function and why
> > it does all these checks? It looks like black magic to me.
>
> Would this help?
>
> -static inline struct page *find_subpage(struct page *page, pgoff_t offset)
> +/*
> + * Given the page we found in the page cache, return the page corresponding
> + * to this offset in the file
> + */
> +static inline struct page *find_subpage(struct page *head, pgoff_t offset)
> {
> - if (PageHuge(page))
> - return page;
> + /* HugeTLBfs wants the head page regardless */
> + if (PageHuge(head))
> + return head;
>
> - VM_BUG_ON_PAGE(PageTail(page), page);
> + VM_BUG_ON_PAGE(PageTail(head), head);
>
> - return page + (offset & (hpage_nr_pages(page) - 1));
> + return head + (offset & (hpage_nr_pages(head) - 1));

Much better.

\
 
 \ /
  Last update: 2020-02-12 18:53    [W:1.126 / U:1.492 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site