diff mbox series

[2/2] mmap18: Increase minimal stack mapping to 8KB

Message ID 20200924144246.12750-2-mdoucha@suse.cz
State Superseded
Headers show
Series [1/2] Fix formatting signal name in tst_strstatus() | expand

Commit Message

Martin Doucha Sept. 24, 2020, 2:42 p.m. UTC
The first testcase keeps segfaulting on older kernels with only 4KB initial
stack mapping

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---

Note: Increasing initial stack size to 8KB fixes the segfaults but I'm not
entirely sure whether we shouldn't use PTHREAD_STACK_MIN as the minimal size
instead. Pthread man page isn't entirely clear whether PTHREAD_STACK_MIN is
the minimal value for stack size after it grows to the limit, or the minimal
size of the initial stack mapping (before it starts growing).

On x86_64, PTHREAD_STACK_MIN is 4 pages (16KB). On PPC64, it's 2 pages
(128KB).

 testcases/kernel/syscalls/mmap/mmap18.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Li Wang Sept. 25, 2020, 10:12 a.m. UTC | #1
On Thu, Sep 24, 2020 at 10:43 PM Martin Doucha <mdoucha@suse.cz> wrote:

> The first testcase keeps segfaulting on older kernels with only 4KB initial
> stack mapping
>
> Signed-off-by: Martin Doucha <mdoucha@suse.cz>
>
Reviewed-by: Li Wang <liwang@redhat.com>


> ---
>
> Note: Increasing initial stack size to 8KB fixes the segfaults but I'm not
> entirely sure whether we shouldn't use PTHREAD_STACK_MIN as the minimal
> size
> instead. Pthread man page isn't entirely clear whether PTHREAD_STACK_MIN
> is
> the minimal value for stack size after it grows to the limit, or the
> minimal
> size of the initial stack mapping (before it starts growing).
>

I slightly think the latter, which means PTHREAD_STACK_MIN is the minimal
size of the initial stack mapping. So maybe better to use the
PTHREAD_STACK_MIN
as mmaped_size, we even don't need to have a MAX() there.


>
> On x86_64, PTHREAD_STACK_MIN is 4 pages (16KB). On PPC64, it's 2 pages
> (128KB).


>  testcases/kernel/syscalls/mmap/mmap18.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/mmap/mmap18.c
> b/testcases/kernel/syscalls/mmap/mmap18.c
> index 966bf673e..8b149fb93 100644
> --- a/testcases/kernel/syscalls/mmap/mmap18.c
> +++ b/testcases/kernel/syscalls/mmap/mmap18.c
> @@ -201,10 +201,11 @@ static void grow_stack_fail(size_t stack_size,
> size_t mapped_size)
>  static void run_test(void)
>  {
>         size_t stack_size = 8 * PTHREAD_STACK_MIN;
> +       size_t minsize = MAX(page_size, 8192);
>
> -       grow_stack_success(stack_size, page_size);
> +       grow_stack_success(stack_size, minsize);
>         grow_stack_success(stack_size, stack_size/2);
> -       grow_stack_fail(stack_size, page_size);
> +       grow_stack_fail(stack_size, minsize);
>         grow_stack_fail(stack_size, stack_size/2);
>  }
>
> --
> 2.28.0
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
>
Cyril Hrubis Sept. 25, 2020, 12:34 p.m. UTC | #2
Hi!
> The first testcase keeps segfaulting on older kernels with only 4KB initial
> stack mapping
> 
> Signed-off-by: Martin Doucha <mdoucha@suse.cz>
> ---
> 
> Note: Increasing initial stack size to 8KB fixes the segfaults but I'm not
> entirely sure whether we shouldn't use PTHREAD_STACK_MIN as the minimal size
> instead. Pthread man page isn't entirely clear whether PTHREAD_STACK_MIN is
> the minimal value for stack size after it grows to the limit, or the minimal
> size of the initial stack mapping (before it starts growing).

I vote for passing down PTHREAD_STACK_MIN for the initial mapping.

> On x86_64, PTHREAD_STACK_MIN is 4 pages (16KB). On PPC64, it's 2 pages
> (128KB).
> 
>  testcases/kernel/syscalls/mmap/mmap18.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/mmap/mmap18.c b/testcases/kernel/syscalls/mmap/mmap18.c
> index 966bf673e..8b149fb93 100644
> --- a/testcases/kernel/syscalls/mmap/mmap18.c
> +++ b/testcases/kernel/syscalls/mmap/mmap18.c
> @@ -201,10 +201,11 @@ static void grow_stack_fail(size_t stack_size, size_t mapped_size)
>  static void run_test(void)
>  {
>  	size_t stack_size = 8 * PTHREAD_STACK_MIN;
> +	size_t minsize = MAX(page_size, 8192);
>  
> -	grow_stack_success(stack_size, page_size);
> +	grow_stack_success(stack_size, minsize);
>  	grow_stack_success(stack_size, stack_size/2);
> -	grow_stack_fail(stack_size, page_size);
> +	grow_stack_fail(stack_size, minsize);
>  	grow_stack_fail(stack_size, stack_size/2);
>  }
>  
> -- 
> 2.28.0
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/mmap/mmap18.c b/testcases/kernel/syscalls/mmap/mmap18.c
index 966bf673e..8b149fb93 100644
--- a/testcases/kernel/syscalls/mmap/mmap18.c
+++ b/testcases/kernel/syscalls/mmap/mmap18.c
@@ -201,10 +201,11 @@  static void grow_stack_fail(size_t stack_size, size_t mapped_size)
 static void run_test(void)
 {
 	size_t stack_size = 8 * PTHREAD_STACK_MIN;
+	size_t minsize = MAX(page_size, 8192);
 
-	grow_stack_success(stack_size, page_size);
+	grow_stack_success(stack_size, minsize);
 	grow_stack_success(stack_size, stack_size/2);
-	grow_stack_fail(stack_size, page_size);
+	grow_stack_fail(stack_size, minsize);
 	grow_stack_fail(stack_size, stack_size/2);
 }