public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: "Nikunj A. Dadhania" <nikunj@linux.vnet.ibm.com>
Cc: mingo@elte.hu, linux-kernel@vger.kernel.org,
	vatsa@linux.vnet.ibm.com, bharata@linux.vnet.ibm.com
Subject: Re: [RFC PATCH 2/4] sched: Adding gang scheduling infrastrucure
Date: Mon, 19 Dec 2011 16:51:44 +0100	[thread overview]
Message-ID: <1324309904.24621.15.camel@twins> (raw)
In-Reply-To: <20111219083424.32311.23559.stgit@abhimanyu.in.ibm.com>

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;
> +		}
> +	}
> +}

  reply	other threads:[~2011-12-19 15:51 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-19  8:33 [RFC PATCH 0/4] Gang scheduling in CFS Nikunj A. Dadhania
2011-12-19  8:34 ` [RFC PATCH 1/4] sched: Adding cpu.gang file to cpu cgroup Nikunj A. Dadhania
2011-12-19  8:34 ` [RFC PATCH 2/4] sched: Adding gang scheduling infrastrucure Nikunj A. Dadhania
2011-12-19 15:51   ` Peter Zijlstra [this message]
2011-12-19 16:51     ` Peter Zijlstra
2011-12-20  1:43       ` Nikunj A Dadhania
2011-12-20  1:39     ` Nikunj A Dadhania
2011-12-19  8:34 ` [RFC PATCH 3/4] sched: Gang using set_next_buddy Nikunj A. Dadhania
2011-12-19  8:35 ` [RFC PATCH 4/4] sched:Implement set_gang_buddy Nikunj A. Dadhania
2011-12-19 15:51   ` Peter Zijlstra
2011-12-20  1:43     ` Nikunj A Dadhania
2011-12-26  2:30     ` Nikunj A Dadhania
2011-12-19 11:23 ` [RFC PATCH 0/4] Gang scheduling in CFS Ingo Molnar
2011-12-19 11:44   ` Avi Kivity
2011-12-19 11:50     ` Nikunj A Dadhania
2011-12-19 11:59       ` Avi Kivity
2011-12-19 12:06         ` Nikunj A Dadhania
2011-12-19 12:50           ` Avi Kivity
2011-12-19 13:09             ` Nikunj A Dadhania
2011-12-19 11:45   ` Nikunj A Dadhania
2011-12-19 13:22     ` Nikunj A Dadhania
2011-12-19 16:28       ` Ingo Molnar
2011-12-21 10:39   ` Nikunj A Dadhania
2011-12-21 10:43     ` Avi Kivity
2011-12-23  3:20       ` Nikunj A Dadhania
2011-12-23 10:36         ` Ingo Molnar
2011-12-25 10:58           ` Avi Kivity
2011-12-25 15:45             ` Avi Kivity
2011-12-26  3:14             ` Nikunj A Dadhania
2011-12-26  9:05               ` Avi Kivity
2011-12-26 11:33                 ` Nikunj A Dadhania
2011-12-26 11:41                   ` Avi Kivity
2011-12-27  1:47                     ` Nikunj A Dadhania
2011-12-27  9:15                       ` Avi Kivity
2011-12-27 10:24                         ` Nikunj A Dadhania
2011-12-27  3:15               ` Nikunj A Dadhania
2011-12-27  9:17                 ` Avi Kivity
2011-12-27  9:44                   ` Nikunj A Dadhania
2011-12-27  9:51                     ` Avi Kivity
2011-12-27 10:10                       ` Nikunj A Dadhania
2011-12-27 10:34                         ` Avi Kivity
2011-12-27 10:43                           ` Nikunj A Dadhania
2011-12-27 10:53                             ` Avi Kivity
2011-12-30  9:51             ` Ingo Molnar
2011-12-30 10:10               ` Nikunj A Dadhania
2011-12-31  2:21                 ` Nikunj A Dadhania
2012-01-02  4:20                   ` Nikunj A Dadhania
2012-01-02  9:39                     ` Avi Kivity
2012-01-02 10:22                       ` Nikunj A Dadhania
2012-01-02  9:37                   ` Avi Kivity
2012-01-02 10:30                     ` Nikunj A Dadhania
2012-01-02 13:33                       ` Avi Kivity
2012-01-04 10:52                     ` Nikunj A Dadhania
2012-01-04 14:41                       ` Avi Kivity
2012-01-04 14:56                         ` Srivatsa Vaddagiri
2012-01-04 17:13                           ` Avi Kivity
2012-01-05  6:57                             ` Nikunj A Dadhania
2012-01-04 16:47                         ` Rik van Riel
2012-01-04 17:16                           ` Avi Kivity
2012-01-04 20:56                             ` Rik van Riel
2012-01-04 21:31                             ` Peter Zijlstra
2012-01-04 21:41                               ` Avi Kivity
2012-01-05  9:10                                 ` Ingo Molnar
2012-02-20  8:08                                   ` Nikunj A Dadhania
2012-02-20  8:14                                     ` Ingo Molnar
2012-02-20 10:51                                     ` Peter Zijlstra
2012-02-20 11:53                                       ` Nikunj A Dadhania
2012-02-20 12:02                                         ` Srivatsa Vaddagiri
2012-02-20 12:14                                           ` Peter Zijlstra
2012-01-05  2:10                         ` Nikunj A Dadhania
2011-12-19 15:51 ` Peter Zijlstra
2011-12-19 16:09   ` Alan Cox
2011-12-19 22:10   ` Benjamin Herrenschmidt
2011-12-20  1:56   ` Nikunj A Dadhania
2011-12-20  8:52   ` Jeremy Fitzhardinge

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1324309904.24621.15.camel@twins \
    --to=peterz@infradead.org \
    --cc=bharata@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=nikunj@linux.vnet.ibm.com \
    --cc=vatsa@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox