Gavin Maltby wrote:
Hi
On 07/11/06 07:19, Oliver Yang wrote:
I have a question about last member of kmem_cache structure.
Why the elements number of cache_cpu is 1 as below definition, but on
SMP system, it's actual elements number is equal to the cpu numbers?
233 struct kmem_cache {
....................................................................
297
298 /*
299 * Per-CPU layer
300 */
301 kmem_cpu_cache_t cache_cpu[1]; /* max_ncpus actual
elements */
302 };
You can't define an array with a variable number of elements, and we
only want
any array sized on the maximum number of cpus that can ever be present
during
this OS instance (on x86 that is equal to the number present at boot,
on sparc
with DR it can grow and max_ncpus is the maximum number the platform
supports
even if not all present at boot).
Thanks a lot!
You are right. It should be max cpu numbers of the system support, but
both x86 and sparc.
Here is default vaule of max_ncpus on my platform:
> max_ncpus/X
max_ncpus:
max_ncpus: 20
I also get this answer from the code:
http://cvs.opensolaris.org/source/xref/on/usr/src/uts/common/os/kmem.c#kmem_cache_create
2020 size_t csize = KMEM_CACHE_SIZE(max_ncpus);
http://cvs.opensolaris.org/source/xref/on/usr/src/uts/common/sys/kmem_impl.h#KMEM_CPU_CACHE_SIZE
204 #define KMEM_CACHE_SIZE(ncpus) \
205 ((size_t)(&((kmem_cache_t *)0)->cache_cpu[ncpus]))
206
Thanks for your instructions. :-)
--
Cheers,
----------------------------------------------------------------------
Oliver Yang | OPG Engineering Operation | [EMAIL PROTECTED] | x82229
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code