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: <a9a9343f962a50f508324db6397131982abb12e4.camel@linux.intel.com>
Date: Mon, 17 Mar 2025 10:30:39 -0700
From: Tim Chen <tim.c.chen@...ux.intel.com>
To: Kemeng Shi <shikemeng@...weicloud.com>, akpm@...ux-foundation.org
Cc: kasong@...cent.com, linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 7/9] mm: swap: free each cluster individually in
 swap_entries_put_map_nr()


>  
>  fallback:
> -	for (i = 0; i < nr; i++) {
> -		if (data_race(si->swap_map[offset + i])) {
> -			count = swap_entry_put(si, swp_entry(type, offset + i));
> -			if (count == SWAP_HAS_CACHE)
> -				has_cache = true;
> -		} else {
> -			WARN_ON_ONCE(1);
> -		}
> +	ci = lock_cluster(si, offset);

Relocking the cluster is unnecessary overhead if we don't release the ci lock
prior to jumping to fallback label for the locked case.

Maybe something like:

diff --git a/mm/swapfile.c b/mm/swapfile.c
index 9cd93a03b25c..41aa841b86d6 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1504,8 +1504,7 @@ static bool swap_entries_put_map(struct swap_info_struct *si,
 
        ci = lock_cluster(si, offset);
        if (!swap_is_last_map(si, offset, nr, &has_cache)) {
-               unlock_cluster(ci);
-               goto fallback;
+               goto locked_fallback;
        }
        if (!has_cache)
                swap_entries_free(si, ci, entry, nr);
@@ -1518,6 +1517,7 @@ static bool swap_entries_put_map(struct swap_info_struct *si,
 
 fallback:
        ci = lock_cluster(si, offset);
+locked_fallback:
        for (i = 0; i < nr; i++, entry.val++) {
                count = swap_entry_put_locked(si, ci, entry, 1);
                if (count == SWAP_HAS_CACHE)


Tim

> +	for (i = 0; i < nr; i++, entry.val++) {
> +		count = swap_entry_put_locked(si, ci, entry, 1);
> +		if (count == SWAP_HAS_CACHE)
> +			has_cache = true;
>  	}
> +	unlock_cluster(ci);
> +	return has_cache;
> +
> +}
> +


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ