Skip to content

Instantly share code, notes, and snippets.

View mhiramat's full-sized avatar

Masami HIRAMATSU mhiramat

  • Google
  • Japan
View GitHub Profile
@mhiramat
mhiramat / tailcall.c
Created June 22, 2020 23:49
Tail call example
#include <stdio.h>
#include <stdlib.h>
int __attribute__((noinline)) function1(int a, int b)
{
if (a <= b)
return a;
a -= b;
return function1(a, b);
}
@mhiramat
mhiramat / facedetect_masking_filter.py
Last active May 4, 2020 23:14
Face Detection and masking filter program with fake webcam
import cv2
import numpy
import pyfakewebcam as fakecam
import threading, queue
from time import sleep
imq = queue.Queue()
rectq = queue.Queue()
def faceDetector():
@mhiramat
mhiramat / Draft-of-kretprobe-issue-investigation.txt
Created January 3, 2019 14:41
Kretprobe combination bug investigation report
Hello,
On recent talk with Andrea, I started more precise investigation of
the reported kretprobe issue with notrace functions.
At first, I tried to reproduce the issue. I picked up __fdget and
ftrace_ops_assist_func as probed functions.
With CONFIG_KPROBE_EVENTS_ON_NOTRACE=y, I could reproduce the kernel
panic as below.
@mhiramat
mhiramat / gist:18d6b2a80a16bf8692faae988624fa5b
Created December 25, 2018 14:34
Using xarray in kprobes cause RCU error
[381] Probing on seq_hlist_start 7 sec
[382] Probing on __x64_sys_finit_module 7 sec
[383] Probing on vgacon_set_palette 7 sec
[384] Probing on cp_compat_stat 7 sec
[385] Probing on smp_call_function_single_interrupt [ 37.669723]
[ 37.672350] =============================
[ 37.675551] WARNING: suspicious RCU usage
[ 37.678733] 4.20.0-rc7+ #29 Not tainted
[ 37.681849] -----------------------------
[ 37.685034] /home/mhiramat/ksrc/linux/include/linux/rcupdate.h:609 rcu_read_lock() used illegally while idle!
/ # [ 1.854550] input: ImExPS/2 Generic Explorer Mouse as /devices/platform/i8042/serio1/input/input3
exit
[ 11.672737] ACPI: Preparing to enter system sleep state S5
[ 11.676601] reboot: Power down
[ 11.681659] ------------[ cut here ]------------
[ 11.682686] sched: Unexpected reschedule of offline CPU#6!
[ 11.683625] WARNING: CPU: 0 PID: 1262 at /home/mhiramat/ksrc/linux/arch/x86/kernel/smp.c:128 native_smp_send_reschedule+0x39/0x40
[ 11.685473] Modules linked in:
[ 11.686047] CPU: 0 PID: 1262 Comm: init Not tainted 4.19.5 #18
[ 11.687023] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.10.1-0-g8891697-prebuilt.qemu-project.org 04/01/2014
@mhiramat
mhiramat / bench.sh
Last active February 26, 2018 23:46
Benchmarking kprobe-event
#!/bin/sh
#set -xe
mount -t debugfs debug /sys/kernel/debug
cd /sys/kernel/debug/tracing
runbench() {
sync
echo "runbench: $1"
@mhiramat
mhiramat / gist:13887f1026d7193a64552c5c345ee27a
Created July 14, 2017 14:10
Linux 4.12.1 kernel overlayfs bug
[ 1153.461894] BUG: unable to handle kernel paging request at ffffffffc0cd8667
[ 1153.461938] IP: report_bug+0x84/0xe0
[ 1153.461956] PGD 392e0d067
[ 1153.461957] P4D 392e0d067
[ 1153.461970] PUD 392e0f067
[ 1153.461983] PMD 48e7bd067
[ 1153.462006] PTE 80000004855d3161
[ 1153.462043] Oops: 0003 [#2] SMP
[ 1153.462058] Modules linked in: overlay xt_CHECKSUM ipt_MASQUERADE nf_nat_masquerade_ipv4 xt_addrtype rfcomm fuse nf_conntrack_tftp ip6t_rpfilter ip6t_REJECT nf_reject_ipv6 ipt_REJECT nf_reject_ipv4 xt_conntrack ip_set ebtable_nat ebtable_filter ebtable_broute ebtables ip6table_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 ip6table_raw ip6table_mangle ip6table_security ip6table_filter ip6_tables iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat iptable_raw iptable_mangle iptable_security iptable_filter ip_tables bnep binfmt_misc nls_iso8859_1 i2c_designware_platform i2c_designware_core snd_hda_codec_hdmi dell_wmi dell_laptop dell_smbios dcdbas brcmfmac snd_hda_codec_realtek snd_hda_cod
@mhiramat
mhiramat / ermine-cause-crash.log
Created April 25, 2017 14:12
Wait! this is not Ryzen bug, but Qemu bug...
[ 0.058632] HugeTLB registered 2 MB page size, pre-allocated 0 pages
[ 0.075999] raid6: sse2x1 gen() 9820 MB/s
[ 0.092999] raid6: sse2x1 xor() 7681 MB/s
[ 0.110000] raid6: sse2x2 gen() 12304 MB/s
[ 0.126999] raid6: sse2x2 xor() 8460 MB/s
[ 0.143999] raid6: sse2x4 gen() 14363 MB/s
[ 0.161000] raid6: sse2x4 xor() 10099 MB/s
[ 0.162003] invalid opcode: 0000 [#1] SMP
[ 0.162310] Modules linked in:
[ 0.162549] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.11.0-rc6+ #1
@mhiramat
mhiramat / build-error-log.log
Created April 9, 2017 08:21
Build error with gcc5.3.0-musl1.1.14
In file included from /home/mhiramat/ksrc/mincs/work/gcc-openrisc/or1k-linux-musl/or1k-linux-musl/include/netdb.h:9:0,
from include/libbb.h:20,
from networking/tcpudp.c:69:
/home/mhiramat/ksrc/mincs/work/gcc-openrisc/or1k-linux-musl/or1k-linux-musl/include/linux/in.h:28:3: error: expected identifier before numeric constant
IPPROTO_IP = 0, /* Dummy protocol for TCP */
^
In file included from /home/mhiramat/ksrc/mincs/work/gcc-openrisc/or1k-linux-musl/or1k-linux-musl/include/linux/netfilter.h:7:0,
from /home/mhiramat/ksrc/mincs/work/gcc-openrisc/or1k-linux-musl/or1k-linux-musl/include/linux/netfilter_ipv4.h:8,
from networking/tcpudp.c:75:
/home/mhiramat/ksrc/mincs/work/gcc-openrisc/or1k-linux-musl/or1k-linux-musl/include/linux/in.h:84:8: error: redefinition of 'struct in_addr'
@mhiramat
mhiramat / gpu-hang-log.txt
Created March 30, 2017 11:10
GPU hang in 4.10.6
[41886.708659] [drm] GPU HANG: ecode 9:0:0x84dffff8, in Xorg [1366], reason: Hang on render ring, action: reset
[41886.708660] [drm] GPU hangs can indicate a bug anywhere in the entire gfx stack, including userspace.
[41886.708660] [drm] Please file a _new_ bug report on bugs.freedesktop.org against DRI -> DRM/Intel
[41886.708660] [drm] drm/i915 developers can then reassign to the right component if it's not a kernel issue.
[41886.708661] [drm] The gpu crash dump is required to analyze gpu hangs, so please always attach it.
[41886.708661] [drm] GPU crash dump saved to /sys/class/drm/card0/error
[41886.708758] drm/i915: Resetting chip after gpu hang
[41886.708831] [drm] RC6 on
[41886.723408] [drm] GuC firmware load skipped