Re: [PATCH -mm] mm: refactor page index/offset getters

From: Naoya Horiguchi
Date: Wed Jul 23 2014 - 17:46:16 EST


On Wed, Jul 23, 2014 at 02:39:18PM -0700, Andrew Morton wrote:
> On Tue, 15 Jul 2014 12:41:12 -0400 Naoya Horiguchi <n-horiguchi@xxxxxxxxxxxxx> wrote:
>
> > There is a complaint about duplication around the fundamental routines
> > of page index/offset getters.
> >
> > page_(index|offset) and page_file_(index|offset) provide the same
> > functionality, so we can merge them as page_(index|offset), respectively.
> >
> > And this patch gives the clear meaning to the getters:
> > - page_index(): get page cache index (offset in relevant page size)
> > - page_pgoff(): get 4kB page offset
> > - page_offset(): get byte offset
> > All these functions are aware of regular pages, swapcaches, and hugepages.
> >
> > The definition of PageHuge is relocated to include/linux/mm.h, because
> > some users of page_pgoff() doesn't include include/linux/hugetlb.h.
> >
> > __page_file_index() is not well named, because it's only for swap cache.
> > So let's rename it with __page_swap_index().
>
> Thanks, I guess that's better. Could others please have a look-n-think?
>
> I did this:
>
> --- a/include/linux/pagemap.h~mm-refactor-page-index-offset-getters-fix
> +++ a/include/linux/pagemap.h
> @@ -412,7 +412,7 @@ static inline pgoff_t page_pgoff(struct
> }
>
> /*
> - * Return the byte offset of the given page.
> + * Return the file offset of the given pagecache page, in bytes.

Thanks, it's clearer.

> static inline loff_t page_offset(struct page *page)
> {
>
>
>
> You had a random xfs_aops.c whitespace fix which I'll pretend I didn't
> notice ;)

I just couldn't resist fixing it ;)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/