From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Qian Cai <cai@lca.pw>
Cc: Matthew Wilcox <willy@infradead.org>,
Huang Ying <ying.huang@intel.com>,
linux-mm@kvack.org
Subject: Re: page cache: Store only head pages in i_pages
Date: Thu, 4 Apr 2019 16:45:54 +0300 [thread overview]
Message-ID: <20190404134553.vuvhgmghlkiw2hgl@kshutemo-mobl1> (raw)
In-Reply-To: <1554383410.26196.39.camel@lca.pw>
On Thu, Apr 04, 2019 at 09:10:10AM -0400, Qian Cai wrote:
> On Mon, 2019-04-01 at 12:27 +0300, Kirill A. Shutemov wrote:
> > What about patch like this? (completely untested)
> >
> > diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
> > index f939e004c5d1..e3b9bf843dcb 100644
> > --- a/include/linux/pagemap.h
> > +++ b/include/linux/pagemap.h
> > @@ -335,12 +335,12 @@ static inline struct page *grab_cache_page_nowait(struct
> > address_space *mapping,
> >
> > static inline struct page *find_subpage(struct page *page, pgoff_t offset)
> > {
> > - unsigned long index = page_index(page);
> > + unsigned long mask;
> >
> > VM_BUG_ON_PAGE(PageTail(page), page);
> > - VM_BUG_ON_PAGE(index > offset, page);
> > - VM_BUG_ON_PAGE(index + (1 << compound_order(page)) <= offset, page);
> > - return page - index + offset;
> > +
> > + mask = (1UL << compound_order(page)) - 1;
> > + return page + (offset & mask);
> > }
> >
> > struct page *find_get_entry(struct address_space *mapping, pgoff_t offset);
>
> No, this then leads to a panic below by LTP hugemmap05. Still reverting the
> whole "mm: page cache: store only head pages in i_pages" commit fixed the
> problem.
Ughh... hugetlb stores pages in page cache differently.
What about this:
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index f939e004c5d1..2e8438a1216a 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -335,12 +335,15 @@ static inline struct page *grab_cache_page_nowait(struct address_space *mapping,
static inline struct page *find_subpage(struct page *page, pgoff_t offset)
{
- unsigned long index = page_index(page);
+ unsigned long mask;
+
+ if (PageHuge(page))
+ return page;
VM_BUG_ON_PAGE(PageTail(page), page);
- VM_BUG_ON_PAGE(index > offset, page);
- VM_BUG_ON_PAGE(index + (1 << compound_order(page)) <= offset, page);
- return page - index + offset;
+
+ mask = (1UL << compound_order(page)) - 1;
+ return page + (offset & mask);
}
struct page *find_get_entry(struct address_space *mapping, pgoff_t offset);
--
Kirill A. Shutemov
next prev parent reply other threads:[~2019-04-04 13:46 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1553285568.26196.24.camel@lca.pw>
2019-03-23 3:38 ` Matthew Wilcox
2019-03-23 23:50 ` Qian Cai
2019-03-24 2:06 ` Matthew Wilcox
2019-03-24 2:52 ` Qian Cai
2019-03-24 3:04 ` Matthew Wilcox
2019-03-24 15:42 ` Qian Cai
2019-03-27 10:48 ` William Kucharski
2019-03-27 11:50 ` Matthew Wilcox
2019-03-29 1:43 ` Qian Cai
2019-03-29 19:59 ` Matthew Wilcox
2019-03-29 21:25 ` Qian Cai
2019-03-30 3:04 ` Matthew Wilcox
2019-03-30 14:10 ` Matthew Wilcox
2019-03-31 3:23 ` Matthew Wilcox
2019-04-01 9:18 ` Kirill A. Shutemov
2019-04-01 9:27 ` Kirill A. Shutemov
2019-04-04 13:10 ` Qian Cai
2019-04-04 13:45 ` Kirill A. Shutemov [this message]
2019-04-04 21:28 ` Qian Cai
2019-04-05 13:37 ` Kirill A. Shutemov
2019-04-05 13:51 ` Matthew Wilcox
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=20190404134553.vuvhgmghlkiw2hgl@kshutemo-mobl1 \
--to=kirill@shutemov.name \
--cc=cai@lca.pw \
--cc=linux-mm@kvack.org \
--cc=willy@infradead.org \
--cc=ying.huang@intel.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