Re: [PATCH RFC tip/core/rcu 6/6] rcu: Reduce cache-missinitialization latencies for large systems

From: Paul E. McKenney
Date: Fri Apr 27 2012 - 11:03:31 EST


On Fri, Apr 27, 2012 at 12:01:25AM +0200, Peter Zijlstra wrote:
> On Thu, 2012-04-26 at 13:28 -0700, Paul E. McKenney wrote:

[ . . . ]

> > I think I see what you
> > are getting at, though I am having a hard time seeing how to pack
> > it into a linear array.
>
> Yeah, I'm not sure you can either. Hence me building a tree ;-) But you
> too have a tree, its tree-rcu after all.
>
> > The idea seems to be to compute a per-CPU list of CPU masks, with the first
> > entry having bits set for the CPUs closest to the CPU corresponding to
> > the list, and subsequent entries adding more-distant CPUs. The last
> > CPU mask would presumably have bits set for all CPUs.
>
> Indeed. So the scheduler already knows about nodes (included in the
> default_topology thing), here we're constructing masks spanning nodes
> based on distance.
>
> So the first level is all nodes that are directly connected, the second
> level are all nodes that have one intermediate hop, etc.. with indeed
> the last level being the entire machine.
>
> > I take it that there is no data structure listing per-node CPU masks,
> > indicating which CPUs are members of a given node? Or is something else
> > going on here?
>
> There is, its cpumask_of_node(), you'll find it used in the above
> code :-) We do the for_each_cpu loop because we need the mask per-node
> and there's no such thing as per-node memory so we fudge it using
> per-cpu memory.
>
> This could be optimized to reduce overhead if this all turns out to work
> well.
>
> So in short: for every 'i < level', for every cpu, we build a mask of
> which cpus are '<= i' hops away from our current node.

So this information could be used to create a cache-friendly CPU ordering,
such that CPU i and CPU i+1 tend to be electrically close to each other.
One could solve the traveling salesmans problem, but doing a traveral
of the CPUs following the node tree should be much simpler and come
pretty close.

If someone were to show significant performance degradation due to
RCU's using the smp_processor_id() ordering for its rcu_node tree,
I would try this ordering. It would cause the rcu_node tree performance
to be much less sensitive to the rcu_node tree's geometry.

> > > +
> > > + tl = kzalloc((ARRAY_SIZE(default_topology) + level) *
> > > + sizeof(struct sched_domain_topology_level), GFP_KERNEL);
> > > + if (!tl)
> > > + return;
> > > +
> > > + for (i = 0; default_topology[i].init; i++)
> > > + tl[i] = default_topology[i];
> > > +
> > > + for (j = 0; j < level; i++, j++) {
> > > + tl[i] = (struct sched_domain_topology_level){
> >
> > tl[j]?
>
> No, [i]. See how we allocate an array of ARRAY_SIZE(default_topology) +
> level, then copy the default topology array then continue i by j
> additional levels.

OK, good thing I correctly characterized my comments. ;-)

Thanx, Paul

> > > + .init = sd_init_NUMA,
> > > + .mask = sd_numa_mask,
> > > + .flags = SDTL_OVERLAP,
> > > + .numa_level = j,
> > > + };
> > > + }
> > > +
> > > + sched_domain_topology = tl;
> > > +}
>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/