summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_proc.c
diff options
context:
space:
mode:
authoradrian <adrian@FreeBSD.org>2014-10-18 19:36:11 +0000
committeradrian <adrian@FreeBSD.org>2014-10-18 19:36:11 +0000
commit9b44fe556be01b7365289ce03c873448f9158644 (patch)
tree001cb1730d8c530fa2dede702f8a9a45fb21aef9 /sys/kern/kern_proc.c
parent073b7e1f4d4771f686e7f67b7d18d1b9fc02cdb8 (diff)
downloadFreeBSD-src-9b44fe556be01b7365289ce03c873448f9158644.zip
FreeBSD-src-9b44fe556be01b7365289ce03c873448f9158644.tar.gz
Update the ULE scheduler + thread and kinfo structs to use int for cpuid
rather than u_char. To try and play nice with the ABI, the u_char CPU ID values are clamped at 254. The new fields now contain the full CPU ID, or -1 for no cpu. Differential Revision: D955 Reviewed by: jhb, kib Sponsored by: Norse Corp, Inc.
Diffstat (limited to 'sys/kern/kern_proc.c')
-rw-r--r--sys/kern/kern_proc.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index 41cd304..495139f 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -984,6 +984,25 @@ fill_kinfo_thread(struct thread *td, struct kinfo_proc *kp, int preferthread)
kp->ki_wchan = td->td_wchan;
kp->ki_pri.pri_level = td->td_priority;
kp->ki_pri.pri_native = td->td_base_pri;
+
+ /*
+ * Note: legacy fields; clamp at the old NOCPU value and/or
+ * the maximum u_char CPU value.
+ */
+ if (td->td_lastcpu == NOCPU)
+ kp->ki_lastcpu_old = NOCPU_OLD;
+ else if (td->td_lastcpu > MAXCPU_OLD)
+ kp->ki_lastcpu_old = MAXCPU_OLD;
+ else
+ kp->ki_lastcpu_old = td->td_lastcpu;
+
+ if (td->td_oncpu == NOCPU)
+ kp->ki_oncpu_old = NOCPU_OLD;
+ else if (td->td_oncpu > MAXCPU_OLD)
+ kp->ki_oncpu_old = MAXCPU_OLD;
+ else
+ kp->ki_oncpu_old = td->td_oncpu;
+
kp->ki_lastcpu = td->td_lastcpu;
kp->ki_oncpu = td->td_oncpu;
kp->ki_tdflags = td->td_flags;
@@ -1164,6 +1183,11 @@ freebsd32_kinfo_proc_out(const struct kinfo_proc *ki, struct kinfo_proc32 *ki32)
CP(*ki, *ki32, ki_rqindex);
CP(*ki, *ki32, ki_oncpu);
CP(*ki, *ki32, ki_lastcpu);
+
+ /* XXX TODO: wrap cpu value as appropriate */
+ CP(*ki, *ki32, ki_oncpu_old);
+ CP(*ki, *ki32, ki_lastcpu_old);
+
bcopy(ki->ki_tdname, ki32->ki_tdname, TDNAMLEN + 1);
bcopy(ki->ki_wmesg, ki32->ki_wmesg, WMESGLEN + 1);
bcopy(ki->ki_login, ki32->ki_login, LOGNAMELEN + 1);
OpenPOWER on IntegriCloud