From: Miaohe Lin <linmiaohe@huawei.com>
To: <akpm@linux-foundation.org>
Cc: <vitalywool@gmail.com>, <linux-kernel@vger.kernel.org>,
<linux-mm@kvack.org>, <linmiaohe@huawei.com>
Subject: [PATCH 4/6] mm/z3fold: remove unused function handle_to_z3fold_header()
Date: Sat, 19 Jun 2021 17:31:49 +0800 [thread overview]
Message-ID: <20210619093151.1492174-5-linmiaohe@huawei.com> (raw)
In-Reply-To: <20210619093151.1492174-1-linmiaohe@huawei.com>
handle_to_z3fold_header() is unused now. So we can remove it. As a result,
get_z3fold_header() becomes the only caller of __get_z3fold_header() and
the argument lock is always true. Therefore we could further fold the
__get_z3fold_header() into get_z3fold_header() with lock = true.
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
mm/z3fold.c | 22 ++++------------------
1 file changed, 4 insertions(+), 18 deletions(-)
diff --git a/mm/z3fold.c b/mm/z3fold.c
index 988d57c143fd..bab08c08bf19 100644
--- a/mm/z3fold.c
+++ b/mm/z3fold.c
@@ -255,9 +255,8 @@ static inline void z3fold_page_unlock(struct z3fold_header *zhdr)
spin_unlock(&zhdr->page_lock);
}
-
-static inline struct z3fold_header *__get_z3fold_header(unsigned long handle,
- bool lock)
+/* return locked z3fold page if it's not headless */
+static inline struct z3fold_header *get_z3fold_header(unsigned long handle)
{
struct z3fold_buddy_slots *slots;
struct z3fold_header *zhdr;
@@ -271,13 +270,12 @@ static inline struct z3fold_header *__get_z3fold_header(unsigned long handle,
read_lock(&slots->lock);
addr = *(unsigned long *)handle;
zhdr = (struct z3fold_header *)(addr & PAGE_MASK);
- if (lock)
- locked = z3fold_page_trylock(zhdr);
+ locked = z3fold_page_trylock(zhdr);
read_unlock(&slots->lock);
if (locked)
break;
cpu_relax();
- } while (lock);
+ } while (true);
} else {
zhdr = (struct z3fold_header *)(handle & PAGE_MASK);
}
@@ -285,18 +283,6 @@ static inline struct z3fold_header *__get_z3fold_header(unsigned long handle,
return zhdr;
}
-/* Returns the z3fold page where a given handle is stored */
-static inline struct z3fold_header *handle_to_z3fold_header(unsigned long h)
-{
- return __get_z3fold_header(h, false);
-}
-
-/* return locked z3fold page if it's not headless */
-static inline struct z3fold_header *get_z3fold_header(unsigned long h)
-{
- return __get_z3fold_header(h, true);
-}
-
static inline void put_z3fold_header(struct z3fold_header *zhdr)
{
struct page *page = virt_to_page(zhdr);
--
2.23.0
next prev parent reply other threads:[~2021-06-19 9:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-19 9:31 [PATCH 0/6] Cleanup and fixup for z3fold Miaohe Lin
2021-06-19 9:31 ` [PATCH 1/6] mm/z3fold: define macro NCHUNKS as TOTAL_CHUNKS - ZHDR_CHUNKS Miaohe Lin
2021-06-19 9:31 ` [PATCH 2/6] mm/z3fold: avoid possible underflow in z3fold_alloc() Miaohe Lin
2021-06-19 9:31 ` [PATCH 3/6] mm/z3fold: remove magic number in z3fold_create_pool() Miaohe Lin
2021-06-19 9:31 ` Miaohe Lin [this message]
2021-06-19 9:31 ` [PATCH 5/6] mm/z3fold: fix potential memory leak in z3fold_destroy_pool() Miaohe Lin
2021-06-19 9:31 ` [PATCH 6/6] mm/z3fold: use release_z3fold_page_locked() to release locked z3fold page Miaohe Lin
2021-06-20 0:26 ` Hillf Danton
2021-06-22 13:49 ` Miaohe Lin
2021-06-21 8:00 ` [PATCH 0/6] Cleanup and fixup for z3fold Vitaly Wool
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=20210619093151.1492174-5-linmiaohe@huawei.com \
--to=linmiaohe@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=vitalywool@gmail.com \
/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