lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aXsGo1lh2oBLeG66@yjaykim-PowerEdge-T330>
Date: Thu, 29 Jan 2026 16:05:07 +0900
From: YoungJun Park <youngjun.park@....com>
To: Kairui Song <ryncsn@...il.com>
Cc: linux-mm@...ck.org, Andrew Morton <akpm@...ux-foundation.org>,
	Kemeng Shi <shikemeng@...weicloud.com>,
	Nhat Pham <nphamcs@...il.com>, Baoquan He <bhe@...hat.com>,
	Barry Song <baohua@...nel.org>,
	Johannes Weiner <hannes@...xchg.org>,
	David Hildenbrand <david@...nel.org>,
	Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
	linux-kernel@...r.kernel.org, Chris Li <chrisl@...nel.org>,
	Kairui Song <kasong@...cent.com>
Subject: Re: [PATCH v2 09/12] mm, swap: use the swap table to track the swap
 count

On Wed, Jan 28, 2026 at 05:28:33PM +0800, Kairui Song wrote:
> From: Kairui Song <kasong@...cent.com>

> +/**
> + * swap_dup_entries_cluster: Increase the swap count of slots within one cluster.
> + * @si: The swap device.
> + * @offset: start offset of slots.
> + * @nr: number of slots.
> + *
> + * Context: The specified slots must be pinned by existing swap count or swap
> + * cache reference, so they won't be released until this helper returns.
> + * Return: 0 on success. -ENOMEM if the swap count maxed out (SWP_TB_COUNT_MAX)
> + * and failed to allocate an extended table.
> + */
> +static int swap_dup_entries_cluster(struct swap_info_struct *si,
> +				    pgoff_t offset, int nr)
> +{
> +	int err;
> +	struct swap_cluster_info *ci;
> +	unsigned int ci_start, ci_off, ci_end;
> +
> +	ci_start = offset % SWAPFILE_CLUSTER;
> +	ci_end = ci_start + nr;
> +	ci_off = ci_start;
> +	ci = swap_cluster_lock(si, offset);
> +restart:
> +	do {
> +		err = __swap_cluster_dup_entry(ci, ci_off);
> +		if (unlikely(err)) {
> +			if (err == -ENOMEM) {
> +				spin_unlock(&ci->lock);
> +				err = swap_extend_table_alloc(si, ci, GFP_ATOMIC);

Hello Kairui

Just a minor nit.
If the extended table already exists but the allocation fails, the operation
currently terminates as a failure. It seems swap_extend_table_alloc returns
failure even if it holds an extended table. It seems extend_table created 
while ungrabbing ci->lock.

If my assumtion is right,
How about adjusting the error handling in swap_extend_table_alloc, or
perhaps implementing a non-locking __swap_extend_table_alloc version?
(I think the latter is better. it avoids unneeded lock - unlock - lock sequence.)

Thanks
Youngjun Park

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ