From owner-freebsd-hackers Tue Feb 18 19: 8:45 2003 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id ABD1037B401 for ; Tue, 18 Feb 2003 19:08:41 -0800 (PST) Received: from rwcrmhc51.attbi.com (rwcrmhc51.attbi.com [204.127.198.38]) by mx1.FreeBSD.org (Postfix) with ESMTP id E92CC43F75 for ; Tue, 18 Feb 2003 19:08:40 -0800 (PST) (envelope-from julian@elischer.org) Received: from interjet.elischer.org (12-232-168-4.client.attbi.com[12.232.168.4]) by rwcrmhc51.attbi.com (rwcrmhc51) with ESMTP id <2003021903084005100cq4ase>; Wed, 19 Feb 2003 03:08:40 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id TAA26884; Tue, 18 Feb 2003 19:08:38 -0800 (PST) Date: Tue, 18 Feb 2003 19:08:36 -0800 (PST) From: Julian Elischer To: Mooneer Salem Cc: FreeBSD Hackers Subject: RE: Per-jail CPU limits? In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Firstly, this is a -current question so 'hackers' is not the best place.. secondly all teh kse stuff is ONLY used for a threaded program. Unthreaded programs (not compiled with libkse) are permanently bound to their KSE. On Tue, 18 Feb 2003, Mooneer Salem wrote: > Hello, > > An update: > > * I changed a block of code in kse_reassign() to the following: > > if ((td = kg->kg_last_assigned)) { > do { > td = TAILQ_NEXT(td, td_runq); > } while (td && jail_check_cpu(td)); > } else { > td = TAILQ_FIRST(&kg->kg_runq); > } > > * jail_check_cpu() has been placed in kern_jail.c and looks like the > following: > > int > jail_check_cpu(td) > struct thread *td; > { > struct prison *pr = td->td_ucred->cr_prison; > u_int totalcpu = td->td_ksegrp->kg_estcpu; > > if (!pr) { > /* Not in jail; don't care about its CPU. */ > return 0; > } > > printf("cpu debug: %d\n", totalcpu); > > /* By default, return 0. */ > return 0; > } > > jail_check_cpu() is a passthrough function that accepts by default and is > supposed > to print the total CPU used to the console. After recompiling the kernel and > rebooting, > I tried to start a jail. Unfortunately, I didn't see the message that should > have > been printed. > > I believe kse_reassign() might only be called under certain circumstances > (e.g. when > SMP is involved). If that's the case, another function will need to be found > to > insert the code in. > > Thanks, > > -- > Mooneer Salem > GPLTrans: http://www.translator.cx/ > lifeafterking.org: http://www.lifeafterking.org/ > > -----Original Message----- > From: owner-freebsd-hackers@FreeBSD.ORG > [mailto:owner-freebsd-hackers@FreeBSD.ORG]On Behalf Of Mooneer Salem > Sent: Tuesday, February 18, 2003 5:07 PM > To: FreeBSD Hackers > Subject: Per-jail CPU limits? > > > Hello, > > I've been looking at the kernel source, in particular the scheduler > in the past few weeks. I found a place in kern_switch.c where per-jail > CPU controls could be added (in particular, in the kse_reassign() function). > >From looking at that function, I could loop through td_runq until I either: > > 1. Found a thread that isn't jailed, > 2. Found a jailed thread, but determine it's safe to let it run because > it does not go over sysctl-defined limits, or > 3. Find no usable thread, in which case the KSE would theoretically switch > over to the idle process until it's time to repeat the process again. > > This should allow the use of the standard FreeBSD scheduler, except for > the jail limits. The question is, how do we determine the total CPU used > by the jail? I found the kg_estcpu entry in struct ksegrp, which the thread > has a pointer to, but would that be enough? Is there a different approach we > could take that would solve this problem? > > Thanks, > > -- > Mooneer Salem > GPLTrans: http://www.translator.cx/ > lifeafterking.org: http://www.lifeafterking.org/ > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message > > > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message