]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/zsmalloc.c: combine two atomic ops in zs_pool_dec_isolated()
authorMiaohe Lin <linmiaohe@huawei.com>
Mon, 23 Aug 2021 23:59:44 +0000 (09:59 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 25 Aug 2021 23:34:27 +0000 (09:34 +1000)
atomic_long_dec_and_test() is equivalent to atomic_long_dec() and
atomic_long_read() == 0.  Use it to make code more succinct.

Link: https://lkml.kernel.org/r/20210624123930.1769093-3-linmiaohe@huawei.com
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
mm/zsmalloc.c

index b897ce3b399a1019a7f62d00fff434c685a2794d..3e713ff6261eea648fe3562738f138fb9f165e03 100644 (file)
@@ -1828,14 +1828,13 @@ static void putback_zspage_deferred(struct zs_pool *pool,
 static inline void zs_pool_dec_isolated(struct zs_pool *pool)
 {
        VM_BUG_ON(atomic_long_read(&pool->isolated_pages) <= 0);
-       atomic_long_dec(&pool->isolated_pages);
        /*
         * Checking pool->destroying must happen after atomic_long_dec()
         * for pool->isolated_pages above. Paired with the smp_mb() in
         * zs_unregister_migration().
         */
        smp_mb__after_atomic();
-       if (atomic_long_read(&pool->isolated_pages) == 0 && pool->destroying)
+       if (atomic_long_dec_and_test(&pool->isolated_pages) && pool->destroying)
                wake_up_all(&pool->migration_wait);
 }