linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mel Gorman <mgorman@suse.de>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>,
	Ingo Molnar <mingo@kernel.org>,
	Andrea Arcangeli <aarcange@redhat.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Linux-MM <linux-mm@kvack.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 16/16] sched: Select least loaded CPU on preferred NUMA node
Date: Thu, 11 Jul 2013 14:24:56 +0100	[thread overview]
Message-ID: <20130711132455.GD2355@suse.de> (raw)
In-Reply-To: <20130711123902.GI25631@dyad.programming.kicks-ass.net>

On Thu, Jul 11, 2013 at 02:39:02PM +0200, Peter Zijlstra wrote:
> On Thu, Jul 11, 2013 at 10:47:00AM +0100, Mel Gorman wrote:
> > +++ b/kernel/sched/fair.c
> > @@ -841,29 +841,81 @@ static unsigned int task_scan_max(struct task_struct *p)
> >   */
> >  unsigned int sysctl_numa_balancing_settle_count __read_mostly = 3;
> >  
> > +static unsigned long source_load(int cpu, int type);
> > +static unsigned long target_load(int cpu, int type);
> > +static unsigned long power_of(int cpu);
> > +static long effective_load(struct task_group *tg, int cpu, long wl, long wg);
> > +
> > +static int task_numa_find_cpu(struct task_struct *p, int nid)
> > +{
> > +	int node_cpu = cpumask_first(cpumask_of_node(nid));
> > +	int cpu, src_cpu = task_cpu(p), dst_cpu = src_cpu;
> > +	unsigned long src_load, dst_load;
> > +	unsigned long min_load = ULONG_MAX;
> > +	struct task_group *tg = task_group(p);
> > +	s64 src_eff_load, dst_eff_load;
> > +	struct sched_domain *sd;
> > +	unsigned long weight;
> > +	int imbalance_pct, idx = -1;
> >  
> > +	/* No harm being optimistic */
> > +	if (idle_cpu(node_cpu))
> > +		return node_cpu;
> >  
> > +	/*
> > +	 * Find the lowest common scheduling domain covering the nodes of both
> > +	 * the CPU the task is currently running on and the target NUMA node.
> > +	 */
> >  	rcu_read_lock();
> > +	for_each_domain(src_cpu, sd) {
> > +		if (cpumask_test_cpu(node_cpu, sched_domain_span(sd))) {
> > +			/*
> > +			 * busy_idx is used for the load decision as it is the
> > +			 * same index used by the regular load balancer for an
> > +			 * active cpu.
> > +			 */
> > +			idx = sd->busy_idx;
> > +			imbalance_pct = sd->imbalance_pct;
> > +			break;
> >  		}
> >  	}
> >  	rcu_read_unlock();
> >  
> > +	if (WARN_ON_ONCE(idx == -1))
> > +		return src_cpu;
> > +
> > +	/*
> > +	 * XXX the below is mostly nicked from wake_affine(); we should
> > +	 * see about sharing a bit if at all possible; also it might want
> > +	 * some per entity weight love.
> > +	 */
> > +	weight = p->se.load.weight;
> > + 
> > +	src_load = source_load(src_cpu, idx);
> > +
> > +	src_eff_load = 100 + (imbalance_pct - 100) / 2;
> > +	src_eff_load *= power_of(src_cpu);
> > +	src_eff_load *= src_load + effective_load(tg, src_cpu, -weight, -weight);
> > +
> > +	for_each_cpu(cpu, cpumask_of_node(nid)) {
> > +		dst_load = target_load(cpu, idx);
> > +
> > +		/* If the CPU is idle, use it */
> > +		if (!dst_load)
> > +			return dst_cpu;
> > +
> > +		/* Otherwise check the target CPU load */
> > +		dst_eff_load = 100;
> > +		dst_eff_load *= power_of(cpu);
> > +		dst_eff_load *= dst_load + effective_load(tg, cpu, weight, weight);
> 
> So the missing part is:
> 
> 		/*
> 		 * Do not allow the destination CPU to be loaded significantly
> 		 * more than the CPU we came from.
> 		 */
> 		if (dst_eff_load <= src_eff_load)
> 			continue;
> 

Yes, the results with the patch included. I decided to punt it for now as I
expected that fixing false shared detection would mitigate the problem and
the requirement of the patch would be reduced. That said, the comparison
also had another patch in the middle that was dropped before release so
I'll retest in isolation.

> > +
> > +		if (dst_load < min_load) {
> > +			min_load = dst_load;
> > +			dst_cpu = cpu;
> > +		}
> > + 	}
> > +
> > +	return dst_cpu;
> >  }
> 
> This is almost a big fat NOP. It did a scan for the least loaded cpu and now it
> still does.

This version makes more sense and does not fall apart just because the
number of NUMA tasks running happened to be more than the available CPUs.

> It also doesn't cure the problem Srikar saw where we kept migrating
> all tasks back to the one node with all the memory.
> 

No, it doesn't. That problem is still there.

> Task migration must be subject to fairness limits; otherwise there's nothing
> avoiding heaping all tasks on a single pile.
> 
> One thing we could do to maybe relax things a little bit is take away the
> effective_load() term in the src_eff_load() computation. That way we compare
> the current src load to the future dst load, instead of using the future load
> for both.
> 

I'll try that and get back to you.

-- 
Mel Gorman
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

      reply	other threads:[~2013-07-11 13:25 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-11  9:46 [PATCH 0/16] Basic scheduler support for automatic NUMA balancing V4 Mel Gorman
2013-07-11  9:46 ` [PATCH 01/16] mm: numa: Document automatic NUMA balancing sysctls Mel Gorman
2013-07-11  9:46 ` [PATCH 02/16] sched: Track NUMA hinting faults on per-node basis Mel Gorman
2013-07-11  9:46 ` [PATCH 03/16] mm: numa: Account for THP numa hinting faults on the correct node Mel Gorman
2013-07-11  9:46 ` [PATCH 04/16] mm: numa: Do not migrate or account for hinting faults on the zero page Mel Gorman
2013-07-11 11:21   ` Peter Zijlstra
2013-07-11 12:42     ` Mel Gorman
2013-07-11  9:46 ` [PATCH 05/16] sched: Select a preferred node with the most numa hinting faults Mel Gorman
2013-07-11 11:23   ` Peter Zijlstra
2013-07-11 12:53     ` Mel Gorman
2013-07-11  9:46 ` [PATCH 06/16] sched: Update NUMA hinting faults once per scan Mel Gorman
2013-07-11  9:46 ` [PATCH 07/16] sched: Favour moving tasks towards the preferred node Mel Gorman
2013-07-11  9:46 ` [PATCH 08/16] sched: Reschedule task on preferred NUMA node once selected Mel Gorman
2013-07-11 12:30   ` Peter Zijlstra
2013-07-11 13:03     ` Mel Gorman
2013-07-11 13:11       ` Peter Zijlstra
2013-07-11 14:09         ` Mel Gorman
2013-07-12 10:14           ` Peter Zijlstra
2013-07-12 10:28             ` Mel Gorman
2013-07-11  9:46 ` [PATCH 09/16] sched: Add infrastructure for split shared/private accounting of NUMA hinting faults Mel Gorman
2013-07-11  9:46 ` [PATCH 10/16] sched: Increase NUMA PTE scanning when a new preferred node is selected Mel Gorman
2013-07-11  9:46 ` [PATCH 11/16] sched: Check current->mm before allocating NUMA faults Mel Gorman
2013-07-11  9:46 ` [PATCH 12/16] sched: Set the scan rate proportional to the size of the task being scanned Mel Gorman
2013-07-11  9:46 ` [PATCH 13/16] mm: numa: Scan pages with elevated page_mapcount Mel Gorman
2013-07-11  9:46 ` [PATCH 14/16] sched: Remove check that skips small VMAs Mel Gorman
2013-07-11  9:46 ` [PATCH 15/16] sched: Set preferred NUMA node based on number of private faults Mel Gorman
2013-07-11  9:47 ` [PATCH 16/16] sched: Select least loaded CPU on preferred NUMA node Mel Gorman
2013-07-11 12:39   ` Peter Zijlstra
2013-07-11 13:24     ` Mel Gorman [this message]

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=20130711132455.GD2355@suse.de \
    --to=mgorman@suse.de \
    --cc=aarcange@redhat.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=srikar@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;
as well as URLs for NNTP newsgroup(s).