[LTP] [PATCH] thp01: Find largest arguments size
Li Wang
liwang@redhat.com
Fri Sep 1 09:05:20 CEST 2017
On Thu, Aug 31, 2017 at 4:34 PM, Richard Palethorpe
<rpalethorpe@suse.com> wrote:
> Because of kernel commit da029c11e6b1 the arguments size for exec has been
> reduced considerably. This causes exec to fail with E2BIG, so we call it
> repeatedly with a decreasing number of arguments until it is successful.
>
> As far as I know, there is no other reliable and easy way to determine the
> maximum argument length.
>
> Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
> ---
> testcases/kernel/mem/thp/thp01.c | 83 ++++++++++++++++++++++++----------------
> 1 file changed, 50 insertions(+), 33 deletions(-)
>
> diff --git a/testcases/kernel/mem/thp/thp01.c b/testcases/kernel/mem/thp/thp01.c
> index 101a9b5c8..b90b9b637 100644
> --- a/testcases/kernel/mem/thp/thp01.c
> +++ b/testcases/kernel/mem/thp/thp01.c
> @@ -30,6 +30,7 @@
> * ....
> */
>
> +#include <errno.h>
> #include <sys/types.h>
> #include <sys/resource.h>
> #include <sys/wait.h>
> @@ -38,56 +39,72 @@
> #include <stdlib.h>
> #include <unistd.h>
> #include "mem.h"
> +#include "tst_minmax.h"
> +#include "tst_safe_sysv_ipc.h"
>
> -#define ARRAY_SZ 256
> +#define ARGS_SZ 256
>
> -static int ps;
> -static long length;
> -static char *array[ARRAY_SZ];
> +static int shm_id;
> +static char *args[ARGS_SZ];
> static char *arg;
> -static struct rlimit rl = {
> - .rlim_cur = RLIM_INFINITY,
> - .rlim_max = RLIM_INFINITY,
> -};
> +static long *arg_count;
Two queries:
1. Can't we declare the arg_count just as a global variable? why
should we take use of share memory, only for the loop counting?
2. The kernel patch limit all arg stack usage to at most 75% of _STK_LIM (6MB),
and here the size of arg_len is 32*PAGE_SIZE. So it means that there
almost only have 6MB/(PAGE_SIZE*32) numbers can be accepted in
args[(*arg_count)], if it is a ppc64 machine(*arg_count == 3) that's
OK, but if a system PAGE_SIZE > 192KB, then the test will be break and
your loop is absolutely useless. About that, if we shrink the arg_len
size, things would be better I guess.
--
Li Wang
liwang@redhat.com
More information about the ltp
mailing list