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]
Date:   Wed, 25 Jan 2017 16:08:02 -0800
From:   Andrew Morton <akpm@...ux-foundation.org>
To:     Mel Gorman <mgorman@...hsingularity.net>
Cc:     Tejun Heo <tj@...nel.org>, Vlastimil Babka <vbabka@...e.cz>,
        Linux Kernel <linux-kernel@...r.kernel.org>,
        Linux-MM <linux-mm@...ck.org>,
        Hillf Danton <hillf.zj@...baba-inc.com>,
        Jesper Dangaard Brouer <brouer@...hat.com>
Subject: Re: [PATCH] mm, page_alloc: Use static global work_struct for
 draining per-cpu pages

On Wed, 25 Jan 2017 08:30:38 +0000 Mel Gorman <mgorman@...hsingularity.net> wrote:

> As suggested by Vlastimil Babka and Tejun Heo, this patch uses a static
> work_struct to co-ordinate the draining of per-cpu pages on the workqueue.
> Only one task can drain at a time but this is better than the previous
> scheme that allowed multiple tasks to send IPIs at a time.
> 
> One consideration is whether parallel requests should synchronise against
> each other. This patch does not synchronise for a global drain as the common
> case for such callers is expected to be multiple parallel direct reclaimers
> competing for pages when the watermark is close to min. Draining the per-cpu
> list is unlikely to make much progress and serialising the drain is of
> dubious merit. Drains are synchonrised for callers such as memory hotplug
> and CMA that care about the drain being complete when the function returns.
> 
> ...
>
> @@ -2402,24 +2415,16 @@ void drain_all_pages(struct zone *zone)
>  			cpumask_clear_cpu(cpu, &cpus_with_pcps);
>  	}
>  
> -	if (works) {
> -		for_each_cpu(cpu, &cpus_with_pcps) {
> -			struct work_struct *work = per_cpu_ptr(works, cpu);
> -			INIT_WORK(work, drain_local_pages_wq);
> -			schedule_work_on(cpu, work);
> -		}
> -		for_each_cpu(cpu, &cpus_with_pcps)
> -			flush_work(per_cpu_ptr(works, cpu));
> -	} else {
> -		for_each_cpu(cpu, &cpus_with_pcps) {
> -			struct work_struct work;
> -
> -			INIT_WORK(&work, drain_local_pages_wq);
> -			schedule_work_on(cpu, &work);
> -			flush_work(&work);
> -		}
> +	for_each_cpu(cpu, &cpus_with_pcps) {
> +		struct work_struct *work = per_cpu_ptr(&pcpu_drain, cpu);
> +		INIT_WORK(work, drain_local_pages_wq);

It's strange to repeatedly run INIT_WORK() in this fashion. 
Overwriting an atomic_t which should already be zero, initializing a
list_head which should already be in the initialized state...

Can we instead do this a single time in init code?

> +		schedule_work_on(cpu, work);
>  	}
> +	for_each_cpu(cpu, &cpus_with_pcps)
> +		flush_work(per_cpu_ptr(&pcpu_drain, cpu));
> +
>  	put_online_cpus();
> +	mutex_unlock(&pcpu_drain_mutex);
>  }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ