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: <20180723105438.GD2494@hirez.programming.kicks-ass.net>
Date:   Mon, 23 Jul 2018 12:54:38 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Srikar Dronamraju <srikar@...ux.vnet.ibm.com>
Cc:     Ingo Molnar <mingo@...nel.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Mel Gorman <mgorman@...hsingularity.net>,
        Rik van Riel <riel@...riel.com>,
        Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [PATCH v2 13/19] mm/migrate: Use xchg instead of spinlock

On Wed, Jun 20, 2018 at 10:32:54PM +0530, Srikar Dronamraju wrote:
> Currently resetting the migrate rate limit is under a spinlock.
> The spinlock will only serialize the migrate rate limiting and something
> similar can actually be achieved by a simpler xchg.

You're again not explaining things right. The xchg isn't simpler in any
way. It just happens to be faster, esp. so on PPC.

> diff --git a/mm/migrate.c b/mm/migrate.c
> index 8c0af0f..c774990 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -1868,17 +1868,25 @@ static struct page *alloc_misplaced_dst_page(struct page *page,
>  static bool numamigrate_update_ratelimit(pg_data_t *pgdat,
>  					unsigned long nr_pages)
>  {
> +	unsigned long next_window, interval;
> +
> +	next_window = READ_ONCE(pgdat->numabalancing_migrate_next_window);
> +	interval = msecs_to_jiffies(migrate_interval_millisecs);
> +
>  	/*
>  	 * Rate-limit the amount of data that is being migrated to a node.
>  	 * Optimal placement is no good if the memory bus is saturated and
>  	 * all the time is being spent migrating!
>  	 */
> +	if (time_after(jiffies, next_window)) {
> +		if (xchg(&pgdat->numabalancing_migrate_nr_pages, 0)) {
> +			do {
> +				next_window += interval;
> +			} while (unlikely(time_after(jiffies, next_window)));
> +
> +			WRITE_ONCE(pgdat->numabalancing_migrate_next_window,
> +							       next_window);
> +		}
>  	}
>  	if (pgdat->numabalancing_migrate_nr_pages > ratelimit_pages) {
>  		trace_mm_numa_migrate_ratelimit(current, pgdat->node_id,

If you maybe write that like:

	if (time_after(jiffies, next_window) &&
	    xchg(&pgdat->numabalancing_migrate_nr_pages, 0UL)) {

		do {
			next_window += interval;
		} while (unlikely(time_after(jiffies, next_window)));

		WRITE_ONCE(pgdat->numabalancing_migrate_next_window, next_window);
	}

Then you avoid an indent level and line-wrap, resulting imo easier to
read code.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ