7272#define CONTAINER_READ_NUMBER_CHECKED (controller, filename, log_string, retval ) \
7373{ \
7474 bool is_ok; \
75- is_ok = controller->read_number (filename, & retval); \
75+ is_ok = controller->read_number (filename, retval); \
7676 if (!is_ok) { \
7777 log_trace (os, container)(log_string " failed: %d" , OSCONTAINER_ERROR); \
78- return OSCONTAINER_ERROR; \
78+ return false ; \
7979 } \
80- log_trace (os, container)(log_string " is: " JULONG_FORMAT, retval); \
80+ log_trace (os, container)(log_string " is: %zu" , retval); \
81+ return true ; \
8182}
8283
8384#define CONTAINER_READ_NUMBER_CHECKED_MAX (controller, filename, log_string, retval ) \
8485{ \
8586 bool is_ok; \
86- is_ok = controller->read_number_handle_max (filename, & retval); \
87+ is_ok = controller->read_number_handle_max (filename, retval); \
8788 if (!is_ok) { \
8889 log_trace (os, container)(log_string " failed: %d" , OSCONTAINER_ERROR); \
89- return OSCONTAINER_ERROR; \
90+ return false ; \
9091 } \
91- log_trace (os, container)(log_string " is: " JLONG_FORMAT, retval); \
92+ log_trace (os, container)(log_string " is: %zd" , retval); \
93+ return true ; \
9294}
9395
9496#define CONTAINER_READ_STRING_CHECKED (controller, filename, log_string, retval, buf_size ) \
@@ -113,21 +115,21 @@ class CgroupController: public CHeapObj<mtInternal> {
113115 const char * mount_point () { return _mount_point; }
114116 virtual bool needs_hierarchy_adjustment () { return false ; }
115117
116- /* Read a numerical value as unsigned long
118+ /* Read a numerical value as size_t
117119 *
118120 * returns: false if any error occurred. true otherwise and
119- * the parsed value is set in the provided julong pointer .
121+ * the parsed value is set in the provided size_t reference .
120122 */
121- bool read_number (const char * filename, julong* result);
123+ bool read_number (const char * filename, size_t & result);
122124
123125 /* Convenience method to deal with numbers as well as the string 'max'
124126 * in interface files. Otherwise same as read_number().
125127 *
126128 * returns: false if any error occurred. true otherwise and
127- * the parsed value (which might be negative) is being set in
128- * the provided jlong pointer .
129+ * the parsed value in the range [-1,SSIZE_MAX] is being set in
130+ * the provided ssize_t reference. -1 means the value is unlimited .
129131 */
130- bool read_number_handle_max (const char * filename, jlong* result);
132+ bool read_number_handle_max (const char * filename, ssize_t & result);
131133
132134 /* Read a string of at most buf_size - 1 characters from the interface file.
133135 * The provided buffer must be at least buf_size in size so as to account
@@ -145,26 +147,27 @@ class CgroupController: public CHeapObj<mtInternal> {
145147 * parsing interface files like cpu.max which contain such tuples.
146148 *
147149 * returns: false if any error occurred. true otherwise and the parsed
148- * value of the appropriate tuple entry set in the provided jlong pointer.
150+ * value of the appropriate tuple entry set in the provided ssize_t reference
151+ * in the range [-1,SSIZE_MAX]. -1 means unlimited tuple value.
149152 */
150- bool read_numerical_tuple_value (const char * filename, bool use_first, jlong* result);
153+ bool read_numerical_tuple_value (const char * filename, bool use_first, ssize_t & result);
151154
152155 /* Read a numerical value from a multi-line interface file. The matched line is
153156 * determined by the provided 'key'. The associated numerical value is being set
154- * via the passed in julong pointer . Example interface file 'memory.stat'
157+ * via the passed in size_t reference . Example interface file 'memory.stat'
155158 *
156159 * returns: false if any error occurred. true otherwise and the parsed value is
157- * being set in the provided julong pointer .
160+ * being set in the provided size_t reference .
158161 */
159- bool read_numerical_key_value (const char * filename, const char * key, julong* result);
162+ bool read_numerical_key_value (const char * filename, const char * key, size_t & result);
160163
161164 private:
162- static jlong limit_from_str (char * limit_str);
165+ static bool limit_from_str (char * limit_str, ssize_t & value );
163166};
164167
165168class CachedMetric : public CHeapObj <mtInternal>{
166169 private:
167- volatile jlong _metric;
170+ volatile ssize_t _metric;
168171 volatile jlong _next_check_counter;
169172 public:
170173 CachedMetric () {
@@ -174,8 +177,8 @@ class CachedMetric : public CHeapObj<mtInternal>{
174177 bool should_check_metric () {
175178 return os::elapsed_counter () > _next_check_counter;
176179 }
177- jlong value () { return _metric; }
178- void set_value (jlong value, jlong timeout) {
180+ ssize_t value () { return _metric; }
181+ void set_value (ssize_t value, jlong timeout) {
179182 _metric = value;
180183 // Metric is unlikely to change, but we want to remain
181184 // responsive to configuration changes. A very short grace time
@@ -219,7 +222,7 @@ class CgroupCpuController: public CHeapObj<mtInternal> {
219222// Pure virtual class representing version agnostic CPU accounting controllers
220223class CgroupCpuacctController : public CHeapObj <mtInternal> {
221224 public:
222- virtual jlong cpu_usage_in_micros () = 0;
225+ virtual ssize_t cpu_usage_in_micros () = 0;
223226 virtual bool needs_hierarchy_adjustment () = 0;
224227 virtual bool is_read_only () = 0;
225228 virtual const char * subsystem_path () = 0;
@@ -231,15 +234,15 @@ class CgroupCpuacctController: public CHeapObj<mtInternal> {
231234// Pure virtual class representing version agnostic memory controllers
232235class CgroupMemoryController : public CHeapObj <mtInternal> {
233236 public:
234- virtual jlong read_memory_limit_in_bytes (size_t host_mem) = 0;
235- virtual jlong memory_usage_in_bytes () = 0;
236- virtual jlong memory_and_swap_limit_in_bytes (size_t host_mem, size_t host_swap) = 0;
237- virtual jlong memory_and_swap_usage_in_bytes (size_t host_mem, size_t host_swap) = 0;
238- virtual jlong memory_soft_limit_in_bytes (size_t host_mem) = 0;
239- virtual jlong memory_throttle_limit_in_bytes () = 0;
240- virtual jlong memory_max_usage_in_bytes () = 0;
241- virtual jlong rss_usage_in_bytes () = 0;
242- virtual jlong cache_usage_in_bytes () = 0;
237+ virtual ssize_t read_memory_limit_in_bytes (size_t host_mem) = 0;
238+ virtual ssize_t memory_usage_in_bytes () = 0;
239+ virtual ssize_t memory_and_swap_limit_in_bytes (size_t host_mem, size_t host_swap) = 0;
240+ virtual ssize_t memory_and_swap_usage_in_bytes (size_t host_mem, size_t host_swap) = 0;
241+ virtual ssize_t memory_soft_limit_in_bytes (size_t host_mem) = 0;
242+ virtual ssize_t memory_throttle_limit_in_bytes () = 0;
243+ virtual ssize_t memory_max_usage_in_bytes () = 0;
244+ virtual ssize_t rss_usage_in_bytes () = 0;
245+ virtual ssize_t cache_usage_in_bytes () = 0;
243246 virtual void print_version_specific_info (outputStream* st, size_t host_mem) = 0;
244247 virtual bool needs_hierarchy_adjustment () = 0;
245248 virtual bool is_read_only () = 0;
@@ -251,11 +254,11 @@ class CgroupMemoryController: public CHeapObj<mtInternal> {
251254
252255class CgroupSubsystem : public CHeapObj <mtInternal> {
253256 public:
254- jlong memory_limit_in_bytes ();
257+ ssize_t memory_limit_in_bytes ();
255258 int active_processor_count ();
256259
257- virtual jlong pids_max () = 0;
258- virtual jlong pids_current () = 0;
260+ virtual ssize_t pids_max () = 0;
261+ virtual ssize_t pids_current () = 0;
259262 virtual bool is_containerized () = 0;
260263
261264 virtual char * cpu_cpuset_cpus () = 0;
@@ -269,16 +272,16 @@ class CgroupSubsystem: public CHeapObj<mtInternal> {
269272 int cpu_period ();
270273 int cpu_shares ();
271274
272- jlong cpu_usage_in_micros ();
275+ ssize_t cpu_usage_in_micros ();
273276
274- jlong memory_usage_in_bytes ();
275- jlong memory_and_swap_limit_in_bytes ();
276- jlong memory_and_swap_usage_in_bytes ();
277- jlong memory_soft_limit_in_bytes ();
278- jlong memory_throttle_limit_in_bytes ();
279- jlong memory_max_usage_in_bytes ();
280- jlong rss_usage_in_bytes ();
281- jlong cache_usage_in_bytes ();
277+ ssize_t memory_usage_in_bytes ();
278+ ssize_t memory_and_swap_limit_in_bytes ();
279+ ssize_t memory_and_swap_usage_in_bytes ();
280+ ssize_t memory_soft_limit_in_bytes ();
281+ ssize_t memory_throttle_limit_in_bytes ();
282+ ssize_t memory_max_usage_in_bytes ();
283+ ssize_t rss_usage_in_bytes ();
284+ ssize_t cache_usage_in_bytes ();
282285 void print_version_specific_info (outputStream* st);
283286};
284287
0 commit comments