Re: RFC: Memory Tiering Kernel Interfaces

From: Wei Xu
Date: Thu May 05 2022 - 02:35:32 EST


On Wed, May 4, 2022 at 10:02 AM Dave Hansen <dave.hansen@xxxxxxxxx> wrote:
>
> On 5/3/22 18:31, Wei Xu wrote:
> >> Well, x86 CPUs have performance monitoring hardware that can
> >> theoretically collect physical access information too. But, this
> >> performance monitoring hardware wasn't designed for this specific use
> >> case in mind. So, in practice, these events (PEBS) weren't very useful
> >> for driving memory tiering.
> > The PEBS events without any filtering might not be useful for memory
> > tiering, but the PEBS events with hardware-based data source filtering
> > can be useful in driving promotions in memory tiering. Certainly,
> > because these events are not designed for this specific use case in
> > mind, there are inefficiencies using them for memory tiering, e.g.
> > instead of just getting a heat counter for each hot page, we can get
> > events repeatedly on the hot pages.
>
> Also, I believe the addresses that come out of the PEBS events are
> virtual addresses (Data Linear Addresses according to the SDM). If the
> events are written from a KVM guest, you get guest linear addresses.
>
> That means a lot of page table and EPT walks to map those linear
> addresses back to physical. That adds to the inefficiency.

That's true if the tracking is purely based on physical pages. For
hot page tracking from PEBS, we can consider tracking in
virtual/linear addresses. We don't need to maintain the history for
all linear page addresses nor for an indefinite amount of time. After
all, we just need to identify pages accessed frequently recently and
promote them.

> In the end, you get big PEBS buffers with lots of irrelevant data that
> needs significant post-processing to make sense of it.

I am curious about what are "lots of irrelevant data" if PEBS data is
filtered on data sources (e.g. DRAM vs PMEM) by hardware. If we need
to have different policies for the pages from the same data source,
then I agree that the software has to do a lot of filtering work.

> The folks at Intel that tried this really struggled to take this mess and turn it into a successful hot-page tracking.
>
> Maybe someone else will find a better way to do it, but we tried and
> gave up.

It might be challenging to use PEBS as the only and universal hot page
tracking hardware mechanism. For example, there are challenges to use
PEBS to sample KVM guest accesses from the host. On the other hand,
PEBS with hardware-based data source filtering can be a useful
mechanism to improve hot page tracking in conjunction with other
techniques.