Skip to content

Instantly share code, notes, and snippets.

View denji's full-sized avatar
πŸ‡ΊπŸ‡¦

Denis Denisov denji

πŸ‡ΊπŸ‡¦
View GitHub Profile
@ibireme
ibireme / kpc_demo.c
Last active December 1, 2025 00:45
A demo shows how to read Intel or Apple M1 CPU performance counter in macOS.
// =============================================================================
// XNU kperf/kpc demo
// Available for 64-bit Intel/Apple Silicon, macOS/iOS, with root privileges
//
//
// Demo 1 (profile a function in current thread):
// 1. Open directory '/usr/share/kpep/', find your CPU PMC database.
// M1 (Pro/Max/Ultra): /usr/share/kpep/a14.plist
// M2 (Pro/Max): /usr/share/kpep/a15.plist
// M3: /usr/share/kpep/as1.plist
@krzys-h
krzys-h / Hyper-V GPU-PV with Linux guest.md
Last active December 11, 2025 09:12
Ubuntu 21.04 VM with GPU acceleration under Hyper-V...?

Ubuntu 21.04 VM with GPU acceleration under Hyper-V...?

Modern versions of Windows support GPU paravirtualization in Hyper-V with normal consumer graphics cards. This is used e.g. for graphics acceleration in Windows Sandbox, as well as WSLg. In some cases, it may be useful to create a normal VM with GPU acceleration using this feature, but this is not officially supported. People already figured out how to do it with Windows guests though, so why not do the same with Linux? It should be easy given that WSLg is open source and reasonably well documented, right?

Well... not quite. I managed to get it to run... but not well.

How to do it?

  1. Verify driver support
@oleduc
oleduc / isolate-cpus.sh
Last active November 2, 2025 15:32
CPU isolation bash script for KVM QEMU VFIO gpu passthrough for virtual machine performance optimizations using libvirt-hooks and cgroups
#!/bin/bash
# Cores reserved for the host machine
# Must include QEMU IO/Emulation cores if configured
# Ex: 1st Core -> reserved=0
# Ex: 1st & 2nt Cores -> reserved=0,1
# Ex: 1st Physical Core (16 Virtual Cores) -> reserved=0,8
reserved=0,8
# Host core range numbered from 0 to core count - 1
@nijave
nijave / gigabyte-x470-gaming-7-sensors.sh
Last active July 1, 2024 00:13
Setup sensors for Gigabyte X470 Gaming 7 w/ Fedora
#!/bin/sh
# The chip info can be found via sensors-detect in lm_sensors
# Driver `to-be-written':
# * ISA bus, address 0xa40
# Chip `ITE IT8686E Super IO Sensors' (confidence: 9)
# Driver `it87':
# * ISA bus, address 0xa60
# Chip `ITE IT8792E Super IO Sensors' (confidence: 9)
@x0nu11byt3
x0nu11byt3 / elf_format_cheatsheet.md
Created February 27, 2021 05:26
ELF Format Cheatsheet

ELF Format Cheatsheet

Introduction

Executable and Linkable Format (ELF), is the default binary format on Linux-based systems.

ELF

Compilation

@jart
jart / reallz4.S
Created January 13, 2021 01:17
Tiniest lz4 block copier that's binary compatible with i8086 + i386 + x86_64
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-β”‚
β”‚vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :viβ”‚
β•žβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•‘
β”‚ Copyright 2020 Justine Alexandra Roberts Tunney β”‚
β”‚ β”‚
β”‚ Permission to use, copy, modify, and/or distribute this software for β”‚
β”‚ any purpose with or without fee is hereby granted, provided that the β”‚
β”‚ above copyright notice and this permission notice appear in all copies. β”‚
β”‚ β”‚
β”‚ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL β”‚
@null-dev
null-dev / disable-fb.sh
Created January 7, 2021 06:50
Disable efifb at runtime
#!/usr/bin/env bash
# 1. Download and install the QEMU hook helper from here: https://github.com/PassthroughPOST/VFIO-Tools
# 2. Place this file in /etc/libvirt/hooks/qemu.d/NAME OF YOUR VM/prepare/begin/disable-fb.sh
# 3. Make disable-fb.sh executable.
VM_NAME="$1"
echo "libvirt-qemu disable-fb: Disabling efi-framebuffer to prepare to pass GPU to VM $VM_NAME" > /dev/kmsg 2>&1
echo "efi-framebuffer.0" > /sys/bus/platform/devices/efi-framebuffer.0/driver/unbind
@Th3Whit3Wolf
Th3Whit3Wolf / Arch Secure Laptop Install.md
Last active May 4, 2025 09:37
My install instruction for a secure Arch Linux (sway) laptop workstation

What's Cool

  • Encrypted root partition
    • AES-256 bit cipher
    • Argon2id variant for PBKDF
    • Sha3-512 bit hash
  • rEFInd bootloader
    • With dreary theme
    • Optimal Settings (optimized for aesthetics, and boot time)
  • Boot into backups thanks to refind-btrfs
@jart
jart / defer.c
Last active March 26, 2024 07:08
Go-like defer for C that works with most optimization flag combinations under GCC/Clang
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-β”‚
β”‚vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :viβ”‚
β•žβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•‘
β”‚ Copyright 2020 Justine Alexandra Roberts Tunney β”‚
β”‚ β”‚
β”‚ Permission to use, copy, modify, and/or distribute this software for β”‚
β”‚ any purpose with or without fee is hereby granted, provided that the β”‚
β”‚ above copyright notice and this permission notice appear in all copies. β”‚
β”‚ β”‚
β”‚ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL β”‚
@ShannonScott
ShannonScott / nvidia_gpu_list.sh
Last active June 4, 2023 20:32
[List NVDIA GPUs] Bash array of GPUs in a system. #tags: nvidia, gpu, bash
#!/bin/bash
# Get a list of GPUs in a system
#
# Useful nvidia-smi Queries
# https://nvidia.custhelp.com/app/answers/detail/a_id/3751/~/useful-nvidia-smi-queries
# Get GPU names as a bach array, replace spaces with underscores
gpu_names=($(nvidia-smi --query-gpu=gpu_name --format=csv,noheader | tr -s ' ' '_'))
for name in "${gpu_names[@]}"