Re: git: b75062f23431 - main - riscv: Fix thread0.td_kstack_pages init

From: Brooks Davis <brooks_at_freebsd.org>
Date: Wed, 18 Jan 2023 23:16:02 UTC
On Wed, Jan 18, 2023 at 06:07:47PM -0400, Mitchell Horne wrote:
> 
> 
> On 1/17/23 12:38, Brooks Davis wrote:
> > The branch main has been updated by brooks:
> > 
> > URL: https://cgit.FreeBSD.org/src/commit/?id=b75062f23431fbabef1e7d665cae270b144f71b1
> > 
> > commit b75062f23431fbabef1e7d665cae270b144f71b1
> > Author:     Brooks Davis <brooks@FreeBSD.org>
> > AuthorDate: 2023-01-17 16:36:15 +0000
> > Commit:     Brooks Davis <brooks@FreeBSD.org>
> > CommitDate: 2023-01-17 16:37:42 +0000
> > 
> >      riscv: Fix thread0.td_kstack_pages init
> >      
> >      Commit 0ef3ca7ae37c70e9dc83475dc2e68e98e1c2a418 initialized
> >      thread0.td_kstack_pages to KSTACK_PAGES.  Due to the lack of an
> >      include of opt_kstack_pages.h it used the fallback value of 4 from
> >      machine/param.h. 
> 
> Does this mean that we could/should include opt_kstack_pages.h within 
> machine/param.h (under #ifdef _KERNEL)? This header is both a consumer 
> and provider of the KSTACK_PAGES definition, by virtue of the #ifndef. I 
> think the hidden dependency should be avoided, if possible.

It's possible we should be doing it in that case, but it's not something
we normally do (the only header I can find that does this is
sys/terminal.h).  If we wanted to do this I'd be tempted to make
machine/param.h define some sort of _KSTACK_PAGES_DEFAULT and move the
definition of KSTACK_PAGES to sys/param.h.

It's a bit unfortunate that the kernel config system means KSTACK_PAGES
is only defined if set explicitly and there's no way to tell the opt_
header has been included since it doesn't include guards.

-- Brooks