mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 11:41:38 -04:00
page-flags: define PG_locked behavior on compound pages
lock_page() must operate on the whole compound page. It doesn't make much sense to lock part of compound page. Change code to use head page's PG_locked, if tail page is passed. This patch also gets rid of custom helper functions -- __set_page_locked() and __clear_page_locked(). They are replaced with helpers generated by __SETPAGEFLAG/__CLEARPAGEFLAG. Tail pages to these helper would trigger VM_BUG_ON(). SLUB uses PG_locked as a bit spin locked. IIUC, tail pages should never appear there. VM_BUG_ON() is added to make sure that this assumption is correct. [[email protected]: fix fs/cifs/file.c] Signed-off-by: Kirill A. Shutemov <[email protected]> Cc: Andrea Arcangeli <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Vlastimil Babka <[email protected]> Cc: Christoph Lameter <[email protected]> Cc: Naoya Horiguchi <[email protected]> Cc: Steve Capper <[email protected]> Cc: "Aneesh Kumar K.V" <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Jerome Marchand <[email protected]> Cc: Jérôme Glisse <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
95ad97554a
commit
48c935ad88
11 changed files with 32 additions and 36 deletions
15
mm/filemap.c
15
mm/filemap.c
|
|
@ -682,11 +682,11 @@ int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
|
|||
void *shadow = NULL;
|
||||
int ret;
|
||||
|
||||
__set_page_locked(page);
|
||||
__SetPageLocked(page);
|
||||
ret = __add_to_page_cache_locked(page, mapping, offset,
|
||||
gfp_mask, &shadow);
|
||||
if (unlikely(ret))
|
||||
__clear_page_locked(page);
|
||||
__ClearPageLocked(page);
|
||||
else {
|
||||
/*
|
||||
* The page might have been evicted from cache only
|
||||
|
|
@ -809,6 +809,7 @@ EXPORT_SYMBOL_GPL(add_page_wait_queue);
|
|||
*/
|
||||
void unlock_page(struct page *page)
|
||||
{
|
||||
page = compound_head(page);
|
||||
VM_BUG_ON_PAGE(!PageLocked(page), page);
|
||||
clear_bit_unlock(PG_locked, &page->flags);
|
||||
smp_mb__after_atomic();
|
||||
|
|
@ -873,18 +874,20 @@ EXPORT_SYMBOL_GPL(page_endio);
|
|||
*/
|
||||
void __lock_page(struct page *page)
|
||||
{
|
||||
DEFINE_WAIT_BIT(wait, &page->flags, PG_locked);
|
||||
struct page *page_head = compound_head(page);
|
||||
DEFINE_WAIT_BIT(wait, &page_head->flags, PG_locked);
|
||||
|
||||
__wait_on_bit_lock(page_waitqueue(page), &wait, bit_wait_io,
|
||||
__wait_on_bit_lock(page_waitqueue(page_head), &wait, bit_wait_io,
|
||||
TASK_UNINTERRUPTIBLE);
|
||||
}
|
||||
EXPORT_SYMBOL(__lock_page);
|
||||
|
||||
int __lock_page_killable(struct page *page)
|
||||
{
|
||||
DEFINE_WAIT_BIT(wait, &page->flags, PG_locked);
|
||||
struct page *page_head = compound_head(page);
|
||||
DEFINE_WAIT_BIT(wait, &page_head->flags, PG_locked);
|
||||
|
||||
return __wait_on_bit_lock(page_waitqueue(page), &wait,
|
||||
return __wait_on_bit_lock(page_waitqueue(page_head), &wait,
|
||||
bit_wait_io, TASK_KILLABLE);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(__lock_page_killable);
|
||||
|
|
|
|||
Loading…
Reference in a new issue