-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathEPTMigrate.h
103 lines (77 loc) · 2.3 KB
/
EPTMigrate.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
* SPDX-License-Identifier: GPL-2.0
*
* Copyright (c) 2018 Intel Corporation
*
* Authors: Yao Yuan <yuan.yao@intel.com>
* Fengguang Wu <fengguang.wu@intel.com>
*/
#ifndef _MIGRATION_H
#define _MIGRATION_H
#include <sys/types.h>
#include <unordered_map>
#include <string>
#include <vector>
#include "Option.h"
#include "Formatter.h"
#include "MovePages.h"
#include "ProcVmstat.h"
#include "ProcIdlePages.h"
#include "EPTScan.h"
#include "PidContext.h"
class BandwidthLimit;
class NumaNodeCollection;
class ProcVmstat;
struct MigrateStats: public MoveStats
{
unsigned long anon_kb;
void clear();
void add(MigrateStats *s);
void show(Formatter& fmt, MigrateWhat mwhat);
void show_move_result_state(Formatter& fmt);
};
class EPTMigrate : public EPTScan
{
public:
int dram_percent;
EPTMigrate();
int migrate();
int migrate(ProcIdlePageType type);
void set_throttler(BandwidthLimit* new_throttler)
{ migrator.set_throttler(new_throttler); }
void set_numacollection(NumaNodeCollection* new_numa_collection) {
numa_collection = new_numa_collection;
migrator.set_numacollection(new_numa_collection);
}
void set_pid_context(PidContext *new_context)
{ context = new_context; }
static void reset_sys_migrate_stats();
void count_migrate_stats();
MigrateStats& get_migrate_stats() {
return migrate_stats;
}
private:
size_t get_threshold_refs(ProcIdlePageType type, int& min_refs, int& max_refs);
// select max counted pages in page_refs_4k and page_refs_2m
int select_top_pages(ProcIdlePageType type);
long do_move_pages(ProcIdlePageType type);
// status => count
std::unordered_map<int, int> calc_migrate_stats();
unsigned long calc_numa_anon_capacity(ProcIdlePageType type, ProcVmstat& proc_vmstat);
public:
static MigrateStats sys_migrate_stats;
private:
// The Virtual Address of hot/cold pages.
// [0...n] = [VA0...VAn]
//std::vector<unsigned long> hot_pages;
std::vector<void *> pages_addr[PMD_ACCESSED + 1];
// Get the status after migration
std::vector<int> migrate_status;
MigrateStats migrate_stats;
MovePages migrator;
NumaNodeCollection* numa_collection;
Formatter fmt;
PidContext *context = NULL;
};
#endif
// vim:set ts=2 sw=2 et: