Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Feb 2003 19:08:36 -0800 (PST)
From:      Julian Elischer <julian@elischer.org>
To:        Mooneer Salem <mooneer@translator.cx>
Cc:        FreeBSD Hackers <freebsd-hackers@freebsd.org>
Subject:   RE: Per-jail CPU limits?
Message-ID:  <Pine.BSF.4.21.0302181907050.25812-100000@InterJet.elischer.org>
In-Reply-To: <FHEMJMOKKMJDGKFOHHEPMEEBFAAA.mooneer@translator.cx>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0302181907050.25812-100000>