Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
forked fromtorvalds/linux

Commit76e32a2

Browse files
vwooltorvalds
authored andcommitted
z3fold: fix page locking in z3fold_alloc()
Stress testing of the current z3fold implementation on a 8-core systemrevealed it was possible that a z3fold page deleted from its unbuddiedlist in z3fold_alloc() would be put on another unbuddied list byz3fold_free() while z3fold_alloc() is still processing it. This hasbeen introduced with commit5a27aa8 ("z3fold: add kref refcounting")due to the removal of special handling of a z3fold page not on any listin z3fold_free().To fix this, the z3fold page lock should be taken in z3fold_alloc()before the pool lock is released. To avoid deadlocking, we just try tolock the page as soon as we get a hold of it, and if trylock fails, wedrop this page and take the next one.Signed-off-by: Vitaly Wool <vitalywool@gmail.com>Cc: Dan Streetman <ddstreet@ieee.org>Cc: <Oleksiy.Avramchenko@sony.com>Signed-off-by: Andrew Morton <akpm@linux-foundation.org>Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent2760078 commit76e32a2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

‎mm/z3fold.c‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ static inline void z3fold_page_lock(struct z3fold_header *zhdr)
185185
spin_lock(&zhdr->page_lock);
186186
}
187187

188+
/* Try to lock a z3fold page */
189+
staticinlineintz3fold_page_trylock(structz3fold_header*zhdr)
190+
{
191+
returnspin_trylock(&zhdr->page_lock);
192+
}
193+
188194
/* Unlock a z3fold page */
189195
staticinlinevoidz3fold_page_unlock(structz3fold_header*zhdr)
190196
{
@@ -385,7 +391,7 @@ static int z3fold_alloc(struct z3fold_pool *pool, size_t size, gfp_t gfp,
385391
spin_lock(&pool->lock);
386392
zhdr=list_first_entry_or_null(&pool->unbuddied[i],
387393
structz3fold_header,buddy);
388-
if (!zhdr) {
394+
if (!zhdr|| !z3fold_page_trylock(zhdr)) {
389395
spin_unlock(&pool->lock);
390396
continue;
391397
}
@@ -394,7 +400,6 @@ static int z3fold_alloc(struct z3fold_pool *pool, size_t size, gfp_t gfp,
394400
spin_unlock(&pool->lock);
395401

396402
page=virt_to_page(zhdr);
397-
z3fold_page_lock(zhdr);
398403
if (zhdr->first_chunks==0) {
399404
if (zhdr->middle_chunks!=0&&
400405
chunks >=zhdr->start_middle)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp