Aug 27 09:04:52 arch kernel: atkbd serio0: Failed to deactivate keyboard on isa0060/serio0Aug 27 09:04:52 zarch kernel: atkbd serio0: Failed to enable keyboard on isa0060/serio0
根据 Claude 以及互联网上相关的讨论,这个问题大概率跟内置键盘的驱动有关,通常可以通过尝试不同的 i8042/atkbd 相关参数来解决。
已经记不得从什么时候开始,我的 Linux 桌面偶尔会遇到无响应的问题,这个问题经常跟比较重的磁盘读写相关,例如更新 JetBrains IDE,JetBrains IDE 创建索引。之所以会把无响应的问题归结到磁盘读写上,是因为卡顿往往跟内存占用、CPU 使用率、进程数无关。卡顿的表现为:鼠标可以移动,但是 KDE 桌面包括状态栏无法更新;Kitty 可以创建新的 Tab,但是 Fish 启动会卡住;已有终端下虽然可以流畅输入命令,但是执行命令会卡住。这个周末因为成都一直在下雨,不太方便出门,决定来尝试解决卡顿问题。
我的电脑配置如下:
出现问题的固态硬盘型号是 KINGSTON SNVS1000G, SMART 信息如下:
# nvme smart-log /dev/nvme1Smart Log for NVME device:nvme1 namespace-id:ffffffffcritical_warning : 0temperature : 89 °F (305 K)available_spare : 100%available_spare_threshold : 10%percentage_used : 31%endurance group critical warning summary: 0Data Units Read : 61665672 (31.57 TB)Data Units Written : 171536497 (87.83 TB)host_read_commands : 967548759host_write_commands : 2052988968controller_busy_time : 75703power_cycles : 79989power_on_hours : 15798unsafe_shutdowns : 241media_errors : 0num_err_log_entries : 0Warning Temperature Time : 0Critical Composite Temperature Time : 0Thermal Management T1 Trans Count : 0Thermal Management T2 Trans Count : 0Thermal Management T1 Total Time : 0Thermal Management T2 Total Time : 0
然而在调度器的选择上,Gemini 跟 Arch Wiki 出现了分歧,Gemini 认为 NVME 以及 SSD 就应该选择 none 作为 io scheduler,但 Arch Wiki 认为 it depends:
The best choice of scheduler depends on both the device and the exact nature of the workload. Also, the throughput in MB/s is not the only measure of performance: deadline or fairness deteriorate the overall throughput but may improve system responsiveness. Benchmarking may be useful to indicate each I/O scheduler performance.
List all captured core dumps:coredumpctlList captured core dumps for a program:coredumpctl list programShow information about the core dumps matching a program with `PID`:coredumpctl info PIDInvoke debugger using the last core dump:coredumpctl debugInvoke debugger using the last core dump of a program:coredumpctl debug programExtract the last core dump of a program to a file:coredumpctl --output path/to/file dump programSkip debuginfod and pagination prompts and then print the backtrace when using `gdb`:coredumpctl debug --debugger-arguments "-iex 'set debuginfod enabled on' -iex 'set pagination off' -ex bt"
下面的这份 CMake 文件是我跟 Claude 一起编写的,不一定能够通过 IDE 编译 node addon,但是可以提供智能补全。
cmake_minimum_required(VERSION 3.10)project(duckdb_node_neo)set(CMAKE_CXX_STANDARD 17)# include node headersinclude_directories(/usr/include/node)# Node.js addon API headersinclude_directories(${CMAKE_SOURCE_DIR}/bindings/node_modules/node-addon-api)# DuckDB headersinclude_directories(${CMAKE_SOURCE_DIR}/bindings/libduckdb)# Add source filesfile(GLOB SOURCE_FILES"bindings/src/*.cpp")# This is just for CLion's code intelligence - not for actual buildingadd_library(duckdb_node_bindings SHARED ${SOURCE_FILES})# Define preprocessor macros used in the codeadd_definitions(-DNODE_ADDON_API_DISABLE_DEPRECATED)add_definitions(-DNODE_ADDON_API_REQUIRE_BASIC_FINALIZERS)add_definitions(-DNODE_API_NO_EXTERNAL_BUFFERS_ALLOWED)# Add Node.js specific definitions to help CLion's IntelliSenseadd_definitions(-DNAPI_VERSION=8)# Tell CLion to treat this as a Node.js addon projectset_target_properties(duckdb_node_bindings PROPERTIES CXX_STANDARD 17 PREFIX "" SUFFIX ".node")
生成带有 symbol 的二进制
设置后 debugger 后,还需要提供一个 symbol 文件,帮助 debugger 定位代码位置。对于 node-gyp 而言,只需要在编译时设置 --debug 参数即可生成带有 symbol 的二进制。
首先安装 amd-debug-tools,运行 amd-s2idle test ,查看当前系统是否满足 s2idle 的要求:
$ amd-s2idle test💻 AMD Ryzen AI 9 H 365 w/ Radeon 880M (family 1a model 24)💻 MECHREVO WUJIE Series (STX\KRK)🐧 Arch Linux🐧 Kernel 6.12.32-1-lts🔋 Battery BAT0 (OEM standard) is operating at 100.00% of design✅ ASPM policy set to 'default'✅ GPIO driver `pinctrl_amd` available✅ PMC driver `amd_pmc` loaded (Program 11 Firmware 93.4.0)✅ USB3 driver `xhci_hcd` bound to 0000:65:00.4, 0000:67:00.0, 0000:67:00.3, 0000:67:00.4✅ USB4 driver `thunderbolt` bound to 0000:67:00.6✅ System is configured for s2idle✅ GPU driver `amdgpu` bound to 0000:65:00.0✅ PC6 and CC6 enabled✅ SMT enabled✅ IOMMU properly configured✅ ACPI FADT supports Low-power S0 idle🚦 Logs are provided via dmesg, timestamps may not be accurate over multiple cycles✅ LPS0 _DSM enabled✅ WLAN driver `mt7921e` bound to 0000:62:00.0❌ Kernel is tainted: 12288💯 Your system does not meet s2idle prerequisites!🗣️ Explanations for your system🚦 Kernel is taintedA tainted kernel may exhibit unpredictable bugs that are difficult for this script to characterize. If this is intended behavior run the tool with --force. For more information on this failure see:https://gitlab.freedesktop.org/drm/amd/-/issues/3089
# Enable verbose PM debuggingecho 1 | sudo tee /sys/power/pm_print_times<br>echo 1 | sudo tee /sys/power/pm_debug_messages# Now try to suspend againsystemctl suspend# Check dmesg after resumedmesg | grep -i "wake\|resume\|acpi"
再次执行 systemctl suspend 复现问题后,可以在 dmesg 中看到下面的日志:
[ 4636.873132] xhci_hcd 0000:67:00.4: PM: pci_pm_suspend_noirq returned 0 after 42252 usecs [ 4636.873146] thunderbolt 0000:67:00.6: PM: pci_pm_suspend_noirq returned 0 after 42269 usecs [ 4636.873169] pcieport 0000:00:08.3: PM: calling pci_pm_suspend_noirq @ 29723, parent: pci0000:00 [ 4636.878632] pcieport 0000:00:02.1: PM: pci_pm_suspend_noirq returned 0 after 10561 usecs [ 4636.878653] pcieport 0000:00:03.2: PM: pci_pm_suspend_noirq returned 0 after 11025 usecs [ 4636.885192] pcieport 0000:00:08.1: PM: pci_pm_suspend_noirq returned 0 after 12279 usecs [ 4636.885300] pcieport 0000:00:08.3: PM: pci_pm_suspend_noirq returned 0 after 12119 usecs [ 4636.885359] PM: noirq suspend of devices complete after 54.690 msecs [ 4636.885376] ACPI: _SB_.PCI0.GPP5: LPI: Constraint not met; min power state:D1 current power state:D0 [ 4636.885381] ACPI: _SB_.PCI0.GPP6: LPI: Constraint not met; min power state:D1 current power state:D0 [ 4636.885388] ACPI: _SB_.PCI0.GPP4.SDCR: LPI: Constraint not met; min power state:D3hot current power state:D0 [ 4636.886012] PM: Triggering wakeup from IRQ 9 [ 4636.886504] ACPI: _SB_.PEP_: Successfully transitioned to state screen off [ 4636.887420] ACPI: _SB_.PEP_: Successfully transitioned to state lps0 ms entry [ 4636.887625] ACPI: _SB_.PEP_: Successfully transitioned to state lps0 entry [ 4636.888555] PM: suspend-to-idle [ 4636.888592] ACPI: EC: ACPI EC GPE status set [ 4636.888623] ACPI: PM: Rearming ACPI SCI for wakeup [ 4636.891279] PM: Triggering wakeup from IRQ 1 [ 4639.593124] amd_pmc: SMU idlemask s0i3: 0xffff1abd [ 4639.593188] ACPI: PM: Wakeup unrelated to ACPI SCI [ 4639.593189] PM: resume from suspend-to-idle [ 4639.594699] amd_pmc AMDI000A:00: Last suspend didn't reach deepest state [ 4639.595185] ACPI: _SB_.PEP_: Successfully transitioned to state lps0 exit [ 4639.595760] PM: Triggering wakeup from IRQ 9 [ 4639.596746] ACPI: _SB_.PEP_: Successfully transitioned to state lps0 ms exit [ 4639.597719] ACPI BIOS Error (bug): Could not resolve symbol [_SB.ACDC.RTAC], AE_NOT_FOUND (20240827/psargs-332) [ 4639.597729] ACPI Error: Aborting method _SB.PEP._DSM due to previous error (AE_NOT_FOUND) (20240827/psparse-529) [ 4639.597737] ACPI: _SB_.PEP_: Failed to transitioned to state screen on
Deepseek 大胆推断是 IRQ 1 (typically the i8042 keyboard controller) 造成的问题,可以通过下面的方法来验证:
echo"disabled" | sudo tee /sys/devices/platform/i8042/serio0/power/wakeup