[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200411232205.GJ21484@bombadil.infradead.org>
Date: Sat, 11 Apr 2020 16:22:05 -0700
From: Matthew Wilcox <willy@...radead.org>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: linux-fsdevel <linux-fsdevel@...r.kernel.org>,
Linux-MM <linux-mm@...ck.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [GIT PULL] Rename page_offset() to page_pos()
On Sat, Apr 11, 2020 at 03:09:35PM -0700, Linus Torvalds wrote:
> On Sat, Apr 11, 2020 at 3:06 PM Matthew Wilcox <willy@...radead.org> wrote:
> >
> > But we _have_ an offset_in_page() and it doesn't take a struct page
> > argument.
>
> .. it doesn't take a struct page argument because a struct page always
> has one compile-time fixed size.
>
> The only reason you seem to want to get the new interface is because
> you want to change that fact.
>
> So yes, you'd have to change the _existing_ offset_in_page() to take
> that extra "which page" argument.
>
> That's not confusing.
Unfortunately there isn't always a struct page around. For example:
int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len,
struct list_head *uf, bool downgrade)
{
unsigned long end;
struct vm_area_struct *vma, *prev, *last;
if ((offset_in_page(start)) || start > TASK_SIZE || len > TASK_SIZE-start)
return -EINVAL;
where we don't care _which_ page, we just want to know the offset relative
to the architecturally defined page size. In this specific case, it
should probably be changed to is_page_aligned(start).
There are trickier ones like on powerpc:
unsigned long vmalloc_to_phys(void *va)
{
unsigned long pfn = vmalloc_to_pfn(va);
BUG_ON(!pfn);
return __pa(pfn_to_kaddr(pfn)) + offset_in_page(va);
}
where there actually _is_ a struct page, but it will need to be found.
Maybe we can pass in NULL to indicate to use the base page size. Or
rename all current callers to offset_in_base_page() before adding a
struct page pointer to offset_in_page(). Tedious, but doable.
Powered by blists - more mailing lists