+#define VM_RESERVE_SIZE (1024 * 1024 * 256)
+#define MAX_COMPRESSOR_POOL_SIZE (1024 * 1024 * 450)
+
+ if (compressor_pool_max_size > MAX_COMPRESSOR_POOL_SIZE)
+ compressor_pool_max_size = MAX_COMPRESSOR_POOL_SIZE;
+
+ if (vm_compression_limit == 0)
+ compressor_pool_size = ((kernel_map->max_offset - kernel_map->min_offset) - kernel_map->size) - VM_RESERVE_SIZE;
+ compressor_pool_multiplier = 1;
+#else
+ if (compressor_pool_max_size > max_mem)
+ compressor_pool_max_size = max_mem;
+
+ if (vm_compression_limit == 0)
+ compressor_pool_size = max_mem;
+ compressor_pool_multiplier = 1;
+#endif
+ if (compressor_pool_size > compressor_pool_max_size)
+ compressor_pool_size = compressor_pool_max_size;
+
+try_again:
+ c_segments_limit = (uint32_t)(compressor_pool_size / (vm_size_t)(C_SEG_ALLOCSIZE));
+ c_segments_nearing_limit = (uint32_t)(((uint64_t)c_segments_limit * 98ULL) / 100ULL);
+
+ c_segment_pages_compressed_limit = (c_segments_limit * (C_SEG_BUFSIZE / PAGE_SIZE) * compressor_pool_multiplier);
+
+ if (c_segment_pages_compressed_limit < (uint32_t)(max_mem / PAGE_SIZE))
+ c_segment_pages_compressed_limit = (uint32_t)(max_mem / PAGE_SIZE);
+
+ c_segment_pages_compressed_nearing_limit = (uint32_t)(((uint64_t)c_segment_pages_compressed_limit * 98ULL) / 100ULL);