diff options
| author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2021-07-04 23:05:31 -0700 |
|---|---|---|
| committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2021-07-04 23:05:31 -0700 |
| commit | 818b26588994d9d95743fca0a427f08ec6c1c41d (patch) | |
| tree | 870d9abed0e43b82257350a93e6517816815cd6c /mm/z3fold.c | |
| parent | 45a4b68354ffccbc9ca71027bd34754ca24f5183 (diff) | |
| parent | f8f84af5da9ee04ef1d271528656dac42a090d00 (diff) | |
| download | net-818b26588994d9d95743fca0a427f08ec6c1c41d.tar.gz | |
Merge branch 'next' into for-linus
Prepare input updates for 5.14 merge window.
Diffstat (limited to 'mm/z3fold.c')
| -rw-r--r-- | mm/z3fold.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/mm/z3fold.c b/mm/z3fold.c index b5dafa7e44e429..9d889ad2bb8693 100644 --- a/mm/z3fold.c +++ b/mm/z3fold.c @@ -1346,8 +1346,22 @@ static int z3fold_reclaim_page(struct z3fold_pool *pool, unsigned int retries) page = list_entry(pos, struct page, lru); zhdr = page_address(page); - if (test_bit(PAGE_HEADLESS, &page->private)) + if (test_bit(PAGE_HEADLESS, &page->private)) { + /* + * For non-headless pages, we wait to do this + * until we have the page lock to avoid racing + * with __z3fold_alloc(). Headless pages don't + * have a lock (and __z3fold_alloc() will never + * see them), but we still need to test and set + * PAGE_CLAIMED to avoid racing with + * z3fold_free(), so just do it now before + * leaving the loop. + */ + if (test_and_set_bit(PAGE_CLAIMED, &page->private)) + continue; + break; + } if (kref_get_unless_zero(&zhdr->refcount) == 0) { zhdr = NULL; |
