Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d6d5cfaf authored by Nick Piggin's avatar Nick Piggin Committed by Linus Torvalds
Browse files

[PATCH] sched: less newidle locking



Similarly to the earlier change in load_balance, only lock the runqueue in
load_balance_newidle if the busiest queue found has a nr_running > 1.  This
will reduce frequency of expensive remote runqueue lock aquisitions in the
schedule() path on some workloads.

Signed-off-by: default avatarNick Piggin <npiggin@suse.de>
Acked-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 67f9a619
Loading
Loading
Loading
Loading
+10 −7
Original line number Original line Diff line number Diff line
@@ -2104,8 +2104,7 @@ static int load_balance(int this_cpu, runqueue_t *this_rq,
		 */
		 */
		double_lock_balance(this_rq, busiest);
		double_lock_balance(this_rq, busiest);
		nr_moved = move_tasks(this_rq, this_cpu, busiest,
		nr_moved = move_tasks(this_rq, this_cpu, busiest,
						imbalance, sd, idle,
					imbalance, sd, idle, &all_pinned);
						&all_pinned);
		spin_unlock(&busiest->lock);
		spin_unlock(&busiest->lock);


		/* All tasks on this runqueue were pinned by CPU affinity */
		/* All tasks on this runqueue were pinned by CPU affinity */
@@ -2200,18 +2199,22 @@ static int load_balance_newidle(int this_cpu, runqueue_t *this_rq,


	BUG_ON(busiest == this_rq);
	BUG_ON(busiest == this_rq);


	schedstat_add(sd, lb_imbalance[NEWLY_IDLE], imbalance);

	nr_moved = 0;
	if (busiest->nr_running > 1) {
		/* Attempt to move tasks */
		/* Attempt to move tasks */
		double_lock_balance(this_rq, busiest);
		double_lock_balance(this_rq, busiest);

	schedstat_add(sd, lb_imbalance[NEWLY_IDLE], imbalance);
		nr_moved = move_tasks(this_rq, this_cpu, busiest,
		nr_moved = move_tasks(this_rq, this_cpu, busiest,
					imbalance, sd, NEWLY_IDLE, NULL);
					imbalance, sd, NEWLY_IDLE, NULL);
		spin_unlock(&busiest->lock);
	}

	if (!nr_moved)
	if (!nr_moved)
		schedstat_inc(sd, lb_failed[NEWLY_IDLE]);
		schedstat_inc(sd, lb_failed[NEWLY_IDLE]);
	else
	else
		sd->nr_balance_failed = 0;
		sd->nr_balance_failed = 0;


	spin_unlock(&busiest->lock);
	return nr_moved;
	return nr_moved;


out_balanced:
out_balanced: