Skip to content

Instantly share code, notes, and snippets.

View congwang-mk's full-sized avatar

Cong Wang congwang-mk

View GitHub Profile
@congwang-mk
congwang-mk / bench_redis.py
Created March 21, 2026 22:08
Sandlock vs Docker Redis benchmark
#!/usr/bin/env python3
"""Benchmark Redis: bare metal vs sandlock vs Docker.
redis-server runs in each environment.
redis-benchmark runs on host, connecting to the server.
Tests SET/GET with small payloads (256 bytes) — similar to RioDB's pattern.
"""
import json
import subprocess
root@localhost:~# kerf exec --console --verbose web-server
Instance name: web-server (ID: 1)
Checking if kernel image is loaded for instance 'web-server'...
Status file: /sys/fs/multikernel/instances/web-server/status
Instance status: 'loaded'
✓ Kernel image found for instance 'web-server'
Instance ID to boot: 1
Using reboot syscall with command: 0x4d4b4c49
Calling reboot syscall at TSC 126359934520
✓ Boot command executed successfully (result: 0)
@congwang-mk
congwang-mk / tsc_elapsed.py
Created January 22, 2026 02:43
Python tool to convert TSC to ms
#!/usr/bin/env python3
import sys
import re
def get_tsc_freq_mhz():
with open('/proc/cpuinfo', 'r') as f:
for line in f:
if line.startswith('cpu MHz'):
match = re.search(r':\s*([\d.]+)', line)
if match:
@congwang-mk
congwang-mk / dmesg.txt
Created January 10, 2026 02:36
36ms kernel boot
[ 0.000000] Linux version 6.19.0-rc2+ (wangcong@pop-os) (gcc (Ubuntu 12.3.0-1ubuntu1~22.04.2) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #2033 SMP Fri Jan 9 18:33:57 PST 2026
[ 0.000000] Command line: pci=noaer,lastbus=0 lpj=999999 clocksource=tsc tsc=reliable pci=realloc=off random.trust_cpu=on console=ttyS0 pci=nobar quiet rootfstype=daxfs rootflags=phys=0x48000000,size=9834496 init=/init
[ 0.000000] x86 CPU feature dependency check failure: CPU0 has '18*32+31' enabled but '18*32+26' disabled. Kernel might be fine, but no guarantees.
[ 0.000000] BIOS-provided physical RAM map:
[ 0.000000] MULTIKERNEL: [mem 0x0000000040000000-0x0000000047ffffff] usable
[ 0.000000] random: crng init done
[ 0.000000] setup: detected multikernel KHO data
[ 0.000000] KHO: Multikernel KHO: processing FDT at 0x3bfd000 (size: 4096)
[ 0.000000] KHO: Multikernel KHO: successfully populated FDT data
[ 0.000000] NX (Execute Disable) protection: active
@congwang-mk
congwang-mk / dmesg.txt
Created December 29, 2025 22:17
49ms kernel boot message
[ 0.000000] Linux version 6.19.0-rc2+ (wangcong@pop-os) (gcc (Ubuntu 12.3.0-1ubuntu1~22.04.2) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #1438 SMP PREEMPT_DYNAMIC Mon Dec 29 14:00:12 PST 2025
[ 0.000000] Command line: pci=noaer,lastbus=0 lpj=999999 clocksource=tsc tsc=reliable pci=realloc=off random.trust_cpu=on loglevel=0 quiet 8250.nr_uarts=0 console=ttyprintk pci=nobar rootfstype=daxfs rootflags=phys=0x48000000,size=9838592 init=/init
[ 0.000000] x86 CPU feature dependency check failure: CPU0 has '18*32+31' enabled but '18*32+26' disabled. Kernel might be fine, but no guarantees.
[ 0.000000] BIOS-provided physical RAM map:
[ 0.000000] BIOS-e820: [mem 0x0000000000001000-0x000000000009fbff] usable
[ 0.000000] BIOS-e820: [mem 0x0000000040000000-0x0000000047ffffff] usable
[ 0.000000] random: crng init done
[ 0.000000] setup: detected multikernel KHO data
[ 0.000000] KHO: Multikernel KHO: processing FDT at 0xb708000 (size: 4096)
[ 0.000000] KHO: Multikernel KHO: successfully po
@congwang-mk
congwang-mk / kernel.config
Last active December 10, 2025 00:40
Multikernel kernel config
#
# Automatically generated file; DO NOT EDIT.
# Linux/x86 6.18.0 Kernel Configuration
#
CONFIG_CC_VERSION_TEXT="gcc (Ubuntu 12.3.0-1ubuntu1~22.04.2) 12.3.0"
CONFIG_CC_IS_GCC=y
CONFIG_GCC_VERSION=120300
CONFIG_CLANG_VERSION=0
CONFIG_AS_IS_GNU=y
CONFIG_AS_VERSION=23800
@congwang-mk
congwang-mk / mk_vsock_server.c
Created November 12, 2025 17:10
Multikernel Vsock Test (Server)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sys/socket.h>
#include <linux/vm_sockets.h>
#define VSOCK_TRANSPORT_VM 0
#define VSOCK_TRANSPORT_MULTIKERNEL 1
@congwang-mk
congwang-mk / mk_vsock_client.c
Created November 12, 2025 17:09
Multikernel Vsock Test (Client)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sys/socket.h>
#include <linux/vm_sockets.h>
#define VSOCK_TRANSPORT_VM 0
#define VSOCK_TRANSPORT_MULTIKERNEL 1
@congwang-mk
congwang-mk / pci_whitelist.diff
Created October 31, 2025 03:03
pci_whitelist= boot parameter
commit b872ae8254207560b5039bf56c7af104088818d3
Author: Cong Wang <xiyou.wangcong@gmail.com>
Date: Fri May 9 15:10:04 2025 -0700
pci: introduce pci_whitelist= boot parameter
Use it like this: pci_whitelist=1af4:1041@0000:09:00.0
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
#!/bin/bash
mount -t multikernel none /sys/fs/multikernel
cat mk_instance1.dtb > /sys/fs/multikernel/device_tree
grep Multikernel -A 2 /proc/iomem
echo "0000:09:00.0" > /sys/bus/pci/devices/0000:09:00.0/driver/unbind
memmap=$(
awk '/mk-instance-1-web-server-region/ {