From owner-svn-soc-all@FreeBSD.ORG Thu May 24 16:36:56 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id B3A17106564A for ; Thu, 24 May 2012 16:36:54 +0000 (UTC) (envelope-from rudot@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Thu, 24 May 2012 16:36:54 +0000 Date: Thu, 24 May 2012 16:36:54 +0000 From: rudot@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120524163654.B3A17106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r236300 - in soc2012/rudot: aux sys/kern X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 May 2012 16:36:56 -0000 Author: rudot Date: Thu May 24 16:36:54 2012 New Revision: 236300 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=236300 Log: the 4bsd scheduler sets the RACCT_PCTCPU resource value, it is not finished yet. Modified: soc2012/rudot/aux/notes.txt soc2012/rudot/sys/kern/kern_racct.c soc2012/rudot/sys/kern/sched_4bsd.c Modified: soc2012/rudot/aux/notes.txt ============================================================================== --- soc2012/rudot/aux/notes.txt Thu May 24 16:23:21 2012 (r236299) +++ soc2012/rudot/aux/notes.txt Thu May 24 16:36:54 2012 (r236300) @@ -1 +1,4 @@ rctl -a process:PID:pcpu:deny=50 works + +sched_4bsd sets the RACCT_PCTCPU resource to the td->ts_pctcpu value in the +schedcpu routine. I will move it probably to the sched_clock. Modified: soc2012/rudot/sys/kern/kern_racct.c ============================================================================== --- soc2012/rudot/sys/kern/kern_racct.c Thu May 24 16:23:21 2012 (r236299) +++ soc2012/rudot/sys/kern/kern_racct.c Thu May 24 16:36:54 2012 (r236300) @@ -140,7 +140,8 @@ [RACCT_SHMSIZE] = RACCT_RECLAIMABLE | RACCT_DENIABLE | RACCT_SLOPPY, [RACCT_WALLCLOCK] = - RACCT_IN_MILLIONS }; + RACCT_IN_MILLIONS, + [RACCT_PCTCPU] = RACCT_RECLAIMABLE | RACCT_DENIABLE }; static void racct_add_racct(struct racct *dest, const struct racct *src) Modified: soc2012/rudot/sys/kern/sched_4bsd.c ============================================================================== --- soc2012/rudot/sys/kern/sched_4bsd.c Thu May 24 16:23:21 2012 (r236299) +++ soc2012/rudot/sys/kern/sched_4bsd.c Thu May 24 16:36:54 2012 (r236300) @@ -68,6 +68,10 @@ dtrace_vtime_switch_func_t dtrace_vtime_switch_func; #endif +#ifdef RACCT +#include +#endif + /* * INVERSE_ESTCPU_WEIGHT is only suitable for statclock() frequencies in * the range 100-256 Hz (approximately). @@ -507,6 +511,9 @@ #endif ts->ts_cpticks = 0; } +#ifdef RACCT + racct_set(p, RACCT_PCTCPU, ts->ts_pctcpu); +#endif /* * If there are ANY running threads in this process, * then don't count it as sleeping. @@ -670,6 +677,18 @@ return (sched_quantum); } +#ifdef RACCT +static int +sched_racct_pcpu_deny(struct thread *td) +{ + struct proc *p; + + p = td->td_proc; + + return (0); +} +#endif + /* * We adjust the priority of the current process. The priority of * a process gets worse as it accumulates CPU time. The cpu usage @@ -708,6 +727,12 @@ ticks - PCPU_GET(switchticks) >= sched_quantum) td->td_flags |= TDF_NEEDRESCHED; +#ifdef RACCT + if (!TD_IS_IDLETHREAD(td) && + sched_racct_pcpu_deny(td)) + td->td_flags |= TDF_NEEDRESCHED; +#endif + stat = DPCPU_PTR(idlestat); stat->oldidlecalls = stat->idlecalls; stat->idlecalls = 0;