Subject: Re: Adding a size parameter to stackgap_init()
To: Emmanuel Dreyfus <manu@netbsd.org>
From: Jaromir Dolecek <jdolecek@netbsd.org>
List: tech-kern
Date: 03/16/2002 22:51:53
IIRC the stack gap is reserved at process creation time and it's
not possible to decide later you'd need bigger stack gap.  You
definitely want to check this before changing stackgap_init*().

Jaromir

Emmanuel Dreyfus wrote:
> Hi!
> 
> This is still about increasing STACKGAPLEN. I suggested increasing it,
> but I have situations where the requiered space cannot be determined at
> build time (eg: if you need one struct systent per swap object, this
> makes 1048 * number of swap objects)
> 
> It would be nice to have a size parameter to stackgap_init(). To avoid a
> large amount of modification, I propose to introduce
> stackgap_init_sz(), which would do a stackgap initialization with a size
> argument, and to define stackgap_init() as stackgap_init_sz() with a
> STACKGAPLEN size.
> 
> Here is the patch. Is this nice enough to be committed?
> 
> 
> Index: compat_util.c
> ===================================================================
> RCS file: /cvsroot/syssrc/sys/compat/common/compat_util.c,v
> retrieving revision 1.21
> diff -U2 -r1.21 compat_util.c
> --- compat_util.c       2001/11/13 02:07:59     1.21
> +++ compat_util.c       2002/03/16 19:32:26
> @@ -239,6 +239,7 @@
>  
>  caddr_t
> -stackgap_init(e)
> +stackgap_init_sz(e, size)
>         const struct emul *e;
> +       size_t size;
>  {
>         struct proc *p = curproc;               /* XXX */
> @@ -246,5 +247,5 @@
>  #define szsigcode ((caddr_t)(e->e_esigcode - e->e_sigcode))
>         return (caddr_t)(((unsigned long)p->p_psstr - (unsigned
> long)szsigcode
> -               - STACKGAPLEN) & ~ALIGNBYTES);
> +               - size) & ~ALIGNBYTES);
>  #undef szsigcode
>  }
> Index: compat_util.h
> ===================================================================
> RCS file: /cvsroot/syssrc/sys/compat/common/compat_util.h,v
> retrieving revision 1.9
> diff -U2 -r1.9 compat_util.h
> --- compat_util.h       2001/01/22 19:50:56     1.9
> +++ compat_util.h       2002/03/16 19:32:26
> @@ -68,4 +68,5 @@
>  #define        _COMPAT_UTIL_H_
>  
> +#include <sys/exec.h>
>  struct emul;
>  struct proc;
> @@ -77,5 +78,6 @@
>  };
>  
> -caddr_t        stackgap_init __P((const struct emul *));
> +caddr_t        stackgap_init_sz __P((const struct emul *, size_t));
> +#define stackgap_init(e) stackgap_init_sz((e),STACKGAPLEN)
>  void   *stackgap_alloc __P((caddr_t *, size_t));
>  
> -- 
> Emmanuel Dreyfus
> - Quel est le meilleur moyen d'accelerer un PC?
> - 9,81 m/s^2
> manu@netbsd.org
> 


-- 
Jaromir Dolecek <jdolecek@NetBSD.org> http://www.NetBSD.org/Ports/i386/ps2.html
-=- We should be mindful of the potential goal, but as the tantric    -=-
-=- Buddhist masters say, ``You may notice during meditation that you -=-
-=- sometimes levitate or glow.   Do not let this distract you.''     -=-