z3fold: make pages_nr atomic
PATCH 1/1 z3fold: make pages_nr atomic
This patch converts pages_nr per-pool counter to atomic64_t.
--- mm/z3fold.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-)
mm/z3fold.c +9 -11
@@ -80,7 +80,7 @@ struct z3fold_pool {struct list_head unbuddied[NCHUNKS ];struct list_head buddied;struct list_head lru; -u64 pages_nr; +atomic64_t pages_nr;const struct z3fold_ops *ops;struct zpool *zpool;const struct zpool_ops *zpool_ops;
@@ -234,7 +234,7 @@ static struct z3fold_pool *z3fold_create_pool(gfp_t gfp,INIT_LIST_HEAD (&pool->unbuddied[i]);INIT_LIST_HEAD (&pool->buddied);INIT_LIST_HEAD (&pool->lru); - pool->pages_nr =0 ; +atomic64_set (&pool->pages_nr,0 ); pool->ops = ops;return pool; }
@@ -346,7 +346,7 @@ static int z3fold_alloc(struct z3fold_pool *pool, size_t size, gfp_t gfp,if (!page)return -ENOMEM ;spin_lock (&pool->lock); - pool->pages_nr++; +atomic64_inc (&pool->pages_nr); zhdr =init_z3fold_page (page);if (bud ==HEADLESS ) {
@@ -439,10 +439,9 @@ static void z3fold_free(struct z3fold_pool *pool, unsigned long handle)return ; } -if (bud !=HEADLESS ) { -/* Remove from existing buddy list */ +/* Remove from existing buddy list */ +if (bud !=HEADLESS )list_del (&zhdr->buddy); - } if (bud == HEADLESS || (zhdr->first_chunks == 0 && zhdr->middle_chunks == 0 &&
@@ -451,7 +451,7 @@ static void z3fold_free(struct z3fold_pool *pool, unsigned long handle)list_del (&page->lru);clear_bit (PAGE_HEADLESS , &page->private);free_z3fold_page (zhdr); - pool->pages_nr--; +atomic64_dec (&pool->pages_nr); }else {z3fold_compact_page (zhdr);/* Add to the unbuddied list */
@@ -569,7 +569,7 @@ static int z3fold_reclaim_page(struct z3fold_pool *pool, unsigned int retries)*/ clear_bit (PAGE_HEADLESS , &page->private);free_z3fold_page (zhdr); - pool->pages_nr--; +atomic64_dec (&pool->pages_nr);spin_unlock (&pool->lock);return 0 ; }else if (!test_bit (PAGE_HEADLESS , &page->private)) {
@@ -672,12 +672,11 @@ static void z3fold_unmap(struct z3fold_pool *pool, unsigned long handle)* z3fold_get_pool_size() - gets the z3fold pool size in pages * @pool: pool whose size is being queried * -* Returns: size in pages of the given pool. The pool lock need not be -* taken to access pages_nr. +* Returns: size in pages of the given pool. */ static u64 z3fold_get_pool_size (struct z3fold_pool *pool) { -return pool->pages_nr; +return atomic64_read (&pool->pages_nr); }/*****************
Signature · 7 lines
2.4.2 -- 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>
Andrew Morton
maintainerQuoted 1 line · On Thu, 3 Nov 2016 22:00:58 +0100 Vitaly Wool <[email protected]> wrote:
This patch converts
pages_nrper-pool counter toatomic64_t.
Which is slower.
Presumably there is a reason for making this change. This reason should be described in the changelog.
--
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>
Quoted 8 lines · Andrew Morton
Quoted 1 line · On Thu, 3 Nov 2016 22:00:58 +0100 Vitaly Wool <[email protected]> wrote:
This patch converts
pages_nrper-pool counter toatomic64_t.Which is slower.
Presumably there is a reason for making this change. This reason should be described in the changelog.
The reason [which I thought was somewhat obvious :) ] is that there won't be a need to take a per-pool lock to read or modify that counter.
Best regards,
Vitaly
--
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>
Andrew Morton
maintainerQuoted 6 lines · On Thu, 3 Nov 2016 22:24:07 +0100 Vitaly Wool <[email protected]> wrote:
Quoted 4 lines · Andrew Morton
Quoted 1 line · On Thu, 3 Nov 2016 22:00:58 +0100 Vitaly Wool <[email protected]> wrote:
This patch converts
pages_nrper-pool counter toatomic64_t.
Quoted 8 lines
Quoted 4 lines
Which is slower.
Presumably there is a reason for making this change. This reason should be described in the changelog.
The reason [which I thought was somewhat obvious :) ] is that there won't be a need to take a per-pool lock to read or modify that counter.
But the patch didn't change the locking. And as far as I can tell, neither does "z3fold: extend compaction function".
--
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>
Quoted 13 lines · Andrew Morton
Quoted 11 lines · On Thu, 3 Nov 2016 22:24:07 +0100 Vitaly Wool <[email protected]> wrote:
Quoted 8 lines · Andrew Morton
Quoted 1 line · On Thu, 3 Nov 2016 22:00:58 +0100 Vitaly Wool <[email protected]> wrote:
This patch converts
pages_nrper-pool counter toatomic64_t.Which is slower.
Presumably there is a reason for making this change. This reason should be described in the changelog.
Quoted 6 lines
Quoted 3 lines
The reason [which I thought was somewhat obvious :) ] is that there won't be a need to take a per-pool lock to read or modify that counter.
But the patch didn't change the locking. And as far as I can tell, neither does "z3fold: extend compaction function".
Right. I'll come up with the locking rework shortly, but it will be a RFC so I wanted to send it separately.
~vitaly
--
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>
Dan Streetman
Acked-byQuoted 19 lines · Vitaly Wool
Quoted 17 lines · Andrew Morton
Quoted 14 lines · On Thu, 3 Nov 2016 22:24:07 +0100 Vitaly Wool <[email protected]> wrote:
Quoted 8 lines · Andrew Morton
Quoted 1 line · On Thu, 3 Nov 2016 22:00:58 +0100 Vitaly Wool <[email protected]> wrote:
This patch converts
pages_nrper-pool counter toatomic64_t.Which is slower.
Presumably there is a reason for making this change. This reason should be described in the changelog.
The reason [which I thought was somewhat obvious :) ] is that there won't be a need to take a per-pool lock to read or modify that counter.
Quoted 5 lines
Quoted 2 lines
But the patch didn't change the locking. And as far as I can tell, neither does "z3fold: extend compaction function".
Right. I'll come up with the locking rework shortly, but it will be a RFC so I wanted to send it separately.
this is still in mmotm, and it seems the later patches rely on it, so while i agree that the changelog should be clearer about why it's needed, the change itself looks ok.
Quoted 2 lines
~vitaly
--
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>