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: <20140731115137.GA20244@dhcp22.suse.cz>
Date:	Thu, 31 Jul 2014 13:51:37 +0200
From:	Michal Hocko <mhocko@...e.cz>
To:	Lai Jiangshan <laijs@...fujitsu.com>
Cc:	linux-kernel@...r.kernel.org, akpm@...ux-foundation.org,
	Chris Metcalf <cmetcalf@...era.com>,
	Mel Gorman <mgorman@...e.de>, Tejun Heo <tj@...nel.org>,
	Christoph Lameter <cl@...two.org>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Andrea Arcangeli <aarcange@...hat.com>,
	Rik van Riel <riel@...hat.com>,
	Jianyu Zhan <nasa4836@...il.com>,
	Johannes Weiner <hannes@...xchg.org>,
	Khalid Aziz <khalid.aziz@...cle.com>, linux-mm@...ck.org
Subject: Re: [PATCH] swap: remove the struct cpumask has_work

On Thu 31-07-14 11:30:19, Lai Jiangshan wrote:
> It is suggested that cpumask_var_t and alloc_cpumask_var() should be used
> instead of struct cpumask.  But I don't want to add this complicity nor
> leave this unwelcome "static struct cpumask has_work;", so I just remove
> it and use flush_work() to perform on all online drain_work.  flush_work()
> performs very quickly on initialized but unused work item, thus we don't
> need the struct cpumask has_work for performance.

Why? Just because there is general recommendation for using
cpumask_var_t rather than cpumask?

In this particular case cpumask shouldn't matter much as it is static.
Your code will work as well, but I do not see any strong reason to
change it just to get rid of cpumask which is not on stack.

> CC: akpm@...ux-foundation.org
> CC: Chris Metcalf <cmetcalf@...era.com>
> CC: Mel Gorman <mgorman@...e.de>
> CC: Tejun Heo <tj@...nel.org>
> CC: Christoph Lameter <cl@...two.org>
> CC: Frederic Weisbecker <fweisbec@...il.com>
> Signed-off-by: Lai Jiangshan <laijs@...fujitsu.com>
> ---
>  mm/swap.c |   11 ++++-------
>  1 files changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/mm/swap.c b/mm/swap.c
> index 9e8e347..bb524ca 100644
> --- a/mm/swap.c
> +++ b/mm/swap.c
> @@ -833,27 +833,24 @@ static DEFINE_PER_CPU(struct work_struct, lru_add_drain_work);
>  void lru_add_drain_all(void)
>  {
>  	static DEFINE_MUTEX(lock);
> -	static struct cpumask has_work;
>  	int cpu;
>  
>  	mutex_lock(&lock);
>  	get_online_cpus();
> -	cpumask_clear(&has_work);
>  
>  	for_each_online_cpu(cpu) {
>  		struct work_struct *work = &per_cpu(lru_add_drain_work, cpu);
>  
> +		INIT_WORK(work, lru_add_drain_per_cpu);
> +
>  		if (pagevec_count(&per_cpu(lru_add_pvec, cpu)) ||
>  		    pagevec_count(&per_cpu(lru_rotate_pvecs, cpu)) ||
>  		    pagevec_count(&per_cpu(lru_deactivate_pvecs, cpu)) ||
> -		    need_activate_page_drain(cpu)) {
> -			INIT_WORK(work, lru_add_drain_per_cpu);
> +		    need_activate_page_drain(cpu))
>  			schedule_work_on(cpu, work);
> -			cpumask_set_cpu(cpu, &has_work);
> -		}
>  	}
>  
> -	for_each_cpu(cpu, &has_work)
> +	for_each_online_cpu(cpu)
>  		flush_work(&per_cpu(lru_add_drain_work, cpu));
>  
>  	put_online_cpus();
> -- 
> 1.7.4.4
> 
> --
> 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/

-- 
Michal Hocko
SUSE Labs
--
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