[Crash-utility] [PATCH] cmdline: Add a new "--machdep stacksize=<value>".

Dave Anderson anderson at redhat.com
Mon Oct 1 13:37:10 UTC 2018



----- Original Message -----
> Implemented support for 16k stack size that was introduced by commit
> 6538b8ea886e472f4431db8ca1d60478f838d14b titled "x86_64: expand kernel
> stack to 16K".
> Without the patch, kernels has 16k stack, leading to errors in commands
> such as "bt" and any command regarding 8K stack.
> Add a new "--machdep stacksize=<value>" option that can be used to
> override the default machdep->stacksize value which is 8k.

The x86_64 default value of 8K is basically a leftover value that each of 
the architectures originally used for setting machdep->stacksize.  But for 
quite some time now, those values should get overridden later on here
in task_init():

        STRUCT_SIZE_INIT(task_union, "task_union");
        STRUCT_SIZE_INIT(thread_union, "thread_union");

        if (VALID_SIZE(task_union) && (SIZE(task_union) != STACKSIZE())) {
                error(WARNING, "\nnon-standard stack size: %ld\n",
                        len = SIZE(task_union));
                machdep->stacksize = len;
        } else if (VALID_SIZE(thread_union) &&
                ((len = SIZE(thread_union)) != STACKSIZE())) {
                machdep->stacksize = len;
        } else if (!VALID_SIZE(thread_union) && !VALID_SIZE(task_union)) {
                if (kernel_symbol_exists("__start_init_task") &&
                    kernel_symbol_exists("__end_init_task")) {
                        len = symbol_value("__end_init_task");
                        len -= symbol_value("__start_init_task");
                        ASSIGN_SIZE(thread_union) = len;
                        machdep->stacksize = len;
                }
        }

As of Linux 4.18 at least, x86_64 still uses the thread_union declaration.
For example:

  crash> thread_union
  union thread_union {
      struct task_struct task;
      unsigned long stack[2048];
  }
  SIZE: 16384
  crash>

On what kernel version are you seeing the obsolete 8k stacksize being used?
What does the command above show on your system?

Thanks,
  Dave



 
> 
> Signed-off-by: Sean Fu <fxinrong at gmail.com>
> ---
>  x86_64.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/x86_64.c b/x86_64.c
> index 7d01140..1798f05 100644
> --- a/x86_64.c
> +++ b/x86_64.c
> @@ -5716,6 +5716,15 @@ parse_cmdline_args(void)
>  						continue;
>  					}
>  				}
> +			} else if (STRNEQ(arglist[i], "stacksize=")) {
> +	                        p = arglist[i] + strlen("stacksize=");
> +				if (strlen(p)) {
> +					value = stol(p, RETURN_ON_ERROR|QUIET, &errflag);
> +					if (!errflag) {
> +						machdep->stacksize = value;
> +						continue;
> +					}
> +				}
>  			}
>  	
>  			error(WARNING, "ignoring --machdep option: %s\n", arglist[i]);
> --
> 2.6.2
> 
> 




More information about the Crash-utility mailing list