Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions ucomp_bench.sh
Original file line number Diff line number Diff line change
@@ -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
53 changes: 53 additions & 0 deletions ucomp_cmd.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <unistd.h>

#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 <register|unregister> <algorithm>\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;
}