Report page migration events as start/end (#793)

* Squashed commit of the following:

commit b76f2635f4b65599f03812a73d0cf410f5ada213
Author: Mythreya <mythreya.kuricheti@amd.com>
Date:   Fri Apr 26 00:29:09 2024 +0000

    Changed for PR feedback

commit bedb8ad566ff42fbf117b19202c26c507abcf8ac
Author: Jonathan R. Madsen <jonathanrmadsen@gmail.com>
Date:   Thu Apr 25 19:20:06 2024 -0500

    Fix installation

commit a98f8a69459a1450a1be9c98e20b3c1e7f2568c2
Author: Jonathan R. Madsen <jonathanrmadsen@gmail.com>
Date:   Thu Apr 25 19:16:35 2024 -0500

    Restructure the headers

commit 46489a020ffafdd5f4ce3f580469ff233ef67fe1
Author: Mythreya <mythreya.kuricheti@amd.com>
Date:   Tue Apr 23 23:31:10 2024 +0000

    Update hsa include

commit 8e795282cce348fc6aa736b7857b21aeb32aa20a
Author: Mythreya <mythreya.kuricheti@amd.com>
Date:   Tue Apr 23 23:02:32 2024 +0000

    Report page migration events as start/end

    * Updated tests accordingly
    * Page migration events are reported independently

commit 8784e5ad4895a626a2a8e4ac12f8021b34172bd4
Author: Mythreya <mythreya.kuricheti@amd.com>
Date:   Tue Apr 16 17:01:57 2024 +0000

    Update handling of dropped page migration events

    Previously, we dropped all locally buffered events when we detect that
    KFD has dropped some events. This may drop too many pending events too eagerly.

    When we receive an end event and cannot find the corresponding start,
    we can be sure that KFD has dropped some events in the immediate past.

    When this happens, we look through all locally buffered events and report
    the start events that are older than 10s as partial events --- they have
    no "end" information (we expect that the end events have been dropped).

    We also set the polling timeout to 10s to prevent the local buffer from
    getting too large with events waiting to be paired up.

    Updated tests

commit 2e8e0b07eeda9b5990e1ae8d28dcd3a035ce38e1
Author: Mythreya <mythreya.kuricheti@amd.com>
Date:   Tue Apr 16 17:01:31 2024 +0000

    Docs for triggers

* Fix page migration sample

* Fix hasher, kfd install

* Add hsa include
* Install KFD include dir

* Updates from code review

- single timestamp field
- node_id -> agent_id
- from_node -> from_agent
- to_node -> to_agent

* Misc revisions

* Remove page-migration install target

* Update page-migration pytest

* Tweak to serialization

* Address PR comments

* Update page-migration test

* Add cli args, update iterations

* Address PR comments

* Add abi.cpp for static_asserts
* Update page_migration gtest with only runtime tests
* Moved helpers into utils.hpp

---------

Co-authored-by: Jonathan R. Madsen <jonathanrmadsen@gmail.com>
This commit is contained in:
MythreyaandJonathan R. Madsen authored and GitHub committed 2024-11-11 11:08:47 -06:00
1 parent 472907a576
commit 363f85dc72
27 files changed
+1161 -1098

No files matched your search

@@ -25,6 +25,7 @@
#include <rocprofiler-sdk/agent.h>
#include <rocprofiler-sdk/defines.h>
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/kfd/page_migration_args.h>
#include <stdint.h>
@@ -37,49 +38,6 @@ ROCPROFILER_EXTERN_C_INIT
* @{
*/
/**
* @brief Page migration triggers
*
*/
typedef enum
{
ROCPROFILER_PAGE_MIGRATION_TRIGGER_NONE = -1,
ROCPROFILER_PAGE_MIGRATION_TRIGGER_PREFETCH,
ROCPROFILER_PAGE_MIGRATION_TRIGGER_PAGEFAULT_GPU,
ROCPROFILER_PAGE_MIGRATION_TRIGGER_PAGEFAULT_CPU,
ROCPROFILER_PAGE_MIGRATION_TRIGGER_TTM_EVICTION,
ROCPROFILER_PAGE_MIGRATION_TRIGGER_LAST,
} rocprofiler_page_migration_trigger_t;
/**
* @brief Page migration triggers causing the queue to suspend
*
*/
typedef enum
{
ROCPROFILER_PAGE_MIGRATION_QUEUE_SUSPEND_TRIGGER_NONE = -1,
ROCPROFILER_PAGE_MIGRATION_QUEUE_SUSPEND_TRIGGER_SVM,
ROCPROFILER_PAGE_MIGRATION_QUEUE_SUSPEND_TRIGGER_USERPTR,
ROCPROFILER_PAGE_MIGRATION_QUEUE_SUSPEND_TRIGGER_TTM,
ROCPROFILER_PAGE_MIGRATION_QUEUE_SUSPEND_TRIGGER_SUSPEND,
ROCPROFILER_PAGE_MIGRATION_QUEUE_SUSPEND_TRIGGER_CRIU_CHECKPOINT,
ROCPROFILER_PAGE_MIGRATION_QUEUE_SUSPEND_TRIGGER_CRIU_RESTORE,
ROCPROFILER_PAGE_MIGRATION_QUEUE_SUSPEND_TRIGGER_LAST,
} rocprofiler_page_migration_queue_suspend_trigger_t;
/**
* @brief Page migration triggers causing an unmap from the GPU
*
*/
typedef enum
{
ROCPROFILER_PAGE_MIGRATION_UNMAP_FROM_GPU_TRIGGER_NONE = -1,
ROCPROFILER_PAGE_MIGRATION_UNMAP_FROM_GPU_TRIGGER_MMU_NOTIFY,
ROCPROFILER_PAGE_MIGRATION_UNMAP_FROM_GPU_TRIGGER_MMU_NOTIFY_MIGRATE,
ROCPROFILER_PAGE_MIGRATION_UNMAP_FROM_GPU_TRIGGER_UNMAP_FROM_CPU,
ROCPROFILER_PAGE_MIGRATION_UNMAP_FROM_GPU_TRIGGER_LAST,
} rocprofiler_page_migration_unmap_from_gpu_trigger_t;
/**
* @brief ROCProfiler Buffer HSA API Tracer Record.
*/
@@ -265,63 +223,17 @@ typedef struct rocprofiler_buffer_tracing_kernel_dispatch_record_t
/// dispatch
} rocprofiler_buffer_tracing_kernel_dispatch_record_t;
typedef struct
{
uint8_t read_fault : 1; ///< Is the fault due to a read or a write
uint8_t migrated : 1;
uint32_t node_id; ///< GPU or CPU node ID which reports a page fault
uint64_t address; ///< Address access that caused the page fault
} rocprofiler_buffer_tracing_page_migration_page_fault_record_t;
typedef struct
{
uint64_t start_addr; ///< Start address of the page being migrated
uint64_t end_addr; ///< End address of the page being migrated
uint32_t from_node; ///< Source node
uint32_t to_node; ///< Destination node
uint32_t prefetch_node; ///< Node from which page was prefetched
uint32_t preferred_node; ///< Preferred destinaion node
rocprofiler_page_migration_trigger_t trigger; ///< Cause of migration
} rocprofiler_buffer_tracing_page_migration_page_migrate_record_t;
typedef struct
{
uint8_t rescheduled : 1;
uint32_t node_id; ///< GPU node from which the queue was suspended
rocprofiler_page_migration_queue_suspend_trigger_t trigger; ///< Cause of queue suspension
} rocprofiler_buffer_tracing_page_migration_queue_suspend_record_t;
typedef struct
{
uint32_t node_id; ///< Node ID from which page was unmapped
uint64_t start_addr; ///< Start address of unmapped page
uint64_t end_addr; ///< End address of unmapped page
rocprofiler_page_migration_unmap_from_gpu_trigger_t trigger; ///< Cause of unmap
} rocprofiler_buffer_tracing_page_migration_unmap_from_gpu_record_t;
/**
* @brief ROCProfiler Buffer Page Migration Tracer Record
*/
typedef struct rocprofiler_buffer_tracing_page_migration_record_t
{
uint64_t size; ///< size of this struct
rocprofiler_buffer_tracing_kind_t kind; ///< ROCPROFILER_BUFFER_TRACING_PAGE_MIGRATION
rocprofiler_tracing_operation_t operation;
rocprofiler_timestamp_t start_timestamp; ///< start time in nanoseconds
rocprofiler_timestamp_t end_timestamp; ///< end time in nanoseconds
uint32_t pid;
union
{
rocprofiler_buffer_tracing_page_migration_page_fault_record_t page_fault;
rocprofiler_buffer_tracing_page_migration_page_migrate_record_t page_migrate;
rocprofiler_buffer_tracing_page_migration_queue_suspend_record_t queue_suspend;
rocprofiler_buffer_tracing_page_migration_unmap_from_gpu_record_t unmap_from_gpu;
struct
{
uint64_t reserved[12];
};
};
uint64_t size; ///< size of this struct
rocprofiler_buffer_tracing_kind_t kind; ///< ROCPROFILER_BUFFER_TRACING_PAGE_MIGRATION
rocprofiler_page_migration_operation_t operation;
rocprofiler_timestamp_t timestamp; ///< start time in nanoseconds
uint32_t pid;
rocprofiler_page_migration_args_t args;
} rocprofiler_buffer_tracing_page_migration_record_t;
/**