Use CPU_FOREACH rather than expecting CPUs 0 through mp_ncpus-1 to be present.

Don't micro-optimize the uniprocessor case; use the same loop there.

Submitted by:	Bhanu Prakash
Reviewed by:	kib, jhb
This commit is contained in:
Juli Mallett 2011-02-12 02:10:08 +00:00
parent 1591f3f18c
commit 6edf6104a9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=218592

View file

@ -254,16 +254,12 @@ vcnt(SYSCTL_HANDLER_ARGS)
{
int count = *(int *)arg1;
int offset = (char *)arg1 - (char *)&cnt;
#ifdef SMP
int i;
for (i = 0; i < mp_ncpus; ++i) {
CPU_FOREACH(i) {
struct pcpu *pcpu = pcpu_find(i);
count += *(int *)((char *)&pcpu->pc_cnt + offset);
}
#else
count += *(int *)((char *)PCPU_PTR(cnt) + offset);
#endif
return (SYSCTL_OUT(req, &count, sizeof(int)));
}