From: Miaohe Lin <linmiaohe@huawei.com>
To: <akpm@linux-foundation.org>, <minchan@kernel.org>, <ngupta@vflare.org>
Cc: <senozhatsky@chromium.org>, <linux-kernel@vger.kernel.org>,
<linux-mm@kvack.org>, <linmiaohe@huawei.com>
Subject: [PATCH 2/3] mm/zsmalloc.c: combine two atomic ops in zs_pool_dec_isolated()
Date: Thu, 24 Jun 2021 20:39:29 +0800 [thread overview]
Message-ID: <20210624123930.1769093-3-linmiaohe@huawei.com> (raw)
In-Reply-To: <20210624123930.1769093-1-linmiaohe@huawei.com>
atomic_long_dec_and_test() is equivalent to atomic_long_dec() and
atomic_long_read() == 0. Use it to make code more succinct.
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
mm/zsmalloc.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 1476289b619f..0b4b23740d78 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -1828,13 +1828,12 @@ 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);
/*
* There's no possibility of racing, since wait_for_isolated_drain()
* checks the isolated count under &class->lock after enqueuing
* on migration_wait.
*/
- 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);
}
--
2.23.0
next prev parent reply other threads:[~2021-06-24 12:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-24 12:39 [PATCH 0/3] Cleanup for zsmalloc Miaohe Lin
2021-06-24 12:39 ` [PATCH 1/3] mm/zsmalloc.c: remove confusing code in obj_free() Miaohe Lin
2021-06-24 12:39 ` Miaohe Lin [this message]
2021-06-25 5:01 ` [Phishing Risk] [External] [PATCH 2/3] mm/zsmalloc.c: combine two atomic ops in zs_pool_dec_isolated() Muchun Song
2021-06-25 6:32 ` Miaohe Lin
2021-06-25 7:29 ` Muchun Song
2021-06-25 8:46 ` Miaohe Lin
2021-06-25 9:32 ` Miaohe Lin
2021-06-25 10:40 ` Muchun Song
2021-07-01 2:43 ` Miaohe Lin
2021-06-24 12:39 ` [PATCH 3/3] mm/zsmalloc.c: improve readability for async_free_zspage() Miaohe Lin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210624123930.1769093-3-linmiaohe@huawei.com \
--to=linmiaohe@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=ngupta@vflare.org \
--cc=senozhatsky@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).