linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] lib/test_vmalloc: do not create cpumask_t variable on stack
@ 2019-04-18 19:39 Uladzislau Rezki (Sony)
  2019-04-18 22:10 ` Andrew Morton
  2019-04-19 19:49 ` Roman Gushchin
  0 siblings, 2 replies; 4+ messages in thread
From: Uladzislau Rezki (Sony) @ 2019-04-18 19:39 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Roman Gushchin, Uladzislau Rezki, Michal Hocko, Matthew Wilcox,
	linux-mm, LKML, Thomas Garnier, Oleksiy Avramchenko,
	Steven Rostedt, Joel Fernandes, Thomas Gleixner, Ingo Molnar,
	Tejun Heo

On my "Intel(R) Xeon(R) W-2135 CPU @ 3.70GHz" system(12 CPUs)
i get the warning from the compiler about frame size:

<snip>
warning: the frame size of 1096 bytes is larger than 1024 bytes
[-Wframe-larger-than=]
<snip>

the size of cpumask_t depends on number of CPUs, therefore just
make use of cpumask_of() in set_cpus_allowed_ptr() as a second
argument.

Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
---
 lib/test_vmalloc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/test_vmalloc.c b/lib/test_vmalloc.c
index 83cdcaa82bf6..f832b095afba 100644
--- a/lib/test_vmalloc.c
+++ b/lib/test_vmalloc.c
@@ -383,14 +383,14 @@ static void shuffle_array(int *arr, int n)
 static int test_func(void *private)
 {
 	struct test_driver *t = private;
-	cpumask_t newmask = CPU_MASK_NONE;
 	int random_array[ARRAY_SIZE(test_case_array)];
 	int index, i, j, ret;
 	ktime_t kt;
 	u64 delta;
 
-	cpumask_set_cpu(t->cpu, &newmask);
-	set_cpus_allowed_ptr(current, &newmask);
+	ret = set_cpus_allowed_ptr(current, cpumask_of(t->cpu));
+	if (ret < 0)
+		pr_err("Failed to set affinity to %d CPU\n", t->cpu);
 
 	for (i = 0; i < ARRAY_SIZE(test_case_array); i++)
 		random_array[i] = i;
-- 
2.11.0


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

* Re: [PATCH 1/1] lib/test_vmalloc: do not create cpumask_t variable on stack
  2019-04-18 19:39 [PATCH 1/1] lib/test_vmalloc: do not create cpumask_t variable on stack Uladzislau Rezki (Sony)
@ 2019-04-18 22:10 ` Andrew Morton
  2019-04-19 11:06   ` Uladzislau Rezki
  2019-04-19 19:49 ` Roman Gushchin
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2019-04-18 22:10 UTC (permalink / raw)
  To: Uladzislau Rezki (Sony)
  Cc: Roman Gushchin, Michal Hocko, Matthew Wilcox, linux-mm, LKML,
	Thomas Garnier, Oleksiy Avramchenko, Steven Rostedt,
	Joel Fernandes, Thomas Gleixner, Ingo Molnar, Tejun Heo

On Thu, 18 Apr 2019 21:39:25 +0200 "Uladzislau Rezki (Sony)" <urezki@gmail.com> wrote:

> On my "Intel(R) Xeon(R) W-2135 CPU @ 3.70GHz" system(12 CPUs)
> i get the warning from the compiler about frame size:
> 
> <snip>
> warning: the frame size of 1096 bytes is larger than 1024 bytes
> [-Wframe-larger-than=]
> <snip>
> 
> the size of cpumask_t depends on number of CPUs, therefore just
> make use of cpumask_of() in set_cpus_allowed_ptr() as a second
> argument.
> 
> ...
L
> --- a/lib/test_vmalloc.c
> +++ b/lib/test_vmalloc.c
> @@ -383,14 +383,14 @@ static void shuffle_array(int *arr, int n)
>  static int test_func(void *private)
>  {
>  	struct test_driver *t = private;
> -	cpumask_t newmask = CPU_MASK_NONE;
>  	int random_array[ARRAY_SIZE(test_case_array)];
>  	int index, i, j, ret;
>  	ktime_t kt;
>  	u64 delta;
>  
> -	cpumask_set_cpu(t->cpu, &newmask);
> -	set_cpus_allowed_ptr(current, &newmask);
> +	ret = set_cpus_allowed_ptr(current, cpumask_of(t->cpu));
> +	if (ret < 0)
> +		pr_err("Failed to set affinity to %d CPU\n", t->cpu);
>  
>  	for (i = 0; i < ARRAY_SIZE(test_case_array); i++)
>  		random_array[i] = i;

lgtm.

While we're in there...


From: Andrew Morton <akpm@linux-foundation.org>
Subject: lib/test_vmalloc.c:test_func(): eliminate local `ret'

Local 'ret' is unneeded and was poorly named: the variable `ret' generally
means the "the value which this function will return".

Cc: Roman Gushchin <guro@fb.com>
Cc: Uladzislau Rezki <urezki@gmail.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Thomas Garnier <thgarnie@google.com>
Cc: Oleksiy Avramchenko <oleksiy.avramchenko@sonymobile.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Joel Fernandes <joelaf@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 lib/test_vmalloc.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

--- a/lib/test_vmalloc.c~a
+++ a/lib/test_vmalloc.c
@@ -384,12 +384,11 @@ static int test_func(void *private)
 {
 	struct test_driver *t = private;
 	int random_array[ARRAY_SIZE(test_case_array)];
-	int index, i, j, ret;
+	int index, i, j;
 	ktime_t kt;
 	u64 delta;
 
-	ret = set_cpus_allowed_ptr(current, cpumask_of(t->cpu));
-	if (ret < 0)
+	if (set_cpus_allowed_ptr(current, cpumask_of(t->cpu)) < 0)
 		pr_err("Failed to set affinity to %d CPU\n", t->cpu);
 
 	for (i = 0; i < ARRAY_SIZE(test_case_array); i++)
@@ -415,8 +414,7 @@ static int test_func(void *private)
 
 		kt = ktime_get();
 		for (j = 0; j < test_repeat_count; j++) {
-			ret = test_case_array[index].test_func();
-			if (!ret)
+			if (!test_case_array[index].test_func())
 				per_cpu_test_data[t->cpu][index].test_passed++;
 			else
 				per_cpu_test_data[t->cpu][index].test_failed++;
_


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

* Re: [PATCH 1/1] lib/test_vmalloc: do not create cpumask_t variable on stack
  2019-04-18 22:10 ` Andrew Morton
@ 2019-04-19 11:06   ` Uladzislau Rezki
  0 siblings, 0 replies; 4+ messages in thread
From: Uladzislau Rezki @ 2019-04-19 11:06 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Uladzislau Rezki (Sony),
	Roman Gushchin, Michal Hocko, Matthew Wilcox, linux-mm, LKML,
	Thomas Garnier, Oleksiy Avramchenko, Steven Rostedt,
	Joel Fernandes, Thomas Gleixner, Ingo Molnar, Tejun Heo

On Thu, Apr 18, 2019 at 03:10:33PM -0700, Andrew Morton wrote:
> On Thu, 18 Apr 2019 21:39:25 +0200 "Uladzislau Rezki (Sony)" <urezki@gmail.com> wrote:
> 
> > On my "Intel(R) Xeon(R) W-2135 CPU @ 3.70GHz" system(12 CPUs)
> > i get the warning from the compiler about frame size:
> > 
> > <snip>
> > warning: the frame size of 1096 bytes is larger than 1024 bytes
> > [-Wframe-larger-than=]
> > <snip>
> > 
> > the size of cpumask_t depends on number of CPUs, therefore just
> > make use of cpumask_of() in set_cpus_allowed_ptr() as a second
> > argument.
> > 
> > ...
> L
> > --- a/lib/test_vmalloc.c
> > +++ b/lib/test_vmalloc.c
> > @@ -383,14 +383,14 @@ static void shuffle_array(int *arr, int n)
> >  static int test_func(void *private)
> >  {
> >  	struct test_driver *t = private;
> > -	cpumask_t newmask = CPU_MASK_NONE;
> >  	int random_array[ARRAY_SIZE(test_case_array)];
> >  	int index, i, j, ret;
> >  	ktime_t kt;
> >  	u64 delta;
> >  
> > -	cpumask_set_cpu(t->cpu, &newmask);
> > -	set_cpus_allowed_ptr(current, &newmask);
> > +	ret = set_cpus_allowed_ptr(current, cpumask_of(t->cpu));
> > +	if (ret < 0)
> > +		pr_err("Failed to set affinity to %d CPU\n", t->cpu);
> >  
> >  	for (i = 0; i < ARRAY_SIZE(test_case_array); i++)
> >  		random_array[i] = i;
> 
> lgtm.
> 
> While we're in there...
> 
> 
> From: Andrew Morton <akpm@linux-foundation.org>
> Subject: lib/test_vmalloc.c:test_func(): eliminate local `ret'
> 
> Local 'ret' is unneeded and was poorly named: the variable `ret' generally
> means the "the value which this function will return".
> 
> Cc: Roman Gushchin <guro@fb.com>
> Cc: Uladzislau Rezki <urezki@gmail.com>
> Cc: Michal Hocko <mhocko@suse.com>
> Cc: Matthew Wilcox <willy@infradead.org>
> Cc: Thomas Garnier <thgarnie@google.com>
> Cc: Oleksiy Avramchenko <oleksiy.avramchenko@sonymobile.com>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Joel Fernandes <joelaf@google.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@elte.hu>
> Cc: Tejun Heo <tj@kernel.org>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
> 
>  lib/test_vmalloc.c |    8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> --- a/lib/test_vmalloc.c~a
> +++ a/lib/test_vmalloc.c
> @@ -384,12 +384,11 @@ static int test_func(void *private)
>  {
>  	struct test_driver *t = private;
>  	int random_array[ARRAY_SIZE(test_case_array)];
> -	int index, i, j, ret;
> +	int index, i, j;
>  	ktime_t kt;
>  	u64 delta;
>  
> -	ret = set_cpus_allowed_ptr(current, cpumask_of(t->cpu));
> -	if (ret < 0)
> +	if (set_cpus_allowed_ptr(current, cpumask_of(t->cpu)) < 0)
>  		pr_err("Failed to set affinity to %d CPU\n", t->cpu);
>  
>  	for (i = 0; i < ARRAY_SIZE(test_case_array); i++)
> @@ -415,8 +414,7 @@ static int test_func(void *private)
>  
>  		kt = ktime_get();
>  		for (j = 0; j < test_repeat_count; j++) {
> -			ret = test_case_array[index].test_func();
> -			if (!ret)
> +			if (!test_case_array[index].test_func())
>  				per_cpu_test_data[t->cpu][index].test_passed++;
>  			else
>  				per_cpu_test_data[t->cpu][index].test_failed++;
> _
> 
Agree with your slight update.

Thank you!

--
Vlad Rezki

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

* Re: [PATCH 1/1] lib/test_vmalloc: do not create cpumask_t variable on stack
  2019-04-18 19:39 [PATCH 1/1] lib/test_vmalloc: do not create cpumask_t variable on stack Uladzislau Rezki (Sony)
  2019-04-18 22:10 ` Andrew Morton
@ 2019-04-19 19:49 ` Roman Gushchin
  1 sibling, 0 replies; 4+ messages in thread
From: Roman Gushchin @ 2019-04-19 19:49 UTC (permalink / raw)
  To: Uladzislau Rezki (Sony)
  Cc: Andrew Morton, Michal Hocko, Matthew Wilcox, linux-mm, LKML,
	Thomas Garnier, Oleksiy Avramchenko, Steven Rostedt,
	Joel Fernandes, Thomas Gleixner, Ingo Molnar, Tejun Heo

On Thu, Apr 18, 2019 at 09:39:25PM +0200, Uladzislau Rezki (Sony) wrote:
> On my "Intel(R) Xeon(R) W-2135 CPU @ 3.70GHz" system(12 CPUs)
> i get the warning from the compiler about frame size:
> 
> <snip>
> warning: the frame size of 1096 bytes is larger than 1024 bytes
> [-Wframe-larger-than=]
> <snip>
> 
> the size of cpumask_t depends on number of CPUs, therefore just
> make use of cpumask_of() in set_cpus_allowed_ptr() as a second
> argument.
> 
> Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>

Reviewed-by: Roman Gushchin <guro@fb.com>

Thanks!

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

end of thread, other threads:[~2019-04-19 19:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-18 19:39 [PATCH 1/1] lib/test_vmalloc: do not create cpumask_t variable on stack Uladzislau Rezki (Sony)
2019-04-18 22:10 ` Andrew Morton
2019-04-19 11:06   ` Uladzislau Rezki
2019-04-19 19:49 ` Roman Gushchin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).