Skip to content

Instantly share code, notes, and snippets.

View ethercflow's full-sized avatar
🎯
Focusing

Wenbo Zhang ethercflow

🎯
Focusing
  • SmartX
  • China
View GitHub Profile
package main
import (
"context"
"flag"
"log"
"strings"
"time"
pb "github.com/ethercflow/injuredfs/pb"
@ethercflow
ethercflow / README.md
Last active December 24, 2019 07:34
Test systemd on OnFailure
gcc -o failure-gen failure-gen.c
mv failure-gen.service [email protected] /ets/systemd/system # change [email protected] to your email name
systemctl daemon-reload
mkdir -p /opt/onfailure-test/aaa
mv failure-gen /opt/onfailure-test
systemctl start failure-gen.service
cd /opt/onfailure-test

when run

#!/usr/bin/env python
from __future__ import print_function
from bcc import BPF
from time import sleep, strftime
from datetime import datetime
import sys
bpf_source = """
#include <uapi/linux/ptrace.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/slab.h>
#define N 100000
#define ORDER 2 * 2 * 2
static char *mems[N_MEM];
static int
frag_init(void)
export PATH=$PATH:/opt/linuxki
cd /dev/shm
runki -M -X -G ${tgid} -R -e all -d 120 # (default 20s)
kiall -r
cd local/xxx/
vim kiwait.xxx.txt # 分析等待事件
perf stat -e minor-faults
perf record -e minor-faults -c 1 -ag
@ethercflow
ethercflow / steps
Last active January 18, 2019 07:21
cgroup_resource_mgmt_v1
# 1. create a sub group
create -t <tuid>:<tgid> -g cpuset:<gname>
# 2. get nodes and cores of each node
numactl --hardware
# 3. bind one node's cpu to the sub group
cgset -r cpuset.cpus='n1c1, n1c2,...' <gname>
# 4. can limit mem node too (opt)
cgset -r cpuset.mems='0' <gname>
@ethercflow
ethercflow / calc.c
Last active December 6, 2018 06:14
stp-recipes
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
struct A {
void *(*add)(void *out, void *a, void *b);
};
struct task_struct {
volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */
void *stack;
atomic_t usage;
unsigned int flags; /* per process flags, defined below */
unsigned int ptrace;
#ifdef CONFIG_SMP
struct llist_node wake_entry;
int on_cpu;
/*
* debugfs.h - a tiny little debug file system
*
* Copyright (C) 2004 Greg Kroah-Hartman <[email protected]>
* Copyright (C) 2004 IBM Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 as published by the Free Software Foundation.
*
#!/usr/bin/env bash
source /opt/intel/vtune_amplifier_2018.3.0.558279/amplxe-vars.sh
amplxe-cl -c memory-access -knob analyze-mem-objects=true -knob mem-object-size-min-thres=1024 -run-pass-thru=--no-altstack -target-pid $1