linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Chris Li <chrisl@kernel.org>
To: Baoquan He <bhe@redhat.com>
Cc: linux-mm@kvack.org, akpm@linux-foundation.org,
	kasong@tencent.com,  baohua@kernel.org, nphamcs@gmail.com,
	shikemeng@huaweicloud.com
Subject: Re: [PATCH 3/3] mm/swap: remove unneeded swap_active_head
Date: Thu, 2 Oct 2025 01:33:43 -0700	[thread overview]
Message-ID: <CACePvbWD4BUSqcJkdQdZmXFNjDtGQdEkjUmeHVh0QT3_XTvKEA@mail.gmail.com> (raw)
In-Reply-To: <20251001043436.41338-4-bhe@redhat.com>

On Tue, Sep 30, 2025 at 9:35 PM Baoquan He <bhe@redhat.com> wrote:
>
> There's no user of swap_active_head, remove it now.

Removing swap_active_head for 32 swap devices is less than 1K memory
saving? Only the power off code uses it now so the reduction of
complexity is very limited as well. I consider this series payout is
pretty small but has considerable review overhead.

Another consideration is that swap.tiers is possible to use the
swap_active_head to find swap devices belonging to a tier, because the
swap tier is a range of priority. We can revisit it after the initial
implementation for swap.tiers.

Let's hold off the removal of swap_active_head a bit.

Chris

>
> Signed-off-by: Baoquan He <bhe@redhat.com>
> ---
>  include/linux/swap.h |  1 -
>  mm/swapfile.c        | 20 ++++----------------
>  2 files changed, 4 insertions(+), 17 deletions(-)
>
> diff --git a/include/linux/swap.h b/include/linux/swap.h
> index 5b7a39b20f58..dfc0cc9fc166 100644
> --- a/include/linux/swap.h
> +++ b/include/linux/swap.h
> @@ -296,7 +296,6 @@ struct swap_info_struct {
>         struct percpu_ref users;        /* indicate and keep swap device valid. */
>         unsigned long   flags;          /* SWP_USED etc: see above */
>         signed short    prio;           /* swap priority of this type */
> -       struct plist_node list;         /* entry in swap_active_head */
>         signed char     type;           /* strange name for an index */
>         unsigned int    max;            /* extent of the swap_map */
>         unsigned char *swap_map;        /* vmalloc'ed array of usage counts */
> diff --git a/mm/swapfile.c b/mm/swapfile.c
> index 18b52cc20749..80b34dc86a95 100644
> --- a/mm/swapfile.c
> +++ b/mm/swapfile.c
> @@ -85,17 +85,10 @@ static const char Bad_offset[] = "Bad swap offset entry ";
>  static const char Unused_offset[] = "Unused swap offset entry ";
>
>  /*
> - * all active swap_info_structs
> - * protected with swap_lock, and ordered by priority.
> - */
> -static PLIST_HEAD(swap_active_head);
> -
> -/*
> - * all available (active, not full) swap_info_structs
> - * protected with swap_avail_lock, ordered by priority.
> - * This is used by folio_alloc_swap() instead of swap_active_head
> - * because swap_active_head includes all swap_info_structs,
> - * but folio_alloc_swap() doesn't need to look at full ones.
> + * All available (active, not full) swap_info_structs protected with
> + * swap_avail_lock, ordered by priority.
> + * This is used by folio_alloc_swap() because folio_alloc_swap()
> + * doesn't need to look at full ones.
>   * This uses its own lock instead of swap_lock because when a
>   * swap_info_struct changes between not-full/full, it needs to
>   * add/remove itself to/from this list, but the swap_info_struct->lock
> @@ -2539,7 +2532,6 @@ static void setup_swap_info(struct swap_info_struct *si, int prio,
>          * the plist prio is negated because plist ordering is
>          * low-to-high, while swap ordering is high-to-low
>          */
> -       si->list.prio = -si->prio;
>         si->avail_list.prio = -si->prio;
>         si->swap_map = swap_map;
>         si->cluster_info = cluster_info;
> @@ -2553,8 +2545,6 @@ static void _enable_swap_info(struct swap_info_struct *si)
>
>         assert_spin_locked(&swap_lock);
>
> -       plist_add(&si->list, &swap_active_head);
> -
>         /* Add back to available list */
>         add_to_avail_list(si, true);
>  }
> @@ -2682,7 +2672,6 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
>         }
>         spin_lock(&p->lock);
>         del_from_avail_list(p, true);
> -       plist_del(&p->list, &swap_active_head);
>         atomic_long_sub(p->pages, &nr_swap_pages);
>         total_swap_pages -= p->pages;
>         spin_unlock(&p->lock);
> @@ -2958,7 +2947,6 @@ static struct swap_info_struct *alloc_swap_info(void)
>                  */
>         }
>         p->swap_extent_root = RB_ROOT;
> -       plist_node_init(&p->list, 0);
>         plist_node_init(&p->avail_list, 0);
>         p->flags = SWP_USED;
>         spin_unlock(&swap_lock);
> --
> 2.41.0
>


  reply	other threads:[~2025-10-02  8:33 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-01  4:34 [PATCH 0/3] mm/swap: remove plist swap_active_head Baoquan He
2025-10-01  4:34 ` [PATCH 1/3] mm/swapfile.c: remove __has_usable_swap() Baoquan He
2025-10-01  4:34 ` [PATCH 2/3] mm/swapfile.c: use swap_info[] to find the swap device Baoquan He
2025-10-02 15:59   ` Chris Li
2025-10-03  2:38     ` Baoquan He
2025-10-03  4:50       ` Chris Li
2025-10-03  5:29         ` Baoquan He
2025-10-01  4:34 ` [PATCH 3/3] mm/swap: remove unneeded swap_active_head Baoquan He
2025-10-02  8:33   ` Chris Li [this message]
2025-10-02 13:42     ` Baoquan He
2025-10-09  3:26   ` Andrew Morton
2025-10-09  7:47     ` Baoquan He
2025-10-09 17:09       ` Chris Li
2025-10-10  2:56         ` YoungJun Park
2025-10-10  1:28       ` Andrew Morton
2025-10-10  2:14         ` Baoquan He
2025-10-10  2:34           ` Chris Li
2025-10-10  2:33         ` Chris Li
2025-10-10  2:52         ` Chris Li
2025-10-02  6:04 ` [PATCH 0/3] mm/swap: remove plist swap_active_head Chris Li
2025-10-02 13:09   ` Baoquan He
2025-10-02 16:23     ` Chris Li

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=CACePvbWD4BUSqcJkdQdZmXFNjDtGQdEkjUmeHVh0QT3_XTvKEA@mail.gmail.com \
    --to=chrisl@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=baohua@kernel.org \
    --cc=bhe@redhat.com \
    --cc=kasong@tencent.com \
    --cc=linux-mm@kvack.org \
    --cc=nphamcs@gmail.com \
    --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