From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
"Kirill A. Shutemov" <kirill@shutemov.name>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
Hugh Dickins <hughd@google.com>, Rik van Riel <riel@redhat.com>,
Hillf Danton <dhillf@gmail.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Naoya Horiguchi <nao.horiguchi@gmail.com>
Subject: Re: [PATCH -mm] mm: refactor page index/offset getters
Date: Mon, 28 Jul 2014 20:42:46 -0400 [thread overview]
Message-ID: <20140729004246.GA5822@nhori.redhat.com> (raw)
In-Reply-To: <20140728202952.GP1725@cmpxchg.org>
On Mon, Jul 28, 2014 at 04:29:52PM -0400, Johannes Weiner wrote:
> On Tue, Jul 15, 2014 at 12:41:12PM -0400, Naoya Horiguchi wrote:
> > @@ -399,28 +399,24 @@ static inline struct page *read_mapping_page(struct address_space *mapping,
> > }
> >
> > /*
> > - * Get the offset in PAGE_SIZE.
> > + * Return the 4kB page offset of the given page.
> > * (TODO: hugepage should have ->index in PAGE_SIZE)
> > */
> > -static inline pgoff_t page_to_pgoff(struct page *page)
> > +static inline pgoff_t page_pgoff(struct page *page)
> > {
> > - if (unlikely(PageHeadHuge(page)))
> > - return page->index << compound_order(page);
> > - else
> > - return page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
> > + if (unlikely(PageHuge(page))) {
> > + VM_BUG_ON_PAGE(PageTail(page), page);
> > + return page_index(page) << compound_order(page);
> > + } else
> > + return page_index(page) << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
> > }
>
> I just bisected the VM refusing to swap and triggering OOM kills to
> this patch, which is likely the same bug you reported a couple days
> back when you had this patch in your private tree.
Right, thanks.
And sorry for taking your time for my poor testing.
> Changing page->index to page_index() makes this function return the
> swap offset rather than the virtual PFN, but rmap uses this to index
> Into virtual address space. Thus, swapcache pages can no longer be
> found from try_to_unmap() and reclaim fails.
I missed the fact that swap code needs both swap offset (stored in
page->private) and virtual PFN (in page->index), so unifying offset
getters to a single helper is completely wrong.
> We can't simply change it back to page->index, however, because the
> swapout path, which requires the swap offset, also uses this function
> through page_offset(). Virtual address space functions and page cache
> address space functions can't use the same helpers, and the helpers
> should likely be named distinctly so that they are not confused and
> it's clear what is being asked.
OK.
> Plus, the patch forced every fs using
> page_offset() to suddenly check PageHuge(), which is a function call.
OK, PageHuge() check should be done only in vm code.
> How about
>
> o page_offset() for use by filesystems, based on page->index
And many drivers code and network code use this, so I shouldn't have
touched this :(
> o page_virt_pgoff() for use on virtual memory math, based on
> page->index and respecting PageHuge()
This is what current code does with page_to_pgoff().
>
> o page_mapping_pgoff() for use by swapping and when working on
> mappings that could be swapper_space.
page_file_offset() does this.
So it seems to me OK to just rename them with enough comments.
Thanks,
Naoya Horiguchi
> o page_mapping_offset() likewise, just in bytes
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
prev parent reply other threads:[~2014-07-29 1:04 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-01 14:46 [PATCH] rmap: fix pgoff calculation to handle hugepage correctly Naoya Horiguchi
2014-07-01 17:42 ` Rik van Riel
2014-07-01 18:07 ` Kirill A. Shutemov
2014-07-01 18:50 ` Naoya Horiguchi
2014-07-01 20:15 ` Kirill A. Shutemov
2014-07-02 4:30 ` Naoya Horiguchi
2014-07-03 11:41 ` Kirill A. Shutemov
2014-07-07 19:39 ` Andrew Morton
2014-07-15 16:41 ` [PATCH -mm] mm: refactor page index/offset getters Naoya Horiguchi
2014-07-23 21:39 ` Andrew Morton
2014-07-23 21:45 ` Naoya Horiguchi
2014-07-28 20:29 ` Johannes Weiner
2014-07-29 0:42 ` Naoya Horiguchi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140729004246.GA5822@nhori.redhat.com \
--to=n-horiguchi@ah.jp.nec.com \
--cc=akpm@linux-foundation.org \
--cc=dhillf@gmail.com \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=kirill@shutemov.name \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nao.horiguchi@gmail.com \
--cc=riel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox