Re: [RFC PATCH 2/3] Add tunable to control THP behavior

Andy Lutomirski
2013-12-12T20:52:45Z

On Thu, Dec 12, 2013 at 12:49 PM, Alex Thorlton <athorlton@sgi.com> wrote:
>
> > Is there a setting that will turn off the must-be-the-same-node
> > behavior? There are workloads where TLB matters more than cross-node
> > traffic (or where all the pages are hopelessly shared between nodes,
> > but hugepages are still useful).
>
> That's pretty much how THPs already behave in the kernel, so if you want
> to allow THPs to be handed out to one node, but referenced from many
> others, you'd just set the threshold to 1, and let the existing code
> take over.
>

Right. I like that behavior for my workload. (Although I currently
allocate huge pages -- when I wrote that code, THP interacted so badly
with pagecache that it was a non-starter. I think it's fixed now,
though.)

>
> As for the must-be-the-same-node behavior: I'd actually say it's more
> like a "must have so much on one node" behavior, in that, if you set the
> threshold to 16, for example, 16 4K pages must be faulted in on the same
> node, in the same contiguous 2M chunk, before a THP will be created.
> What happens after that THP is created is out of our control, it could
> be referenced from anywhere.

In that case, I guess I misunderstood your description. Are saying
that, once any node accesses this many pages in the potential THP,
then the whole THP will be mapped?

--Andy