Re: [PATCH 5/6] x86: mm: new tunable for single vs full TLB flush

From: Rik van Riel
Date: Thu Apr 24 2014 - 13:56:34 EST


On 04/24/2014 01:25 PM, Dave Hansen wrote:
On 04/24/2014 03:37 AM, Mel Gorman wrote:
On Mon, Apr 21, 2014 at 11:24:26AM -0700, Dave Hansen wrote:
+This will cause us to do the global flush for more cases.
+Lowering it to 0 will disable the use of the individual flushes.
+Setting it to 1 is a very conservative setting and it should
+never need to be 0 under normal circumstances.
+
+Despite the fact that a single individual flush on x86 is
+guaranteed to flush a full 2MB, hugetlbfs always uses the full
+flushes. THP is treated exactly the same as normal memory.
+

You are the second person that told me this and I felt the manual was
unclear on this subject. I was told that it might be a documentation bug
but because this discussion was in a bar I completely failed to follow up
on it. Specifically this part in 4.10.2.3 caused me problems when I last
looked at the area.
<snip>

My understanding comes from "4.10.4.2 Recommended Invalidation":

â If software modifies a paging-structure entry that identifies
the final page frame for a page number (either a PTE or a
paging-structure entry in which the PS flag is 1), it should
execute INVLPG for any linear address with a page number whose
translation uses that PTE. 2

and especially the footnote:

2. One execution of INVLPG is sufficient even for a page with
size greater than 4 KBytes.

I do agree that it's ambiguous at best. I'll go see if anybody cares to
update that bit.

I suspect that IF the TLB actually uses a 2MB entry for the
translation, a single INVLPG will work.

However, the CPU is free to cache the translations for a 2MB
region with a bunch of 4kB entries, if it wanted to, so in
the end we have no guarantee that an INVLPG will actually do
the right thing...

The same is definitely true for 1GB vs 2MB entries, with
some CPUs being capable of parsing page tables with 1GB
entries, but having no TLB entries for 1GB translations.
--
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/