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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 23 Aug 2011 10:56:51 +0400
From:	Konstantin Khlebnikov <khlebnikov@...nvz.org>
To:	"linux-mm@...ck.org" <linux-mm@...ck.org>,
	Andrew Morton <akpm@...ux-foundation.org>
CC:	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	Dave Chinner <david@...morbit.com>
Subject: Re: [PATCH 2/2] vmscan: use atomic-long for shrinker batching

Konstantin Khlebnikov wrote:
>   		delta = (4 * nr_pages_scanned) / shrinker->seeks;
> @@ -329,12 +327,11 @@ unsigned long shrink_slab(struct shrink_control *shrink,
>   		 * manner that handles concurrent updates. If we exhausted the
>   		 * scan, there is no need to do an update.
>   		 */
> -		do {
> -			nr = shrinker->nr;
> -			new_nr = total_scan + nr;
> -			if (total_scan<= 0)
> -				break;
> -		} while (cmpxchg(&shrinker->nr, nr, new_nr) != nr);
> +		if (total_scan>  0)
> +			new_nr = atomic_long_add_return(total_scan,
> +					&shrinker->nr_in_batch);
> +		else
> +			new_nr = atomic_long_read(&shrinker->nr_in_batch);
>
>   		trace_mm_shrink_slab_end(shrinker, shrink_ret, nr, new_nr);

BTW, new_nr required only for tracing, maybe this will be better/faster,
because atomic accuracy there isn't required at all.

	if (total_scan > 0)
		atomic_long_add(total_scan, &shrinker->nr_in_batch);

	new_nr = atomic_long_read(&shrinker->nr_in_batch);
	trace_mm_shrink_slab_end(shrinker, shrink_ret, nr, new_nr);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ