@@ -77,12 +77,9 @@ pub enum SledMode {
77
77
}
78
78
79
79
/// Accounting for high watermark memory usage for various system purposes
80
- #[ derive( Copy , Clone , Debug ) ]
80
+ #[ derive( Clone ) ]
81
81
pub struct MemoryReservations {
82
- /// Installed physical memory in this sled. Probably should hold a
83
- /// [`HardwareManager`] and call `usable_physical_ram_bytes()` instead of
84
- /// this.
85
- hardware_physical_ram_bytes : u64 ,
82
+ hardware_manager : HardwareManager ,
86
83
/// The amount of memory expected to be used if "control plane" services all
87
84
/// running on this sled. "control plane" here refers to services that have
88
85
/// roughly fixed memory use given differing sled hardware configurations.
@@ -98,10 +95,6 @@ pub struct MemoryReservations {
98
95
// XXX: This is really something we should be told by Neuxs, perhaps after
99
96
// starting with this conservative estimate to get the sled started.
100
97
control_plane_earmark_bytes : u64 ,
101
- /// The amount of memory used for `page_t` structures, assuming a distinct
102
- /// `page_t` for each 4k page in the system. If we use larger pages, like
103
- /// 2MiB pages, this will be potentially a gross overestimate.
104
- max_page_t_space : u64 ,
105
98
// XXX: Crucible involves some amount of memory in support of the volumes it
106
99
// manages. We should collect zpool size and estimate the memory that would
107
100
// be used if all available storage was dedicated to Crucible volumes. For
@@ -113,23 +106,12 @@ impl MemoryReservations {
113
106
hardware_manager : HardwareManager ,
114
107
control_plane_earmark_mib : Option < u32 > ,
115
108
) -> MemoryReservations {
116
- let hardware_physical_ram_bytes =
117
- hardware_manager. usable_physical_ram_bytes ( ) ;
118
- // Don't like hardcoding a struct size from the host OS here like
119
- // this, maybe we shuffle some bits around before merging.. On the
120
- // other hand, the last time page_t changed was illumos-gate commit
121
- // a5652762e5 from 2006.
122
- const PAGE_T_SIZE : u64 = 120 ;
123
- let max_page_t_space =
124
- hardware_manager. usable_physical_pages ( ) * PAGE_T_SIZE ;
125
-
126
109
const MIB : u64 = 1024 * 1024 ;
127
110
let control_plane_earmark_bytes =
128
111
u64:: from ( control_plane_earmark_mib. unwrap_or ( 0 ) ) * MIB ;
129
112
130
113
Self {
131
- hardware_physical_ram_bytes,
132
- max_page_t_space,
114
+ hardware_manager,
133
115
control_plane_earmark_bytes,
134
116
}
135
117
}
@@ -141,8 +123,18 @@ impl MemoryReservations {
141
123
/// a fixed amount of memory specified by `ReservoirMode::Size` or
142
124
/// a percentage of this amount specified by `ReservoirMode::Percentage`.
143
125
pub fn vmm_eligible ( & self ) -> u64 {
144
- self . hardware_physical_ram_bytes
145
- - self . max_page_t_space
126
+ let hardware_physical_ram_bytes =
127
+ self . hardware_manager . usable_physical_ram_bytes ( ) ;
128
+ // Don't like hardcoding a struct size from the host OS here like
129
+ // this, maybe we shuffle some bits around before merging.. On the
130
+ // other hand, the last time page_t changed was illumos-gate commit
131
+ // a5652762e5 from 2006.
132
+ const PAGE_T_SIZE : u64 = 120 ;
133
+ let max_page_t_space =
134
+ self . hardware_manager . usable_physical_pages ( ) * PAGE_T_SIZE ;
135
+
136
+ hardware_physical_ram_bytes
137
+ - max_page_t_space
146
138
- self . control_plane_earmark_bytes
147
139
}
148
140
}
0 commit comments