Skip to contentSkip to conversation

mm, thp: adjust conditions when we can reuse the page on WP fault

PATCH Hillf Danton 2 participants 2 messages Apr 28, 2015 1 message not in the archive Memory management

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 11 lines

With new refcounting we will be able map the same compound page with PTEs and PMDs. It requires adjustment to conditions when we can reuse the page on write-protection fault.

For PTE fault we can't reuse the page if it's part of huge page.

For PMD we can only reuse the page if nobody else maps the huge page or it's part. We can do it by checking page_mapcount() on each sub-page, but it's expensive.

Quoted 7 lines

The cheaper way is to check page_count() to be equal 1: every mapcount takes page reference, so this way we can guarantee, that the PMD is the only mapping.

This approach can give false negative if somebody pinned the page, but that doesn't affect correctness.

Then we have to try more to allocate THP if pinned? Are we adding new cost?

Hillf

#2 lore raw
Quoted 15 lines · Hillf Danton
Quoted 15 lines

With new refcounting we will be able map the same compound page with PTEs and PMDs. It requires adjustment to conditions when we can reuse the page on write-protection fault.

For PTE fault we can't reuse the page if it's part of huge page.

For PMD we can only reuse the page if nobody else maps the huge page or it's part. We can do it by checking page_mapcount() on each sub-page, but it's expensive.

The cheaper way is to check page_count() to be equal 1: every mapcount takes page reference, so this way we can guarantee, that the PMD is the only mapping.

Quoted 5 lines
Quoted 3 lines

This approach can give false negative if somebody pinned the page, but that doesn't affect correctness.

Then we have to try more to allocate THP if pinned? Are we adding new cost?

Yes we do. But that shouldn't be often.

Alternatively, we could iterate over all sub-pages and check their mapcount.

Signature · 7 lines
 Kirill A. Shutemov

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>