Discussion:
Which should kcpuset use cpuid or cpu index?
Kengo NAKAHARA
2014-09-08 02:28:46 UTC
Permalink
Hi,

I have a question about kcpuset. Referring "man 9 kcpuset", the APIs
need cpuid (the type is cpuid_t) to identify CPU. However, the callers
such as idle_loop() sys/kern/kern_idle.c use cpu index (the type is u_int).

cpu index means return value of cpu_index(), and cpu index is sequential
number. On the other hand, cpuid means struct cpu_info.ci_cpuid and cpuid
is non-sequential number at least x86 and sparc architectures. So, cpu index
is different from cpuid. Which should kcpuset use cpuid or cpu index?

I think kcpuset APIs should use sequentail u_int cpu index because of
efficient and easy-to-understand usage of bitmap.
Could you comment this idea?

Thanks,
--
//////////////////////////////////////////////////////////////////////
Internet Initiative Japan Inc.

Device Engineering Section,
Core Product Development Department,
Product Division,
Technology Unit

Kengo NAKAHARA <k-***@iij.ad.jp>
Matt Thomas
2014-09-08 03:34:22 UTC
Permalink
Post by Kengo NAKAHARA
I have a question about kcpuset. Referring "man 9 kcpuset", the APIs
need cpuid (the type is cpuid_t) to identify CPU. However, the callers
such as idle_loop() sys/kern/kern_idle.c use cpu index (the type is u_int).
cpu index means return value of cpu_index(), and cpu index is sequential
number. On the other hand, cpuid means struct cpu_info.ci_cpuid and cpuid
is non-sequential number at least x86 and sparc architectures. So, cpu index
is different from cpuid. Which should kcpuset use cpuid or cpu index?
ci_cpuid is MD and has no standard semantics.

Use cpu_index(ci) (curcpu()->ci_index)
Kengo NAKAHARA
2014-09-08 03:51:11 UTC
Permalink
Hi,

Thank you for answer.
Post by Matt Thomas
Post by Kengo NAKAHARA
I have a question about kcpuset. Referring "man 9 kcpuset", the APIs
need cpuid (the type is cpuid_t) to identify CPU. However, the callers
such as idle_loop() sys/kern/kern_idle.c use cpu index (the type is u_int).
cpu index means return value of cpu_index(), and cpu index is sequential
number. On the other hand, cpuid means struct cpu_info.ci_cpuid and cpuid
is non-sequential number at least x86 and sparc architectures. So, cpu index
is different from cpuid. Which should kcpuset use cpuid or cpu index?
ci_cpuid is MD and has no standard semantics.
Use cpu_index(ci) (curcpu()->ci_index)
I see. So, should kcpuset APIs use u_int (not cpuid_t)? As cpu_index()
which is MI function in sys/sys/cpu.h returns u_int type.

Thanks,
--
//////////////////////////////////////////////////////////////////////
Internet Initiative Japan Inc.

Device Engineering Section,
Core Product Development Department,
Product Division,
Technology Unit

Kengo NAKAHARA <k-***@iij.ad.jp>
Matt Thomas
2014-09-08 03:52:58 UTC
Permalink
Post by Kengo NAKAHARA
Hi,
Thank you for answer.
Post by Matt Thomas
Post by Kengo NAKAHARA
I have a question about kcpuset. Referring "man 9 kcpuset", the APIs
need cpuid (the type is cpuid_t) to identify CPU. However, the callers
such as idle_loop() sys/kern/kern_idle.c use cpu index (the type is u_int).
cpu index means return value of cpu_index(), and cpu index is sequential
number. On the other hand, cpuid means struct cpu_info.ci_cpuid and cpuid
is non-sequential number at least x86 and sparc architectures. So, cpu index
is different from cpuid. Which should kcpuset use cpuid or cpu index?
ci_cpuid is MD and has no standard semantics.
Use cpu_index(ci) (curcpu()->ci_index)
I see. So, should kcpuset APIs use u_int (not cpuid_t)? As cpu_index()
which is MI function in sys/sys/cpu.h returns u_int type.
I don't think it matters since it's a u_long.
Kengo NAKAHARA
2014-09-08 04:47:20 UTC
Permalink
Hi,
Post by Matt Thomas
Post by Kengo NAKAHARA
Post by Matt Thomas
ci_cpuid is MD and has no standard semantics.
Use cpu_index(ci) (curcpu()->ci_index)
I see. So, should kcpuset APIs use u_int (not cpuid_t)? As cpu_index()
which is MI function in sys/sys/cpu.h returns u_int type.
I don't think it matters since it's a u_long.
Surely, it does not matter for compile time and run time. But reading
source, it causes confusion as if kcpuset APIs use cpuid. In fact,
as you indicated, the APIs use cpu index.

I think it would avoid misunderstanding to use u_int for kcpuset APIs.
# It would be friendly to novice like me :)

Thanks,
--
//////////////////////////////////////////////////////////////////////
Internet Initiative Japan Inc.

Device Engineering Section,
Core Product Development Department,
Product Division,
Technology Unit

Kengo NAKAHARA <k-***@iij.ad.jp>
Loading...