All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] swap: remove the struct cpumask has_work
@ 2014-07-31  3:30 ` Lai Jiangshan
  0 siblings, 0 replies; 12+ messages in thread
From: Lai Jiangshan @ 2014-07-31  3:30 UTC (permalink / raw)
  To: linux-kernel
  Cc: Lai Jiangshan, akpm, Chris Metcalf, Mel Gorman, Tejun Heo,
	Christoph Lameter, Frederic Weisbecker, Andrea Arcangeli,
	Rik van Riel, Jianyu Zhan, Johannes Weiner, Khalid Aziz,
	linux-mm

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.

CC: akpm@linux-foundation.org
CC: Chris Metcalf <cmetcalf@tilera.com>
CC: Mel Gorman <mgorman@suse.de>
CC: Tejun Heo <tj@kernel.org>
CC: Christoph Lameter <cl@gentwo.org>
CC: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Lai Jiangshan <laijs@cn.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


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH] swap: remove the struct cpumask has_work
@ 2014-07-31  3:30 ` Lai Jiangshan
  0 siblings, 0 replies; 12+ messages in thread
From: Lai Jiangshan @ 2014-07-31  3:30 UTC (permalink / raw)
  To: linux-kernel
  Cc: Lai Jiangshan, akpm, Chris Metcalf, Mel Gorman, Tejun Heo,
	Christoph Lameter, Frederic Weisbecker, Andrea Arcangeli,
	Rik van Riel, Jianyu Zhan, Johannes Weiner, Khalid Aziz,
	linux-mm

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.

CC: akpm@linux-foundation.org
CC: Chris Metcalf <cmetcalf@tilera.com>
CC: Mel Gorman <mgorman@suse.de>
CC: Tejun Heo <tj@kernel.org>
CC: Christoph Lameter <cl@gentwo.org>
CC: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Lai Jiangshan <laijs@cn.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, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] swap: remove the struct cpumask has_work
  2014-07-31  3:30 ` Lai Jiangshan
@ 2014-07-31 11:51   ` Michal Hocko
  -1 siblings, 0 replies; 12+ messages in thread
From: Michal Hocko @ 2014-07-31 11:51 UTC (permalink / raw)
  To: Lai Jiangshan
  Cc: linux-kernel, akpm, Chris Metcalf, Mel Gorman, Tejun Heo,
	Christoph Lameter, Frederic Weisbecker, Andrea Arcangeli,
	Rik van Riel, Jianyu Zhan, Johannes Weiner, Khalid Aziz,
	linux-mm

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@linux-foundation.org
> CC: Chris Metcalf <cmetcalf@tilera.com>
> CC: Mel Gorman <mgorman@suse.de>
> CC: Tejun Heo <tj@kernel.org>
> CC: Christoph Lameter <cl@gentwo.org>
> CC: Frederic Weisbecker <fweisbec@gmail.com>
> Signed-off-by: Lai Jiangshan <laijs@cn.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@vger.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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] swap: remove the struct cpumask has_work
@ 2014-07-31 11:51   ` Michal Hocko
  0 siblings, 0 replies; 12+ messages in thread
From: Michal Hocko @ 2014-07-31 11:51 UTC (permalink / raw)
  To: Lai Jiangshan
  Cc: linux-kernel, akpm, Chris Metcalf, Mel Gorman, Tejun Heo,
	Christoph Lameter, Frederic Weisbecker, Andrea Arcangeli,
	Rik van Riel, Jianyu Zhan, Johannes Weiner, Khalid Aziz,
	linux-mm

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@linux-foundation.org
> CC: Chris Metcalf <cmetcalf@tilera.com>
> CC: Mel Gorman <mgorman@suse.de>
> CC: Tejun Heo <tj@kernel.org>
> CC: Christoph Lameter <cl@gentwo.org>
> CC: Frederic Weisbecker <fweisbec@gmail.com>
> Signed-off-by: Lai Jiangshan <laijs@cn.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@vger.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, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] swap: remove the struct cpumask has_work
  2014-07-31 11:51   ` Michal Hocko
@ 2014-07-31 16:09     ` Chris Metcalf
  -1 siblings, 0 replies; 12+ messages in thread
From: Chris Metcalf @ 2014-07-31 16:09 UTC (permalink / raw)
  To: Michal Hocko, Lai Jiangshan
  Cc: linux-kernel, akpm, Mel Gorman, Tejun Heo, Christoph Lameter,
	Frederic Weisbecker, Andrea Arcangeli, Rik van Riel, Jianyu Zhan,
	Johannes Weiner, Khalid Aziz, linux-mm, Gilad Ben-Yossef

On 7/31/2014 7:51 AM, Michal Hocko wrote:
> 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.

The code uses for_each_cpu with a cpumask to avoid waking cpus that don't
need to do work.  This is important for the nohz_full type functionality,
power efficiency, etc.  So, nack for this change.

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] swap: remove the struct cpumask has_work
@ 2014-07-31 16:09     ` Chris Metcalf
  0 siblings, 0 replies; 12+ messages in thread
From: Chris Metcalf @ 2014-07-31 16:09 UTC (permalink / raw)
  To: Michal Hocko, Lai Jiangshan
  Cc: linux-kernel, akpm, Mel Gorman, Tejun Heo, Christoph Lameter,
	Frederic Weisbecker, Andrea Arcangeli, Rik van Riel, Jianyu Zhan,
	Johannes Weiner, Khalid Aziz, linux-mm, Gilad Ben-Yossef

On 7/31/2014 7:51 AM, Michal Hocko wrote:
> 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.

The code uses for_each_cpu with a cpumask to avoid waking cpus that don't
need to do work.  This is important for the nohz_full type functionality,
power efficiency, etc.  So, nack for this change.

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] swap: remove the struct cpumask has_work
  2014-07-31 16:09     ` Chris Metcalf
@ 2014-08-01  1:39       ` Lai Jiangshan
  -1 siblings, 0 replies; 12+ messages in thread
From: Lai Jiangshan @ 2014-08-01  1:39 UTC (permalink / raw)
  To: Chris Metcalf
  Cc: Michal Hocko, linux-kernel, akpm, Mel Gorman, Tejun Heo,
	Christoph Lameter, Frederic Weisbecker, Andrea Arcangeli,
	Rik van Riel, Jianyu Zhan, Johannes Weiner, Khalid Aziz,
	linux-mm, Gilad Ben-Yossef

On 08/01/2014 12:09 AM, Chris Metcalf wrote:
> On 7/31/2014 7:51 AM, Michal Hocko wrote:
>> 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.
> 
> The code uses for_each_cpu with a cpumask to avoid waking cpus that don't
> need to do work.  This is important for the nohz_full type functionality,
> power efficiency, etc.  So, nack for this change.
> 

flush_work() on initialized but unused work item just disables irq and
fetches work->data to test and restores irq and return.

the struct cpumask has_work is just premature optimization.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] swap: remove the struct cpumask has_work
@ 2014-08-01  1:39       ` Lai Jiangshan
  0 siblings, 0 replies; 12+ messages in thread
From: Lai Jiangshan @ 2014-08-01  1:39 UTC (permalink / raw)
  To: Chris Metcalf
  Cc: Michal Hocko, linux-kernel, akpm, Mel Gorman, Tejun Heo,
	Christoph Lameter, Frederic Weisbecker, Andrea Arcangeli,
	Rik van Riel, Jianyu Zhan, Johannes Weiner, Khalid Aziz,
	linux-mm, Gilad Ben-Yossef

On 08/01/2014 12:09 AM, Chris Metcalf wrote:
> On 7/31/2014 7:51 AM, Michal Hocko wrote:
>> 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.
> 
> The code uses for_each_cpu with a cpumask to avoid waking cpus that don't
> need to do work.  This is important for the nohz_full type functionality,
> power efficiency, etc.  So, nack for this change.
> 

flush_work() on initialized but unused work item just disables irq and
fetches work->data to test and restores irq and return.

the struct cpumask has_work is just premature optimization.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] swap: remove the struct cpumask has_work
  2014-08-01  1:39       ` Lai Jiangshan
@ 2014-08-01 17:16         ` Chris Metcalf
  -1 siblings, 0 replies; 12+ messages in thread
From: Chris Metcalf @ 2014-08-01 17:16 UTC (permalink / raw)
  To: Lai Jiangshan
  Cc: Michal Hocko, linux-kernel, akpm, Mel Gorman, Tejun Heo,
	Christoph Lameter, Frederic Weisbecker, Andrea Arcangeli,
	Rik van Riel, Jianyu Zhan, Johannes Weiner, Khalid Aziz,
	linux-mm, Gilad Ben-Yossef

On 7/31/2014 9:39 PM, Lai Jiangshan wrote:
> On 08/01/2014 12:09 AM, Chris Metcalf wrote:
>> On 7/31/2014 7:51 AM, Michal Hocko wrote:
>>> 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.
>> The code uses for_each_cpu with a cpumask to avoid waking cpus that don't
>> need to do work.  This is important for the nohz_full type functionality,
>> power efficiency, etc.  So, nack for this change.
>>
> flush_work() on initialized but unused work item just disables irq and
> fetches work->data to test and restores irq and return.
>
> the struct cpumask has_work is just premature optimization.

Yes, I see your point.  I was mistakenly thinking that your patch resulted
in calling schedule_work() on all the online cpus.

Given that, I think your suggestion is reasonable, though like Michal,
I'm not sure it necessarily rises to the level of it being worth changing the
code at this point.  Regardless, I withdraw my nack, and you can add my
Reviewed-by: Chris Metcalf <cmetcalf@tilera.com> if the change is taken.

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] swap: remove the struct cpumask has_work
@ 2014-08-01 17:16         ` Chris Metcalf
  0 siblings, 0 replies; 12+ messages in thread
From: Chris Metcalf @ 2014-08-01 17:16 UTC (permalink / raw)
  To: Lai Jiangshan
  Cc: Michal Hocko, linux-kernel, akpm, Mel Gorman, Tejun Heo,
	Christoph Lameter, Frederic Weisbecker, Andrea Arcangeli,
	Rik van Riel, Jianyu Zhan, Johannes Weiner, Khalid Aziz,
	linux-mm, Gilad Ben-Yossef

On 7/31/2014 9:39 PM, Lai Jiangshan wrote:
> On 08/01/2014 12:09 AM, Chris Metcalf wrote:
>> On 7/31/2014 7:51 AM, Michal Hocko wrote:
>>> 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.
>> The code uses for_each_cpu with a cpumask to avoid waking cpus that don't
>> need to do work.  This is important for the nohz_full type functionality,
>> power efficiency, etc.  So, nack for this change.
>>
> flush_work() on initialized but unused work item just disables irq and
> fetches work->data to test and restores irq and return.
>
> the struct cpumask has_work is just premature optimization.

Yes, I see your point.  I was mistakenly thinking that your patch resulted
in calling schedule_work() on all the online cpus.

Given that, I think your suggestion is reasonable, though like Michal,
I'm not sure it necessarily rises to the level of it being worth changing the
code at this point.  Regardless, I withdraw my nack, and you can add my
Reviewed-by: Chris Metcalf <cmetcalf@tilera.com> if the change is taken.

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] swap: remove the struct cpumask has_work
  2014-08-01 17:16         ` Chris Metcalf
@ 2014-08-01 17:28           ` Frederic Weisbecker
  -1 siblings, 0 replies; 12+ messages in thread
From: Frederic Weisbecker @ 2014-08-01 17:28 UTC (permalink / raw)
  To: Chris Metcalf
  Cc: Lai Jiangshan, Michal Hocko, linux-kernel, akpm, Mel Gorman,
	Tejun Heo, Christoph Lameter, Andrea Arcangeli, Rik van Riel,
	Jianyu Zhan, Johannes Weiner, Khalid Aziz, linux-mm,
	Gilad Ben-Yossef

On Fri, Aug 01, 2014 at 01:16:05PM -0400, Chris Metcalf wrote:
> On 7/31/2014 9:39 PM, Lai Jiangshan wrote:
> >On 08/01/2014 12:09 AM, Chris Metcalf wrote:
> >>On 7/31/2014 7:51 AM, Michal Hocko wrote:
> >>>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.
> >>The code uses for_each_cpu with a cpumask to avoid waking cpus that don't
> >>need to do work.  This is important for the nohz_full type functionality,
> >>power efficiency, etc.  So, nack for this change.
> >>
> >flush_work() on initialized but unused work item just disables irq and
> >fetches work->data to test and restores irq and return.
> >
> >the struct cpumask has_work is just premature optimization.
> 
> Yes, I see your point.  I was mistakenly thinking that your patch resulted
> in calling schedule_work() on all the online cpus.
> 
> Given that, I think your suggestion is reasonable, though like Michal,
> I'm not sure it necessarily rises to the level of it being worth changing the
> code at this point.  Regardless, I withdraw my nack, and you can add my
> Reviewed-by: Chris Metcalf <cmetcalf@tilera.com> if the change is taken.

Thing is: static struct cpumask can potentially reserve a bit of memory.
For NR_CPUS=1024 for example it should be 1024 / sizeof(byte) = 128 bytes. It's no
big deal but as I can see sometimes people complaining about the size of the
kernel... Also think about the cacheline it takes.

I mean if the patch really has no side effect in performance, it's probably good to
take.

But I'm not sure it's free of such. It's still an iteration on all online CPUs,
even though a noop, with a high number of CPUs it can be undesired. It depends
what's the usual proportion of has_work CPUs against online?

If most online CPUs are to be found there, we can ignore that but otherwise...

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] swap: remove the struct cpumask has_work
@ 2014-08-01 17:28           ` Frederic Weisbecker
  0 siblings, 0 replies; 12+ messages in thread
From: Frederic Weisbecker @ 2014-08-01 17:28 UTC (permalink / raw)
  To: Chris Metcalf
  Cc: Lai Jiangshan, Michal Hocko, linux-kernel, akpm, Mel Gorman,
	Tejun Heo, Christoph Lameter, Andrea Arcangeli, Rik van Riel,
	Jianyu Zhan, Johannes Weiner, Khalid Aziz, linux-mm,
	Gilad Ben-Yossef

On Fri, Aug 01, 2014 at 01:16:05PM -0400, Chris Metcalf wrote:
> On 7/31/2014 9:39 PM, Lai Jiangshan wrote:
> >On 08/01/2014 12:09 AM, Chris Metcalf wrote:
> >>On 7/31/2014 7:51 AM, Michal Hocko wrote:
> >>>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.
> >>The code uses for_each_cpu with a cpumask to avoid waking cpus that don't
> >>need to do work.  This is important for the nohz_full type functionality,
> >>power efficiency, etc.  So, nack for this change.
> >>
> >flush_work() on initialized but unused work item just disables irq and
> >fetches work->data to test and restores irq and return.
> >
> >the struct cpumask has_work is just premature optimization.
> 
> Yes, I see your point.  I was mistakenly thinking that your patch resulted
> in calling schedule_work() on all the online cpus.
> 
> Given that, I think your suggestion is reasonable, though like Michal,
> I'm not sure it necessarily rises to the level of it being worth changing the
> code at this point.  Regardless, I withdraw my nack, and you can add my
> Reviewed-by: Chris Metcalf <cmetcalf@tilera.com> if the change is taken.

Thing is: static struct cpumask can potentially reserve a bit of memory.
For NR_CPUS=1024 for example it should be 1024 / sizeof(byte) = 128 bytes. It's no
big deal but as I can see sometimes people complaining about the size of the
kernel... Also think about the cacheline it takes.

I mean if the patch really has no side effect in performance, it's probably good to
take.

But I'm not sure it's free of such. It's still an iteration on all online CPUs,
even though a noop, with a high number of CPUs it can be undesired. It depends
what's the usual proportion of has_work CPUs against online?

If most online CPUs are to be found there, we can ignore that but otherwise...

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-08-01 17:28 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-31  3:30 [PATCH] swap: remove the struct cpumask has_work Lai Jiangshan
2014-07-31  3:30 ` Lai Jiangshan
2014-07-31 11:51 ` Michal Hocko
2014-07-31 11:51   ` Michal Hocko
2014-07-31 16:09   ` Chris Metcalf
2014-07-31 16:09     ` Chris Metcalf
2014-08-01  1:39     ` Lai Jiangshan
2014-08-01  1:39       ` Lai Jiangshan
2014-08-01 17:16       ` Chris Metcalf
2014-08-01 17:16         ` Chris Metcalf
2014-08-01 17:28         ` Frederic Weisbecker
2014-08-01 17:28           ` Frederic Weisbecker

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.