[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200212175250.GA11424@infradead.org>
Date: Wed, 12 Feb 2020 09:52:50 -0800
From: Christoph Hellwig <hch@...radead.org>
To: Matthew Wilcox <willy@...radead.org>
Cc: Christoph Hellwig <hch@...radead.org>,
linux-fsdevel@...r.kernel.org, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [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.
Powered by blists - more mailing lists