Detect which process slows down my shutdown/reboot

So I am struggling from very slow shutdowns or reboots. This happens not ALL the time, for example if it happens and I restart my machine afterwards and then try to provoke the behaviour the shutdown/reboot is very fast. But if I used my machine for quite a while the shutdown makes a break for ~90ish seconds - so there must be some kind of timeout involved. How do I analyze the root cause of this behaviour? My question is not only targeted for the solution, but also letting me learn how to perform diagnostics…
Any help would be appreciated!

sudo inxi -Faz
System:
  Kernel: 6.0.8-1-MANJARO arch: x86_64 bits: 64 compiler: gcc v: 12.2.0
    parameters: BOOT_IMAGE=/boot/vmlinuz-6.0-x86_64
    root=UUID=f8b3941a-e541-4f5d-b8d9-be01fa0cf445 ro quiet
    udev.log_priority=3 amdgpu.ppfeaturemask=0xffffffff
  Desktop: KDE Plasma v: 5.26.3 tk: Qt v: 5.15.7 wm: kwin_x11 dm: SDDM
    Distro: Manjaro Linux base: Arch Linux
Machine:
  Type: Desktop System: Micro-Star product: MS-7C84 v: 1.0 serial: N/A
  Mobo: Micro-Star model: MAG X570 TOMAHAWK WIFI (MS-7C84) v: 1.0
    serial: <filter> UEFI: American Megatrends LLC. v: 1.70 date: 06/23/2021
CPU:
  Info: model: AMD Ryzen 9 5950X socket: AM4 bits: 64 type: MT MCP arch: Zen 3
    gen: 4 level: v3 note: check built: 2021-22 process: TSMC n7 (7nm)
    family: 0x19 (25) model-id: 0x21 (33) stepping: 0 microcode: 0xA201016
  Topology: cpus: 1x cores: 16 tpc: 2 threads: 32 smt: enabled cache:
    L1: 1024 KiB desc: d-16x32 KiB; i-16x32 KiB L2: 8 MiB desc: 16x512 KiB
    L3: 64 MiB desc: 2x32 MiB
  Speed (MHz): avg: 3400 min/max: 2200/5083 boost: enabled
    base/boost: 3400/5050 scaling: driver: acpi-cpufreq governor: performance
    volts: 1.1 V ext-clock: 100 MHz cores: 1: 3400 2: 3400 3: 3400 4: 3400
    5: 3400 6: 3400 7: 3400 8: 3400 9: 3400 10: 3400 11: 3400 12: 3400
    13: 3400 14: 3400 15: 3400 16: 3400 17: 3400 18: 3400 19: 3400 20: 3400
    21: 3400 22: 3400 23: 3400 24: 3400 25: 3400 26: 3400 27: 3400 28: 3400
    29: 3400 30: 3400 31: 3400 32: 3400 bogomips: 217681
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm
  Vulnerabilities:
  Type: itlb_multihit status: Not affected
  Type: l1tf status: Not affected
  Type: mds status: Not affected
  Type: meltdown status: Not affected
  Type: mmio_stale_data status: Not affected
  Type: retbleed status: Not affected
  Type: spec_store_bypass mitigation: Speculative Store Bypass disabled via
    prctl
  Type: spectre_v1 mitigation: usercopy/swapgs barriers and __user pointer
    sanitization
  Type: spectre_v2 mitigation: Retpolines, IBPB: conditional, IBRS_FW,
    STIBP: always-on, RSB filling, PBRSB-eIBRS: Not affected
  Type: srbds status: Not affected
  Type: tsx_async_abort status: Not affected
Graphics:
  Device-1: AMD Navi 21 [Radeon RX 6800/6800 XT / 6900 XT] driver: amdgpu
    v: kernel arch: RDNA-2 code: Navi-2x process: TSMC n7 (7nm) built: 2020-22
    pcie: gen: 4 speed: 16 GT/s lanes: 16 ports: active: DP-1,DP-2
    empty: DP-3,HDMI-A-1 bus-ID: 2f:00.0 chip-ID: 1002:73bf class-ID: 0300
  Display: x11 server: X.Org v: 21.1.4 compositor: kwin_x11 driver: X:
    loaded: amdgpu unloaded: modesetting,radeon alternate: fbdev,vesa
    dri: radeonsi gpu: amdgpu display-ID: :0 screens: 1
  Screen-1: 0 s-res: 3840x1200 s-dpi: 96 s-size: 1016x317mm (40.00x12.48")
    s-diag: 1064mm (41.9")
  Monitor-1: DP-1 mapped: DisplayPort-0 pos: primary,left model: HP ZR24w
    serial: <filter> built: 2011 res: 1920x1200 hz: 60 dpi: 94 gamma: 1.2
    size: 518x324mm (20.39x12.76") diag: 611mm (24.1") ratio: 16:10 modes:
    max: 1920x1200 min: 640x480
  Monitor-2: DP-2 mapped: DisplayPort-1 pos: right model: HP ZR24w
    serial: <filter> built: 2011 res: 1920x1200 hz: 60 dpi: 94 gamma: 1.2
    size: 518x324mm (20.39x12.76") diag: 611mm (24.1") ratio: 16:10 modes:
    max: 1920x1200 min: 640x480
  API: OpenGL v: 4.6 Mesa 22.2.3 renderer: AMD Radeon RX 6800 XT (navi21
    LLVM 14.0.6 DRM 3.48 6.0.8-1-MANJARO) direct render: Yes
Audio:
  Device-1: AMD Navi 21/23 HDMI/DP Audio driver: snd_hda_intel v: kernel pcie:
    bus-ID: 1-2:3 gen: 4 chip-ID: 152a:8750 speed: 16 GT/s class-ID: fe01
    lanes: 16 bus-ID: 2f:00.1 chip-ID: 1002:ab28 class-ID: 0403
  Device-2: Thesycon System & Consulting GmbH DX3 Pro+ type: USB
    driver: snd-usb-audio
  Sound API: ALSA v: k6.0.8-1-MANJARO running: yes
  Sound Server-1: JACK v: 1.9.21 running: no
  Sound Server-2: PulseAudio v: 16.1 running: yes
  Sound Server-3: PipeWire v: 0.3.59 running: yes
Network:
  Device-1: Mellanox MT27500 Family [ConnectX-3] driver: mlx4_core v: 4.0-0
    pcie: gen: 3 speed: 8 GT/s lanes: 4 port: N/A bus-ID: 24:00.0
    chip-ID: 15b3:1003 class-ID: 0200
  IF: enp36s0 state: up speed: 10000 Mbps duplex: full mac: <filter>
  IF-ID-1: br10 state: down mac: <filter>
  IF-ID-2: VLAN_30 state: up speed: 10000 Mbps duplex: full mac: <filter>
Bluetooth:
  Device-1: Intel AX200 Bluetooth type: USB driver: btusb v: 0.8 bus-ID: 1-4:5
    chip-ID: 8087:0029 class-ID: e001
  Report: rfkill ID: hci0 rfk-id: 0 state: up address: see --recommends
Drives:
  Local Storage: total: 18.66 TiB used: 6.4 TiB (34.3%)
  ID-1: /dev/nvme0n1 maj-min: 259:0 vendor: Seagate model: FireCuda 530
    ZP2000GM30013 size: 1.82 TiB block-size: physical: 512 B logical: 512 B
    speed: 63.2 Gb/s lanes: 4 type: SSD serial: <filter> rev: SU6SM001
    temp: 33.9 C scheme: GPT
  SMART: yes health: PASSED on: 214d 14h cycles: 927
    read-units: 23,226,159 [11.8 TB] written-units: 22,766,766 [11.6 TB]
  ID-2: /dev/nvme1n1 maj-min: 259:1 vendor: Seagate model: FireCuda 530
    ZP2000GM30013 size: 1.82 TiB block-size: physical: 512 B logical: 512 B
    speed: 63.2 Gb/s lanes: 4 type: SSD serial: <filter> rev: SU6SM001
    temp: 25.9 C scheme: GPT
  SMART: yes health: PASSED on: 63d 1h cycles: 336
    read-units: 2,232,997 [1.14 TB] written-units: 5,436,948 [2.78 TB]
  ID-3: /dev/sda maj-min: 8:0 vendor: Samsung model: SSD 860 PRO 512GB
    family: based SSDs size: 476.94 GiB block-size: physical: 512 B
    logical: 512 B sata: 3.1 speed: 6.0 Gb/s type: SSD serial: <filter>
    rev: 1B6Q temp: 22 C scheme: GPT
  SMART: yes state: enabled health: PASSED on: 2y 178d 1h cycles: 3425
    written: 93.63 TiB
  ID-4: /dev/sdb maj-min: 8:16 vendor: Seagate model: ST16000NM001G-2KK103
    family: Exos X16 size: 14.55 TiB block-size: physical: 4096 B logical: 512 B
    sata: 3.3 speed: 6.0 Gb/s type: HDD rpm: 7200 serial: <filter> rev: SN03
    temp: 37 C scheme: GPT
  SMART: yes state: enabled health: PASSED on: 197d 3h cycles: 853
    read: 2.3 TiB written: 5.29 TiB Pre-Fail: attribute: Spin_Retry_Count
    value: 100 worst: 100 threshold: 97
Partition:
  ID-1: / raw-size: 97.66 GiB size: 95.56 GiB (97.86%) used: 47.27 GiB (49.5%)
    fs: ext4 block-size: 4096 B dev: /dev/nvme0n1p1 maj-min: 259:2
  ID-2: /boot/efi raw-size: 100 MiB size: 98.4 MiB (98.45%)
    used: 298 KiB (0.3%) fs: vfat block-size: 512 B dev: /dev/nvme0n1p3
    maj-min: 259:5
  ID-3: /home raw-size: 1.72 TiB size: 1.7 TiB (98.37%)
    used: 599.64 GiB (34.5%) fs: ext4 block-size: 4096 B dev: /dev/nvme0n1p2
    maj-min: 259:3
Swap:
  Alert: No swap data was found.
Sensors:
  System Temperatures: cpu: 49.5 C mobo: 36.0 C gpu: amdgpu temp: 50.0 C
    mem: 48.0 C
  Fan Speeds (RPM): fan-1: 0 fan-2: 766 fan-3: 0 fan-4: 0 fan-5: 0
    fan-6: 514 fan-7: 0 gpu: amdgpu fan: 0
Info:
  Processes: 543 Uptime: 14m wakeups: 1 Memory: 62.72 GiB
  used: 7.98 GiB (12.7%) Init: systemd v: 251 default: graphical
  tool: systemctl Compilers: gcc: 12.2.0 clang: 14.0.6 Packages: pm: pacman
  pkgs: 1624 libs: 434 tools: pamac Shell: Bash (sudo) v: 5.1.16
  running-in: konsole inxi: 3.3.23

There are some great examples in this manpage. Check them out:

man systemd-analyze

if I read all that correctly
you have 8 GB of RAM - but no swap whatsoever

add swap
add a swap file - it’s easy

swap is for backing up (non existent) RAM … kind of :wink:

Why would you have chosen to run without a swap file or a swap partition?
(it’s a rather rhetorical question - but the answer to it really seems to be affecting you)

some logs might also prove useful
journalctl … variants
google …

2 Likes

I got it, you are superior, thanks for letting me know!

Well, it is actually 64GB of RAM which will never be full, hence no swap - do you think adding a swap file would help? Because I had run this setup since like forever, and the slow shutdown started just a while ago, that’s why I am wondering…

I’m sorry - I misread the command output you provided
but even 64GB can get used up - with unpredictable consequences when there is no swap to back it up

What slows you down?
@zbe likely has good advice

I totally misread what you were asking. Check journalctl or shutdown messages to figure which service isn’t responding. What the actual fix is I don’t know - search online for that specific service. But you can edit timeout in /etc/systemd/system.conf. I think it’s DefaultTimeoutStopSec=

I just added swapfile, because as you say - it won’t hurt me. But posting just a “man whatever” without any further comment is never a good advice, period. It can be an okayish advice, but this is very rare. Same as “google it”. I don’t use google, but searched for quite a while, and found multiple hints like “something is slowing you down” or very specific tips - but nothing really usefull in how to improve my own analytic skills or anything that really helps to find a solution. This is why I made this topic.

We all need to read documentation. It’s already been written, so why would we need to spend time to rehash same thing every day, so someone else won’t have to? Imagine you are working in a store and people constantly ask you “How much does X cost?” because they don’t care to look at a price tag. Would be fun right? Well, at least you would get paid.

2 Likes

After the next long shutdown/reboot, on the next bootup do

journalctl -rb-1

to show you journal messages from the last boot (-b-1) in reverse (-r), i.e., with the final ones at the top. Ninety seconds is a standard systemd timeout indeed so you’ll likely see a service shutdown timing out.

With all due respect - reading documentation is no issue for me, and searching the net beforehand ain’t neither. But just dropping a “rtfm” is always absolutely rude. Giving one or two sentences TOTALLY changes the “sound” of the advice, does not hurt the advisor, helps more and does not sound like the one who posts the “rtfm” has a superiority complex. It is one of the ■■■■■■■■■ things in the whole linux community. It almost never helps as soon as the question is a little bit more complicated than “how do i copy a file” - which would be you example, for which a agree - but complexity is not defined by the answerer, but by the one qho asks the question. Please don’t give such an advice, thanks. And that is said on behalf of all nubs who search for help and searched by themselves beforehand! I will not comment that any further, because it ain’t helpfull.

This is something I already found in my search, but the outcome wan’t very productive in finding a solution, but I will do as adviced and report back, thank you!

Although it doesn’t apply to your problem (as I already noted I misread), I’ll go and add few sentences. (and feel less superior :stuck_out_tongue:)

1 Like

First if all, open ksystemlog and search for errors/warnings.

This behaviour has been the same since you installed Manjaro or the computer worked fine until some day? Can you see just before shutdown if there’s a process clogging the CPU?

You have shown zero respect for the volunteers who have attempted to help you. Please check your attitude. Be excellent to one another.

Please review the Forum Rules - Manjaro

1 Like