[PATCH] Add MAXCPU as a kernel config option and quality discussion on this

Bruce Evans brde at optusnet.com.au
Sat Jul 9 07:02:43 UTC 2011


On Fri, 8 Jul 2011, Peter Wemm wrote:

> On Fri, Jul 8, 2011 at 8:37 AM, Attilio Rao <attilio at freebsd.org> wrote:
>> I've made this patch for making MAXCPU a kernel config option:
>> http://www.freebsd.org/~attilio/maxcpu_kernel_opt.diff
>
> The problem with this is now you have to update all the kernel module
> build glue to create opt_maxcpu.h, including 3rd party modules.
>
> What about userland?
>
> We have constructs like this:
>
> amd64/include/reg.h:
> #if defined(_KERNEL) && !defined(_STANDALONE)
> #include "opt_compat.h"
> #endif
>
> Or even:
> #if defined(SMP) || defined(KLD_MODULE)
> #define MAXCPU		32
> #else
> #define MAXCPU		1
> #endif /* SMP || KLD_MODULE */
>
> Putting opt_*.h references in include files is an invasive change and
> something we've gone to a great deal of effort to avoid.

Putting them in opt_global.h is less invasive, but works little better
since (actually modular) modules can't depend on options but opt_global.h
gives options.  This is handled well mainly for the SMP option since it
is so important, and I'm not sure if it still works for that either.
E.g., on amd64 and i386, modules use pessimized non-inline versions of
all atomic ops.  Other arches don't bother with the non-inlining.  They
also don't use SMP ifdefs in atomic.h, so this doesn't seem to break
modules but just loses any possible optimizations for the non-SMP case.

Bruce


More information about the freebsd-arch mailing list