Stable in v0.1.0 onward. The skeleton release (v0.0.1) implements only the module load/unload entry points.
| Parameter | Type | Default | Description |
|---|---|---|---|
algorithm |
string (charp) | "lz4" |
Compression algorithm: lz4, zstd, snappy |
target_gb |
int | 256 |
Target zram backend size in GB |
sudo insmod ferromem_zram.ko algorithm=lz4 target_gb=256Path: /sys/kernel/ferromem/
| File | Type | Description |
|---|---|---|
compression_ratio |
float | Current compression ratio (compressed bytes / original bytes) |
effective_memory_bytes |
u64 | Physical RAM + compressed zram (estimated) |
cpu_cycles_saved_total |
u64 | Cumulative CPU cycles avoided vs CPU lz4 |
throughput_bytes_per_second |
u64 | Current compression throughput |
queue_depth |
u32 | Current XRT command queue depth |
errors |
u64 | Cumulative error count |
afi_loaded |
u32 | 1 if AFI bitstream loaded, 0 otherwise |
algorithm |
string | Currently selected algorithm |
Path: /dev/ferromem-zram
Read-only ioctl returning a struct ferromem_stats. See src/include/ferromem.h.
struct ferromem_stats stats;
int fd = open("/dev/ferromem-zram", O_RDONLY);
ioctl(fd, FERROMEM_IOC_GET_STATS, &stats);
printf("bytes_in=%llu bytes_out=%llu ratio=%.2f\n",
stats.bytes_in, stats.bytes_out,
(double)stats.bytes_in / stats.bytes_out);
close(fd);Switch algorithm at runtime. Argument: int matching enum ferromem_algorithm.
int alg = FERROMEM_ALG_ZSTD;
ioctl(fd, FERROMEM_IOC_SET_ALG, &alg);Returns -EBUSY if active compression is in flight; retry after cat /sys/kernel/ferromem/queue_depth returns 0.
Reset stats counters. No argument.
ioctl(fd, FERROMEM_IOC_RESET);After load, the backend is selectable from zram's standard sysfs:
echo ferromem > /sys/block/zram0/comp_algorithmTo verify selection:
cat /sys/block/zram0/comp_algorithm
# expected output contains: [ferromem] lzo lz4 zstd ...The kernel module follows standard Linux errno conventions:
| errno | Meaning |
|---|---|
0 |
Success |
-EOPNOTSUPP |
AFI bitstream not loaded (skeleton mode or AFI failure) |
-EBUSY |
XRT command queue full |
-ETIMEDOUT |
FPGA command exceeded timeout (default 10 ms) |
-EINVAL |
Invalid parameter (algorithm name, etc.) |
-ENOMEM |
Out of memory |
-EIO |
XRT / FPGA hardware error |
lib/ferromem-compress.so exposes a simple C interface:
int ferromem_compress(const void *src, size_t src_len,
void *dst, size_t *dst_len,
const char *algorithm);
int ferromem_decompress(const void *src, size_t src_len,
void *dst, size_t dst_len,
const char *algorithm);Implemented in v0.2.0+; the kernel module is sufficient for zram integration.