From: Baoquan He <bhe@redhat.com>
To: linux-mm@kvack.org
Cc: akpm@linux-foundation.org, chrisl@kernel.org, kasong@tencent.com,
baohua@kernel.org, shikemeng@huaweicloud.com, nphamcs@gmail.com
Subject: Re: [PATCH] mm/swapfile.c: select the swap device with default priority round robin
Date: Wed, 24 Sep 2025 18:23:58 +0800 [thread overview]
Message-ID: <aNPGvsQplsBeIMfu@MiWiFi-R3L-srv> (raw)
In-Reply-To: <20250924091746.146461-1-bhe@redhat.com>
On 09/24/25 at 05:17pm, Baoquan He wrote:
> Currently, on system with multiple swap devices, swap allocation will
> select one swap device according to priority. The swap device with the
> highest priority will be chosen to allocate firstly.
>
> People can specify a priority from 0 to 32767 when swapon a swap device,
> or the system will set it from -2 then downwards by default. Meanwhile,
> on NUMA system, the swap device with node_id will be considered first
> on that NUMA node of the node_id.
>
> In the current code, an array of plist, swap_avail_heads[nid], is used
> to organize swap devices on each NUMA node. For each NUMA node, there
> is a plist organizing all swap devices. The 'prio' value in the plist
> is the negated value of the device's priority due to plist being sorted
> from low to high. The swap device owning one node_id will be promoted to
> the front position on that NUMA node, then other swap devices are put in
> order of their default priority.
>
> E.g I got a system with 8 NUMA nodes, and I setup 4 zram partition as
> swap devices.
>
> Current behaviour:
> their priorities will be(note that -1 is skipped):
> NAME TYPE SIZE USED PRIO
> /dev/zram0 partition 16G 0B -2
> /dev/zram1 partition 16G 0B -3
> /dev/zram2 partition 16G 0B -4
> /dev/zram3 partition 16G 0B -5
>
> And their positions in the 8 swap_avail_lists[nid] will be:
> swap_avail_lists[0]: /* node 0's available swap device list */
> zram0 -> zram1 -> zram2 -> zram3
> prio:1 prio:3 prio:4 prio:5
> swap_avali_lists[1]: /* node 1's available swap device list */
> zram1 -> zram0 -> zram2 -> zram3
> prio:1 prio:2 prio:4 prio:5
> swap_avail_lists[2]: /* node 2's available swap device list */
> zram2 -> zram0 -> zram1 -> zram3
> prio:1 prio:2 prio:3 prio:5
> swap_avail_lists[3]: /* node 3's available swap device list */
> zram3 -> zram0 -> zram1 -> zram2
> prio:1 prio:2 prio:3 prio:4
> swap_avail_lists[4-7]: /* node 4,5,6,7's available swap device list */
> zram0 -> zram1 -> zram2 -> zram3
> prio:2 prio:3 prio:4 prio:5
By the way, when testing, I hacked zram kernel code to assign device_id
to zram->disk->node_id to emulate those disk with node_id.
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 8acad3cc6e6e..b0bb6531b029 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -2719,6 +2719,7 @@ static int zram_add(void)
zram->disk->flags |= GENHD_FL_NO_PART;
zram->disk->fops = &zram_devops;
zram->disk->private_data = zram;
+ zram->disk->node_id = device_id % nr_node_ids;
snprintf(zram->disk->disk_name, 16, "zram%d", device_id);
atomic_set(&zram->pp_in_progress, 0);
zram_comp_params_reset(zram);
next prev parent reply other threads:[~2025-09-24 10:24 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-24 9:17 [PATCH] mm/swapfile.c: select the swap device with default priority round robin Baoquan He
2025-09-24 10:23 ` Baoquan He [this message]
2025-09-24 15:41 ` YoungJun Park
2025-09-25 2:24 ` Baoquan He
2025-09-24 15:52 ` YoungJun Park
2025-09-25 4:10 ` Baoquan He
2025-09-25 4:23 ` Baoquan He
2025-09-24 15:54 ` Chris Li
2025-09-24 16:06 ` Chris Li
2025-09-25 2:15 ` Baoquan He
2025-09-25 18:31 ` Chris Li
2025-09-25 1:55 ` Baoquan He
2025-09-25 18:25 ` Chris Li
2025-09-26 15:31 ` Baoquan He
2025-09-27 4:46 ` Chris Li
2025-09-28 2:14 ` Baoquan He
2025-09-24 16:34 ` YoungJun Park
2025-09-25 0:24 ` Baoquan He
2025-09-25 4:36 ` Kairui Song
2025-09-25 6:18 ` Baoquan He
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=aNPGvsQplsBeIMfu@MiWiFi-R3L-srv \
--to=bhe@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=chrisl@kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.