lib/test_vmalloc.c: do not create cpumask_t variable on stack [Linux 5.1]

lib/test_vmalloc.c: do not create cpumask_t variable on stack [Linux 5.1]

This Linux kernel change "lib/test_vmalloc.c: do not create cpumask_t variable on stack" is included in the Linux 5.1 release. This change is authored by Uladzislau Rezki (Sony) <urezki [at]> on Thu Apr 25 22:23:47 2019 -0700. The commit for this change in Linux stable tree is e789803 (patch).

lib/test_vmalloc.c: 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:

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

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) <>
Reviewed-by: Andrew Morton <>
Reviewed-by: Roman Gushchin <>
Cc: Uladzislau Rezki <>
Cc: Michal Hocko <>
Cc: Matthew Wilcox <>
Cc: Thomas Garnier <>
Cc: Oleksiy Avramchenko <>
Cc: Steven Rostedt <>
Cc: Joel Fernandes <>
Cc: Thomas Gleixner <>
Cc: Ingo Molnar <>
Cc: Tejun Heo <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>

There are 6 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 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 83cdcaa..f832b09 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;

Leave a Reply

Your email address will not be published. Required fields are marked *