Hardy: Reinstate ZERO_PAGE optimization in 'get_user_pages()' and fix XIP

Bug #246663 reported by Tim Gardner
8
Affects Status Importance Assigned to Milestone
linux (Ubuntu)
Invalid
Undecided
Unassigned
Hardy
Fix Released
Medium
Unassigned

Bug Description

Upstream cherry-pick requested by Kees Cook.

KAMEZAWA Hiroyuki and Oleg Nesterov point out that since the commit 557ed1fa2620dc119adb86b34c614e152a629a80 ("remove ZERO_PAGE") removed the ZERO_PAGE from the VM mappings, any users of get_user_pages() will generally now populate the VM with real empty pages needlessly.

We used to get the ZERO_PAGE when we did the "handle_mm_fault()", but since fault handling no longer uses ZERO_PAGE for new anonymous pages, we now need to handle that special case in follow_page() instead.

In particular, the removal of ZERO_PAGE effectively removed the core file writing optimization where we would skip writing pages that had not been populated at all, and increased memory pressure a lot by allocating all those useless newly zeroed pages.

This reinstates the optimization by making the unmapped PTE case the same as for a non-existent page table, which already did this correctly.

While at it, this also fixes the XIP case for follow_page(), where the caller could not differentiate between the case of a page that simply could not be used (because it had no "struct page" associated with it) and a page that just wasn't mapped.

We do that by simply returning an error pointer for pages that could not be turned into a "struct page *". The error is arbitrarily picked to be EFAULT, since that was what get_user_pages() already used for the equivalent IO-mapped page case.

[ Also removed an impossible test for pte_offset_map_lock() failing: that's not how that function works ]

Revision history for this message
Tim Gardner (timg-tpi) wrote :
Changed in linux:
assignee: nobody → timg-tpi
importance: Undecided → Medium
milestone: none → ubuntu-8.04.2
status: New → Fix Committed
Revision history for this message
Tim Gardner (timg-tpi) wrote :

SRU Justification: see bug description

Steve Langasek (vorlon)
Changed in linux:
assignee: nobody → timg-tpi
importance: Undecided → Medium
milestone: none → ubuntu-8.04.2
status: New → In Progress
Revision history for this message
Steve Langasek (vorlon) wrote :

Accepted into -proposed, please test and give feedback here. Please see https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you in advance!

Changed in linux:
milestone: ubuntu-8.04.2 → none
status: In Progress → Fix Committed
Revision history for this message
Michael Rooney (mrooney) wrote :

I'll be happy to try it out, but I don't know what I should test for specifically, if anything. Let me know if I can help!

Revision history for this message
Martin Pitt (pitti) wrote :

linux 2.6.24-21 copied to hardy-updates.

Changed in linux:
status: Fix Committed → Fix Released
Tim Gardner (timg-tpi)
Changed in linux (Ubuntu):
assignee: Tim Gardner (timg-tpi) → nobody
importance: Medium → Undecided
milestone: ubuntu-8.04.2 → none
status: Fix Committed → Invalid
Changed in linux (Ubuntu Hardy):
assignee: Tim Gardner (timg-tpi) → nobody
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.