First Commit
This commit is contained in:
29
usr/bin/kerver
Executable file
29
usr/bin/kerver
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
cat << EOF
|
||||
Check kernel version:
|
||||
|
||||
$(cat /proc/version && uname -a)
|
||||
|
||||
|
||||
Check x86_64 support:
|
||||
|
||||
$(/lib64/ld-linux-x86-64.so.2 --help | grep "(supported, searched)")
|
||||
|
||||
|
||||
Check CPU config:
|
||||
|
||||
$(zgrep -iE 'CONFIG_(GENERIC_CPU(=| is)|X86_64_VERSION|MZEN|MBULLDOZER|MPILEDRIVER|MSTREAMROLLER|MEXCAVATOR|MBOBCAT|MJAGUAR|MK10|MK8SSE3|MATOM|MGOLDMONTPLUS|MSKYLAKE2|MIVYBRIDGE|MICELAKE|MNATIVE_INTEL|MNATIVE_AMD|X86_NATIVE_CPU)' /proc/config.gz)
|
||||
|
||||
|
||||
Current disk schedulers:
|
||||
|
||||
$(for disk in /sys/block/*/
|
||||
do [ -f "$disk/queue/scheduler" ] \
|
||||
&& echo "$(basename "$disk"): $(cat "$disk/queue/scheduler")"
|
||||
done)
|
||||
|
||||
Check available schedulers:
|
||||
|
||||
$(journalctl --output cat -k | grep -i scheduler)
|
||||
EOF
|
||||
19
usr/bin/pci-latency
Executable file
19
usr/bin/pci-latency
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env sh
|
||||
# This script is designed to improve the performance and reduce audio latency
|
||||
# for sound cards by setting the PCI latency timer to an optimal value of 80
|
||||
# cycles. It also resets the default value of the latency timer for other PCI
|
||||
# devices, which can help prevent devices with high default latency timers from
|
||||
# causing gaps in sound.
|
||||
|
||||
# Check if the script is run with root privileges
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "Error: This script must be run with root privileges." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Reset the latency timer for all PCI devices
|
||||
setpci -v -s '*:*' latency_timer=20
|
||||
setpci -v -s '0:0' latency_timer=0
|
||||
|
||||
# Set latency timer for all sound cards
|
||||
setpci -v -d "*:*:04xx" latency_timer=80
|
||||
219
usr/bin/topmem
Executable file
219
usr/bin/topmem
Executable file
@@ -0,0 +1,219 @@
|
||||
#!/usr/bin/env lua
|
||||
local f, concat, sort = string.format, table.concat, table.sort
|
||||
local found, uv = pcall(require, 'luv')
|
||||
|
||||
local function die(err, ...)
|
||||
print(err:format(...))
|
||||
os.exit(1)
|
||||
end
|
||||
|
||||
if not found then
|
||||
die("lua-luv dependency is missing, please install it from repositories")
|
||||
end
|
||||
|
||||
local function printf(pattern, ...)
|
||||
print(pattern:format(...))
|
||||
end
|
||||
|
||||
-- Patterns
|
||||
local pid_pattern = "[0-9]+"
|
||||
local ksm_profit_pattern = "ksm_process_profit%s*([0-9]+)"
|
||||
local vm_rss_pattern = "VmRSS:%s*([0-9]+)"
|
||||
local vm_swap_pattern = "VmSwap:%s*([0-9]+)"
|
||||
|
||||
local function get_process_values(pid)
|
||||
local path = concat({ "/proc", pid, "status" }, "/")
|
||||
local file = io.open(path)
|
||||
|
||||
if not file then
|
||||
return nil
|
||||
end
|
||||
|
||||
local rss, swap
|
||||
local line = file:read()
|
||||
while line do
|
||||
if rss == nil then
|
||||
rss = line:match(vm_rss_pattern)
|
||||
elseif swap == nil then
|
||||
swap = line:match(vm_swap_pattern)
|
||||
else
|
||||
break
|
||||
end
|
||||
line = file:read()
|
||||
end
|
||||
file:close()
|
||||
return tonumber(rss), tonumber(swap)
|
||||
end
|
||||
|
||||
local function get_process_ksm_profit(pid)
|
||||
local file = io.open(concat({ "/proc", pid, "ksm_stat" }, "/"))
|
||||
|
||||
if not file then
|
||||
return 0
|
||||
end
|
||||
|
||||
local stat = file:read("*a")
|
||||
local profit = stat:match(ksm_profit_pattern)
|
||||
|
||||
file:close()
|
||||
|
||||
if not profit then
|
||||
return 0
|
||||
end
|
||||
|
||||
return tonumber(profit)
|
||||
end
|
||||
|
||||
local function get_process_first_arg(pid)
|
||||
local file = io.open(concat({ "/proc", pid, "cmdline" }, "/"))
|
||||
|
||||
if not file then
|
||||
return nil
|
||||
end
|
||||
|
||||
local cmdline = file:read("*all")
|
||||
file:close()
|
||||
|
||||
return cmdline:match("([^%z]+)")
|
||||
end
|
||||
|
||||
local function convert_hashmap_table(map)
|
||||
local new_hashmap = {}
|
||||
for key, value in pairs(map) do
|
||||
new_hashmap[#new_hashmap + 1] = { value[1], value[2], value[3], key }
|
||||
end
|
||||
|
||||
return new_hashmap
|
||||
end
|
||||
|
||||
local function get_process_map(sort_by)
|
||||
local map = {}
|
||||
local processes = uv.fs_scandir("/proc")
|
||||
local pid, ftype = uv.fs_scandir_next(processes)
|
||||
|
||||
while pid do
|
||||
if pid:match(pid_pattern) then
|
||||
if ftype == "directory" then
|
||||
local rss, swap = get_process_values(pid)
|
||||
local name = get_process_first_arg(pid)
|
||||
local ksm_profit = get_process_ksm_profit(pid)
|
||||
if name and rss then
|
||||
if map[name] then
|
||||
map[name][1] = map[name][1] + rss
|
||||
map[name][2] = map[name][2] + swap
|
||||
map[name][3] = map[name][3] + ksm_profit
|
||||
else
|
||||
map[name] = { rss, swap, ksm_profit }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
pid, ftype = uv.fs_scandir_next(processes)
|
||||
end
|
||||
map = convert_hashmap_table(map)
|
||||
sort(map, function(a, b) return (a[sort_by] > b[sort_by]) end)
|
||||
return map
|
||||
end
|
||||
|
||||
local function truncate(str)
|
||||
if #str > 25 then
|
||||
return str:sub(1, 25) .. "..."
|
||||
else
|
||||
return str
|
||||
end
|
||||
end
|
||||
|
||||
local function get_filename(path)
|
||||
local lastSlash = path:find("/[^/]*$")
|
||||
if lastSlash then
|
||||
return path:sub(lastSlash + 1)
|
||||
else
|
||||
return path
|
||||
end
|
||||
end
|
||||
|
||||
local function print_top(size, sort_by)
|
||||
local map = get_process_map(sort_by)
|
||||
printf("%-9s %35s %-9s %-s", "MEMORY", "Top " .. size .. " processes ", "SWAP", "KSM")
|
||||
for i = 1, size do
|
||||
local entry = map[i]
|
||||
if entry then
|
||||
printf(
|
||||
"%-9s %-35s %-9s %-s",
|
||||
f("%.0f", entry[1] / 1024) .. "M",
|
||||
truncate(get_filename(entry[4])),
|
||||
f("%.0f", entry[2] / 1024) .. "M",
|
||||
f("%.0f", entry[3] / 1024 / 1024) .. "M"
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function print_help()
|
||||
print([[
|
||||
Shows names of the top 10 (or N) processes by memory consumption
|
||||
|
||||
Usage: topmem [OPTIONS] [N]
|
||||
|
||||
Arguments:
|
||||
[N] [default: 10]
|
||||
|
||||
Options:
|
||||
-s, --sort <TYPE> Column to sort by [possible values: rss (default), swap, ksm]
|
||||
-h, --help Show this message]]
|
||||
)
|
||||
os.exit(0)
|
||||
end
|
||||
|
||||
local function main()
|
||||
local sort_types = {
|
||||
["rss"] = 1,
|
||||
["swap"] = 2,
|
||||
["ksm"] = 3
|
||||
}
|
||||
local sort_by = sort_types["rss"]
|
||||
local size
|
||||
local i = 1
|
||||
while i < #arg + 1 do
|
||||
if arg[i] == "--sort" or arg[i] == "-s" or arg[i]:match("--sort=*") then
|
||||
local criteria
|
||||
local shift = true
|
||||
|
||||
for value in string.gmatch(arg[i], "([^=]+)") do
|
||||
if value ~= "--sort" and value ~= "-s" then
|
||||
criteria = value
|
||||
shift = false
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
criteria = criteria or arg[i + 1]
|
||||
if not criteria then
|
||||
die("Column to sort by is not specified")
|
||||
end
|
||||
|
||||
if not sort_types[criteria] then
|
||||
die("Wrong sorting criterion. Only available: rss, swap, ksm.")
|
||||
else
|
||||
sort_by = sort_types[criteria]
|
||||
if shift then
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
elseif arg[i] == "--help" or arg[i] == "-h" then
|
||||
print_help()
|
||||
else
|
||||
local status, value = pcall(tonumber, arg[i])
|
||||
if not status then
|
||||
die("The argument must be a number")
|
||||
else
|
||||
size = value
|
||||
end
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
print_top(size or 10, sort_by)
|
||||
end
|
||||
|
||||
main()
|
||||
6
usr/bin/zink-run
Executable file
6
usr/bin/zink-run
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
export MESA_LOADER_DRIVER_OVERRIDE=zink
|
||||
export GALLIUM_DRIVER=zink
|
||||
export __GLX_VENDOR_LIBRARY_NAME=mesa
|
||||
export __EGL_VENDOR_LIBRARY_FILENAMES=/usr/share/glvnd/egl_vendor.d/50_mesa.json
|
||||
exec "$@"
|
||||
Reference in New Issue
Block a user