From: Kairui Song <ryncsn@gmail.com>
To: Kemeng Shi <shikemeng@huaweicloud.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 4/6] mm, swap: remove setting SWAP_MAP_BAD for discard cluster
Date: Mon, 24 Feb 2025 09:24:33 +0800 [thread overview]
Message-ID: <CAMgjq7A7EBzGXrCvEwXuyg0cqF-imy9-=km6pYoLQ3WebvBxYw@mail.gmail.com> (raw)
In-Reply-To: <20250222160850.505274-5-shikemeng@huaweicloud.com>
[-- Attachment #1: Type: text/plain, Size: 2037 bytes --]
On Sat, Feb 22, 2025 at 3:12 PM Kemeng Shi <shikemeng@huaweicloud.com>
wrote:
>
> Before alloc from a cluster, we will aqcuire cluster's lock and make
> sure it is usable by cluster_is_usable(), so there is no need to
> set SWAP_MAP_BAD for cluster to be discarded.
>
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
> ---
> mm/swapfile.c | 11 -----------
> 1 file changed, 11 deletions(-)
>
> diff --git a/mm/swapfile.c b/mm/swapfile.c
> index fc45b9d56639..c640f77a464a 100644
> --- a/mm/swapfile.c
> +++ b/mm/swapfile.c
> @@ -479,15 +479,6 @@ static void move_cluster(struct swap_info_struct *si,
> static void swap_cluster_schedule_discard(struct swap_info_struct *si,
> struct swap_cluster_info *ci)
> {
> - unsigned int idx = cluster_index(si, ci);
> - /*
> - * If scan_swap_map_slots() can't find a free cluster, it will
check
> - * si->swap_map directly. To make sure the discarding cluster
isn't
> - * taken by scan_swap_map_slots(), mark the swap entries bad
(occupied).
> - * It will be cleared after discard
> - */
> - memset(si->swap_map + idx * SWAPFILE_CLUSTER,
> - SWAP_MAP_BAD, SWAPFILE_CLUSTER);
> VM_BUG_ON(ci->flags == CLUSTER_FLAG_FREE);
> move_cluster(si, ci, &si->discard_clusters, CLUSTER_FLAG_DISCARD);
> schedule_work(&si->discard_work);
> @@ -571,8 +562,6 @@ static bool swap_do_scheduled_discard(struct
swap_info_struct *si)
> * return the cluster to allocation list.
> */
> ci->flags = CLUSTER_FLAG_NONE;
> - memset(si->swap_map + idx * SWAPFILE_CLUSTER,
> - 0, SWAPFILE_CLUSTER);
> __free_cluster(si, ci);
> spin_unlock(&ci->lock);
> ret = true;
Good, I wanted to do this some time ago, but forgot about this while busy
with other things.
Reviewed-by: Kairui Song <kasong@tencent.com>
[-- Attachment #2: Type: text/html, Size: 2795 bytes --]
next prev parent reply other threads:[~2025-02-24 1:24 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-22 16:08 [PATCH 0/6] Some random fixes and cleanups to mm/swapfile.c Kemeng Shi
2025-02-22 16:08 ` [PATCH 1/6] mm: swap: avoid losting cluster in swap_reclaim_full_clusters() Kemeng Shi
2025-02-22 17:19 ` Kairui Song
2025-02-24 1:17 ` Kemeng Shi
2025-02-22 16:08 ` [PATCH 2/6] mm: swap: use correct step in loop to wait all clusters in wait_for_allocation() Kemeng Shi
2025-02-22 17:32 ` Kairui Song
2025-02-22 16:08 ` [PATCH 3/6] mm, swap: avoid BUG_ON in relocate_cluster() Kemeng Shi
2025-02-22 18:43 ` Kairui Song
2025-02-22 16:08 ` [PATCH 4/6] mm, swap: remove setting SWAP_MAP_BAD for discard cluster Kemeng Shi
2025-02-24 1:24 ` Kairui Song [this message]
2025-02-22 16:08 ` [PATCH 5/6] mm, swap: correct comment in swap_usage_sub() Kemeng Shi
2025-02-22 16:08 ` [PATCH 6/6] mm: swap: remove stale comment of swap_reclaim_full_clusters() Kemeng Shi
2025-02-23 1:44 ` [PATCH 0/6] Some random fixes and cleanups to mm/swapfile.c Andrew Morton
2025-02-24 1:27 ` Kemeng Shi
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='CAMgjq7A7EBzGXrCvEwXuyg0cqF-imy9-=km6pYoLQ3WebvBxYw@mail.gmail.com' \
--to=ryncsn@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=shikemeng@huaweicloud.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