[lkml]   [2021]   [Nov]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] mm: split thp synchronously on MADV_DONTNEED
On Thu, Nov 25, 2021 at 11:32:08AM +0100, David Hildenbrand wrote:
> On 25.11.21 11:24, Peter Xu wrote:
> > On Mon, Nov 22, 2021 at 10:40:54AM -0800, Shakeel Butt wrote:
> >>> Do we have a performance evaluation how much overhead is added e.g., for
> >>> a single 4k MADV_DONTNEED call on a THP or on a MADV_DONTNEED call that
> >>> covers the whole THP?
> >>
> >> I did a simple benchmark of madvise(MADV_DONTNEED) on 10000 THPs on
> >> x86 for both settings you suggested. I don't see any statistically
> >> significant difference with and without the patch. Let me know if you
> >> want me to try something else.
> >
> > I'm a bit surprised that sync split thp didn't bring any extra overhead.
> >
> > "unmap whole thp" is understandable from that pov, because afaict that won't
> > even trigger any thp split anyway even delayed, if this is the simplest case
> > that only this process mapped this thp, and it mapped once.
> >
> > For "unmap 4k upon thp" IIUC that's the worst case and zapping 4k should be
> > fast; while what I don't understand since thp split requires all hand-made work
> > for copying thp flags into small pages and so on, so I thought there should at
> > least be some overhead measured. Shakeel, could there be something overlooked
> > in the test, or maybe it's me that overlooked?
> >
> > I had the same concern as what Kirill/Matthew raised in the other thread - I'm
> > worried proactively splitting simply because any 4k page is zapped might
> > quickly free up 2m thps in the system and I'm not sure whether it'll exaggerate
> > the defragmentation of the system memory in general. I'm also not sure whether
> > that's ideal for some very common workload that frequently uses DONTNEED to
> > proactively drop some pages.
> The pageblock corresponding to the THP is movable. So (unless we start
> spilling unmovable allocations into movable pageblocks) we'd only place
> movable allocations in there. Compaction will be able to migrate to
> re-create a free THP.
> In contrast I think, compaction will happily skip over the THP and
> ignore it, because it has no clue that the THP could be repurposed by
> split+migrate (at least I am not aware of code that does it).
> Unless I am missing something, with the above in mind it could make
> sense to split as soon as possible, even before we're under memory
> pressure -- for example, for proactive compaction.
> [proactive compaction could try splitting first as well I think]

But we can't rely on proactive compaction for rapid operations, because it's
still adding overhead to the overall system by split+merge, right?

+ ...
+Note that compaction has a non-trivial system-wide impact as pages
+belonging to different processes are moved around, which could also lead
+to latency spikes in unsuspecting applications. The kernel employs
+various heuristics to avoid wasting CPU cycles if it detects that
+proactive compaction is not being effective.

Delaying split makes sense to me because after all the kernel is not aware of
the userspace's preference, so the best thing is to do nothing until necessary.

Proactively split thps in dontneed/unmap added an assumption that the userspace
wants to break the pages by default. It's 100% true for Shakeel's use case,
but I'm not sure whether it may always be true. That's why I thought maybe a
new interface is more proper, so we at least won't break anyone by accident.

Peter Xu

 \ /
  Last update: 2021-11-26 03:54    [W:0.203 / U:3.188 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site