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: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]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 [EMAIL PROTECTED]
> with "unsubscribe freebsd-hackers" in the body of the message
> 
> 
> 
> 
> 
> To Unsubscribe: send mail to [EMAIL PROTECTED]
> with "unsubscribe freebsd-hackers" in the body of the message
> 


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to