lib/test_vmalloc: do not create cpumask_t variable on stack
Subsystems (3)
Uladzislau Rezki (Sony)
maintainerPATCH 1/1 lib/test_vmalloc: do not create cpumask_t variable on stack
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.
--- lib/test_vmalloc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/test_vmalloc.c +3 -3
@@ -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;
Signature · 1 line
2.11.0
Andrew Morton
maintainerQuoted 8 lines · On Thu, 18 Apr 2019 21:39:25 +0200 "Uladzislau Rezki (Sony)"…
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>
Quoted 5 lines
the size of
cpumask_tdepends on number of CPUs, therefore just make use ofcpumask_of()inset_cpus_allowed_ptr()as a second argument....
L
Quoted 10 lines
lib/test_vmalloc.c +0
-1@@ -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;
lib/test_vmalloc.c static void shuffle_array(int *arr, int n) · line 396
Quoted 10 lines
lib/test_vmalloc.c +3
-2u64 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 <[email protected]>
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".
---
lib/test_vmalloc.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
lib/test_vmalloc.c renamed from lib/test_vmalloc.c~a +3 -5
@@ -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++;
_
Uladzislau Rezki
maintainerQuoted 92 lines · Andrew Morton
Quoted 8 lines · On Thu, 18 Apr 2019 21:39:25 +0200 "Uladzislau Rezki (Sony)"…
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>Quoted 5 lines
the size of
cpumask_tdepends on number of CPUs, therefore just make use ofcpumask_of()inset_cpus_allowed_ptr()as a second argument....
L
Quoted 10 lines
lib/test_vmalloc.c +0
-1@@ -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;lib/test_vmalloc.c static void shuffle_array(int *arr, int n) · line 396
Quoted 10 lines
lib/test_vmalloc.c +3
-2u64 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 <[email protected]>
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 <[email protected]>Cc Uladzislau Rezki <[email protected]>Cc Michal Hocko <[email protected]>Cc Matthew Wilcox <[email protected]>Cc Thomas Garnier <[email protected]>Cc Oleksiy Avramchenko <[email protected]>Cc Steven Rostedt <[email protected]>Cc Joel Fernandes <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc Tejun Heo <[email protected]>Signed-off-by Andrew Morton <[email protected]>---
lib/test_vmalloc.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)lib/test_vmalloc.c renamed from lib/test_vmalloc.c~a +3
-5@@ -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++;
Quoted 2 lines
_
Agree with your slight update.
Thank you!
--
Vlad Rezki
Quoted 8 lines · Uladzislau Rezki (Sony)
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>
Quoted 5 lines
the size of
cpumask_tdepends on number of CPUs, therefore just make use ofcpumask_of()inset_cpus_allowed_ptr()as a second argument.Signed-off-by Uladzislau Rezki (Sony) <[email protected]>
Thanks!