Re: Scheduler improvements, take 1001, Patch 5/5

2012-10-13 Thread Philip Guenther
On Tue, Oct 9, 2012 at 9:27 AM, Gregor Best g...@ring0.de wrote:
 This patch moves struct schedstate_percpu to kernel land, which I think
 is cleaner than exposing structures for scheduler state to userland,
 especially since grepping for 'schedstate' in /usr/src yielded no
 results outside of /usr/src/sys.

I think this is a misunderstanding about the intent of _KERNEL.  There
are, IMO, two reasons to condition parts of header files on _KERNEL:

1) the header's contents have been specified by a de facto or de jure
standard, but for its own reasons the kernel wants to place additional
info there.

2) the header defines kernel data structures that tools may need (for
crash dump debugging, for example) as well as external symbols like
functions and variables, declarations that can't be used by userspace.

sys/sched.h isn't a standardized header and isn't pulled in by a
standardized header, so (1) isn't an issue.  So, only a non-standard
program is going to be pulling in sys/sched.h anyway.  Unless
there's a reason otherwise, all types and #defines be exposed to it.


(Yeah, the use of CP_* and CPUSTATES by the KERN_CPTIME* sysctl()s is
less than ideal, but this isn't the right way to fix that, IMO.)


Philip Guenther



Re: Scheduler improvements, take 1001, Patch 5/5

2012-10-09 Thread Gregor Best
diff --git a/sys/sched.h b/sys/sched.h
index fb01f21..1784ee2 100644
--- a/sys/sched.h
+++ b/sys/sched.h
@@ -69,8 +69,10 @@
 #ifndef_SYS_SCHED_H_
 #define_SYS_SCHED_H_
 
+#ifdef _KERNEL
 #include sys/queue.h
 #include sys/tree.h
+#endif
 
 /*
  * Posix defines a sched.h which may want to include sys/sched.h
@@ -88,11 +90,9 @@
 #define CP_IDLE4
 #define CPUSTATES  5
 
-#defineSCHED_NQS   32  /* 32 run queues. */
-
+#ifdef _KERNEL
 /*
  * Per-CPU scheduler state.
- * XXX - expose to userland for now.
  */
 struct schedstate_percpu {
struct timeval spc_runtime; /* time curproc started running */
@@ -107,15 +107,13 @@ struct schedstate_percpu {
u_int spc_nrun; /* procs on the run queues */
fixpt_t spc_ldavg;  /* shortest load avg. for this cpu */
 
-   RB_HEAD(prochead, proc) spc_runq;
-
 #ifdef notyet
struct proc *spc_reaper;/* dead proc reaper */
 #endif
LIST_HEAD(,proc) spc_deadproc;
-};
 
-#ifdef _KERNEL
+   RB_HEAD(prochead, proc) spc_runq;
+};
 
 /* spc_flags */
 #define SPCF_SEENRR 0x0001  /* process has seen roundrobin() */
-- 
1.7.6



Re: Scheduler improvements, take 1001, Patch 5/5

2012-10-09 Thread Gregor Best
This patch moves struct schedstate_percpu to kernel land, which I think
is cleaner than exposing structures for scheduler state to userland,
especially since grepping for 'schedstate' in /usr/src yielded no
results outside of /usr/src/sys.

I have not seen negative impact from this, but I haven't yet run a full
userland build (it's running at the moment but the machine I'm building
on is a bit slower than my laptop).

-- 
Gregor Best