lkml.org 
[lkml]   [2011]   [Dec]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [RFC PATCH 2/4] sched: Adding gang scheduling infrastrucure
    From
    Date
    On Mon, 2011-12-19 at 14:04 +0530, Nikunj A. Dadhania wrote:

    > +static void gang_sched_member(void *info)
    > +{
    > + struct task_group *tg = (struct task_group *) info;
    > + struct cfs_rq *cfs_rq;
    > + struct rq *rq;
    > + int cpu;
    > + unsigned long flags;
    > +
    > + cpu = smp_processor_id();
    > + cfs_rq = tg->cfs_rq[cpu];
    > + rq = cfs_rq->rq;
    > +
    > + raw_spin_lock_irqsave(&rq->lock, flags);
    > +
    > + /* Check if the runqueue has runnable tasks */
    > + if (cfs_rq->nr_running) {
    > + /* Favour this task group and set need_resched flag,
    > + * added by following patches */

    That's just plain insanity, patch 3 is all of 4 lines, why split that
    and have an incomplete patch here?

    > + }
    > + raw_spin_unlock_irqrestore(&rq->lock, flags);
    > +}
    > +
    > +#define GANG_SCHED_GRANULARITY 8

    Why have this magical number to begin with?

    > +void gang_sched(struct task_group *tg, struct rq *rq)
    > +{
    > + /* We do not gang sched here */
    > + if (rq->gang_leader == 0 || !tg || tg->gang == 0)
    > + return;
    > +
    > + /* Yes thats the leader */
    > + if (rq->gang_leader == 1) {
    > +
    > + if (!in_interrupt() && !irqs_disabled()) {

    How can this ever happen, schedule() can't be called from interrupt
    context and post_schedule() ensures interrupts are enabled.

    > + smp_call_function_many(rq->gang_cpumask,
    > + gang_sched_member, tg, 0);

    See this is just not going to happen..

    > + rq->gang_schedule = 0;
    > + }
    > +
    > + } else {
    > + /*
    > + * find the gang leader according to the span,
    > + * currently we have it as 8cpu, this can be made
    > + * dynamic
    > + */
    > + struct sched_domain *sd;
    > + unsigned int count;
    > + int i;
    > +
    > + for_each_domain(cpu_of(rq), sd) {
    > + count = 0;
    > + for_each_cpu(i, sched_domain_span(sd))
    > + count++;

    That's just incompetent; there's cpumask_weight(), also that's called
    sd->span_weight.

    > + if (count >= GANG_SCHED_GRANULARITY)
    > + break;
    > + }
    > +
    > + if (sd && cpu_of(rq) == domain_first_cpu(sd)) {
    > + printk(KERN_INFO "Selected CPU %d as gang leader\n",
    > + cpu_of(rq));
    > + rq->gang_leader = 1;
    > + rq->gang_cpumask = sched_domain_span(sd);
    > + } else if (sd) {
    > + /*
    > + * A fellow cpu, it will receive gang
    > + * initiations from the gang leader now
    > + */
    > + rq->gang_leader = 0;
    > + }
    > + }
    > +}


    \
     
     \ /
      Last update: 2011-12-19 16:55    [W:4.602 / U:0.036 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site