[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Z7cG636IwnSnC65d@MiWiFi-R3L-srv>
Date: Thu, 20 Feb 2025 18:41:47 +0800
From: Baoquan He <bhe@...hat.com>
To: Kairui Song <kasong@...cent.com>
Cc: linux-mm@...ck.org, Andrew Morton <akpm@...ux-foundation.org>,
Chris Li <chrisl@...nel.org>, Barry Song <v-songbaohua@...o.com>,
Hugh Dickins <hughd@...gle.com>,
Yosry Ahmed <yosryahmed@...gle.com>,
"Huang, Ying" <ying.huang@...ux.alibaba.com>,
Nhat Pham <nphamcs@...il.com>, Johannes Weiner <hannes@...xchg.org>,
Kalesh Singh <kaleshsingh@...gle.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 7/7] mm, swap: simplify folio swap allocation
On 02/15/25 at 01:57am, Kairui Song wrote:
......snip..
> -swp_entry_t folio_alloc_swap(struct folio *folio)
> +/* Rotate the device and switch to a new cluster */
> +static bool swap_alloc_rotate(swp_entry_t *entry,
> + unsigned char usage,
> + int order)
The function name is misleading which may make people thing it's a HDD
swap allocation. I would call it swap_alloc_slow() relative to the
swap_alloc_fast().
> {
> - unsigned int order = folio_order(folio);
> - unsigned int size = 1 << order;
> - struct swap_info_struct *si, *next;
> - swp_entry_t entry = {};
> - unsigned long offset;
> int node;
> + unsigned long offset;
> + struct swap_info_struct *si, *next;
>
> - if (order) {
> - /*
> - * Should not even be attempting large allocations when huge
> - * page swap is disabled. Warn and fail the allocation.
> - */
> - if (!IS_ENABLED(CONFIG_THP_SWAP) || size > SWAPFILE_CLUSTER) {
> - VM_WARN_ON_ONCE(1);
> - return entry;
> - }
> - }
> -
> - /* Fast path using percpu cluster */
> - local_lock(&percpu_swap_cluster.lock);
> - if (swap_alloc_fast(&entry, SWAP_HAS_CACHE, order))
> - goto out_alloced;
> -
> - /* Rotate the device and switch to a new cluster */
> + node = numa_node_id();
> spin_lock(&swap_avail_lock);
> start_over:
> - node = numa_node_id();
> plist_for_each_entry_safe(si, next, &swap_avail_heads[node], avail_lists[node]) {
> + /* Rotate the device and switch to a new cluster */
> plist_requeue(&si->avail_lists[node], &swap_avail_heads[node]);
> spin_unlock(&swap_avail_lock);
> if (get_swap_device_info(si)) {
> offset = cluster_alloc_swap_entry(si, order, SWAP_HAS_CACHE);
> put_swap_device(si);
> if (offset) {
> - entry = swp_entry(si->type, offset);
> - goto out_alloced;
> + *entry = swp_entry(si->type, offset);
> + return true;
> }
> if (order)
> - goto out_failed;
> + return false;
> }
>
> spin_lock(&swap_avail_lock);
Powered by blists - more mailing lists