diff --git a/ucomp_bench.sh b/ucomp_bench.sh new file mode 100755 index 0000000..1a034fe --- /dev/null +++ b/ucomp_bench.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Recompile ucomp +make -C /workspace/ucomp clean && make -C /workspace/ucomp + +# Stop all current ucomp compressors and unload module (ignore errors) +ucomp unregister zstd 2>/dev/null || true +ucomp unregister lzo 2>/dev/null || true +pkill -f ucomp || true +rmmod ucomp 2>/dev/null || true + +# Insert ucomp module +insmod /workspace/ucomp/ucomp.ko + +# Start ucompd and register compressors +ucompd register + +# Run benchmark for ucomp-zstd (insmod may report 'busy' if already loaded) +insmod ./comp_bench.ko alg=ucomp-zstd path=/workspace/linux_compile/vmlinux || true + +# Run benchmark for ucomp-lzo (insmod may report 'busy' if already loaded) +insmod ./comp_bench.ko alg=ucomp-lzo path=/workspace/linux_compile/vmlinux || true diff --git a/ucomp_cmd.c b/ucomp_cmd.c new file mode 100644 index 0000000..45fa6e9 --- /dev/null +++ b/ucomp_cmd.c @@ -0,0 +1,53 @@ +#include +#include +#include +#include +#include +#include +#include + +#define UCOMP_CTRL_PATH "/dev/ucomp_ctrl" +#define UCOMP_IOC_MAGIC 'u' +#define UCOMP_IOC_REGISTER _IOW(UCOMP_IOC_MAGIC, 1, char *) +#define UCOMP_IOC_UNREGISTER _IOW(UCOMP_IOC_MAGIC, 2, char *) + +static void usage(const char *prog) +{ + fprintf(stderr, "Usage: %s \n", prog); +} + +int main(int argc, char *argv[]) +{ + if (argc != 3) { + usage(argv[0]); + return EXIT_FAILURE; + } + + const char *cmd = argv[1]; + const char *alg = argv[2]; + int fd = open(UCOMP_CTRL_PATH, O_RDWR); + if (fd < 0) { + perror("open"); + return EXIT_FAILURE; + } + + int ret; + if (strcmp(cmd, "register") == 0) { + ret = ioctl(fd, UCOMP_IOC_REGISTER, alg); + } else if (strcmp(cmd, "unregister") == 0) { + ret = ioctl(fd, UCOMP_IOC_UNREGISTER, alg); + } else { + usage(argv[0]); + close(fd); + return EXIT_FAILURE; + } + + if (ret < 0) { + perror(cmd); + close(fd); + return EXIT_FAILURE; + } + + close(fd); + return EXIT_SUCCESS; +}