Bug 494459

Summary: kwin_wayland 6.2.0 Consumes All CPU Resources
Product: [Plasma] kwin Reporter: erdrick016
Component: wayland-genericAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED DUPLICATE    
Severity: major CC: frmdstryr, kdedev, nate, xaver.hugl
Priority: NOR Keywords: regression
Version: 6.2.0   
Target Milestone: ---   
Platform: Neon   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: htop At System Idle
Hotspot - Bottom Up View

Description erdrick016 2024-10-10 15:43:47 UTC
Created attachment 174636 [details]
htop At System Idle

SUMMARY
After upgrading Plasma from 6.1.5 -> 6.2, it became unusable as kwin_wayland is consuming all my CPU. I'm running a VM (under QEMU) with 4x CPUs allocated to it and it was fine before the upgrade, now Wayland is unusable but X11 is fine.


STEPS TO REPRODUCE
1. Login to a Wayland session.

OBSERVED RESULT
See attachment but kwin_wayland is consuming all my CPU resources, yielding the system nigh unusable.

EXPECTED RESULT
kwin_wayland would consume some small percentage of CPU.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: KDE neon 6.2
KDE Plasma Version: 6.2.0
KDE Frameworks Version: 6.6.0
Qt Version: 6.7.2

ADDITIONAL INFORMATION
Processors: 4 × 12th Gen Intel® Core™ i9-12900HK
Memory: 7.6 GiB of RAM
Graphics Processor: llvmpipe
Manufacturer: QEMU
Product Name: Standard PC (Q35 + ICH9, 2009)
System Version: pc-q35-7.1
Comment 1 Vlad Zahorodnii 2024-10-10 15:46:07 UTC
Can you run perf to record some perf data?

  sudo perf record --call-graph dwarf -p $(pidof kwin_wayland)

and then open the dump file in hotspot

At quick glance, it looks like kwin uses the software renderer
Comment 2 TraceyC 2024-10-10 19:56:43 UTC
kwin_wayland is taking up to 200% CPU on a VM, before and after a dist upgrade to 24.04. It started after Plasma updated to 6.2

Here's the output of perf

llvmpipe-0    1405  1418.543079:          1 cycles:P: 
	ffffffff88ac4b06 [unknown] ([kernel.kallsyms])
	ffffffff88a1a3d5 [unknown] ([kernel.kallsyms])
	ffffffff88a0e026 [unknown] ([kernel.kallsyms])
	ffffffff88d9658e [unknown] ([kernel.kallsyms])
	ffffffff88d9f610 [unknown] ([kernel.kallsyms])
	ffffffff88b50dbf [unknown] ([kernel.kallsyms])
	ffffffff89c3ca64 [unknown] ([kernel.kallsyms])
	ffffffff89c3ced3 [unknown] ([kernel.kallsyms])
	ffffffff89c2d025 [unknown] ([kernel.kallsyms])
	ffffffff89c2d0b3 [unknown] ([kernel.kallsyms])
	ffffffff89c2b83b [unknown] ([kernel.kallsyms])
	ffffffff89e00f4b [unknown] ([kernel.kallsyms])
	    7cb3cbe80f4d [unknown] (/tmp/perf-1354.map)

llvmpipe-0    1405  1418.543130:       1600 cycles:P: 
	ffffffff89ba178b [unknown] ([kernel.kallsyms])
	ffffffff88c0594d [unknown] ([kernel.kallsyms])
	ffffffff88c06362 [unknown] ([kernel.kallsyms])
	ffffffff88c072b6 [unknown] ([kernel.kallsyms])
	ffffffff88aa96ee [unknown] ([kernel.kallsyms])
	ffffffff89c2b87d [unknown] ([kernel.kallsyms])
	ffffffff89e00f4b [unknown] ([kernel.kallsyms])
	ffffffff88b50c59 [unknown] ([kernel.kallsyms])
	ffffffff89c3ca64 [unknown] ([kernel.kallsyms])
	ffffffff89c3ced3 [unknown] ([kernel.kallsyms])
	ffffffff89c2d025 [unknown] ([kernel.kallsyms])
	ffffffff89c2d0b3 [unknown] ([kernel.kallsyms])
	ffffffff89c2b83b [unknown] ([kernel.kallsyms])
	ffffffff89e00f4b [unknown] ([kernel.kallsyms])
	    7cb3cbe80f4d [unknown] (/tmp/perf-1354.map)

llvmpipe-1    1406  1418.543384:          1 cycles:P: 
	ffffffff88ac4b06 [unknown] ([kernel.kallsyms])
	ffffffff88a1a3d5 [unknown] ([kernel.kallsyms])
	ffffffff88a0e026 [unknown] ([kernel.kallsyms])
	ffffffff88d9658e [unknown] ([kernel.kallsyms])
	ffffffff88d9f610 [unknown] ([kernel.kallsyms])
	ffffffff88b50dbf [unknown] ([kernel.kallsyms])
	ffffffff89c3ca64 [unknown] ([kernel.kallsyms])
	ffffffff89c3ced3 [unknown] ([kernel.kallsyms])
	ffffffff89c2d025 [unknown] ([kernel.kallsyms])
	ffffffff89c2d0b3 [unknown] ([kernel.kallsyms])
	ffffffff89c2b579 [unknown] ([kernel.kallsyms])
	ffffffff89e00f8b [unknown] ([kernel.kallsyms])
	    7cb3cbe7ff20 [unknown] (/tmp/perf-1354.map)

llvmpipe-1    1406  1418.543944:      58021 cycles:P: 
	    7cb3cbe7fdfd [unknown] (/tmp/perf-1354.map)

llvmpipe-1    1406  1418.543981:      55083 cycles:P: 
	    7cb3cbe7fdeb [unknown] (/tmp/perf-1354.map)

llvmpipe-1    1406  1418.544024:     108871 cycles:P: 
	    7cb3cbe7f621 [unknown] (/tmp/perf-1354.map)

llvmpipe-0    1405  1418.544156:      88794 cycles:P: 
	    7cb3cbe7ce0a [unknown] (/tmp/perf-1354.map)

llvmpipe-0    1405  1418.544209:      81305 cycles:P: 
	    7cb3cbe7d7a4 [unknown] (/tmp/perf-1354.map)

llvmpipe-0    1405  1418.544250:     134360 cycles:P: 
	    7cb3cbe80334 [unknown] (/tmp/perf-1354.map)

llvmpipe-0    1405  1418.544316:     253553 cycles:P: 
	    7cb3cbe801dd [unknown] (/tmp/perf-1354.map)

llvmpipe-0    1405  1418.545041:     352165 cycles:P: 
	    7cb3cbe7c862 [unknown] (/tmp/perf-1354.map)

llvmpipe-1    1406  1418.545107:     201841 cycles:P: 
	    7cb3cbe7d537 [unknown] (/tmp/perf-1354.map)

llvmpipe-0    1405  1418.545183:     328382 cycles:P: 
	    7cb3cbe7fe3a [unknown] (/tmp/perf-1354.map)

llvmpipe-1    1406  1418.545197:     184382 cycles:P: 
	    7cb3cbe7e9f5 [unknown] (/tmp/perf-1354.map)

llvmpipe-1    1406  1418.545280:     246407 cycles:P: 
	    7cb3cbe7d7a4 [unknown] (/tmp/perf-1354.map)

llvmpipe-0    1405  1418.545317:     383286 cycles:P: 
	    7cb3cbe7fd23 [unknown] (/tmp/perf-1354.map)

llvmpipe-1    1406  1418.545384:     339701 cycles:P: 
	    7cb3cbe7c9e6 [unknown] (/tmp/perf-1354.map)

llvmpipe-0    1405  1418.545471:     454590 cycles:P: 
	    7cb3cbe7f697 [unknown] (/tmp/perf-1354.map)

llvmpipe-1    1406  1418.546048:     416213 cycles:P: 
	    7cb3cbe7e5a1 [unknown] (/tmp/perf-1354.map)

llvmpipe-0    1405  1418.546086:     510665 cycles:P: 
	    7cb3cbe7f060 [unknown] (/tmp/perf-1354.map)

llvmpipe-1    1406  1418.546213:     390340 cycles:P: 
	    7cb3cbe7f663 [unknown] (/tmp/perf-1354.map)

llvmpipe-0    1405  1418.546286:     481423 cycles:P: 
	    7cb3cbe7e423 [unknown] (/tmp/perf-1354.map)

llvmpipe-1    1406  1418.546370:     439702 cycles:P: 
	    7cb3cbe8018c [unknown] (/tmp/perf-1354.map)

llvmpipe-0    1405  1418.546475:     521880 cycles:P: 
	    7cb3cbe7dfa7 [unknown] (/tmp/perf-1354.map)

llvmpipe-1    1406  1418.546544:     501851 cycles:P: 
	    7cb3cbe7e8a5 [unknown] (/tmp/perf-1354.map)

llvmpipe-0    1405  1418.546679:     571722 cycles:P: 
	    7cb3cbe7fe8c [unknown] (/tmp/perf-1354.map)

llvmpipe-1    1406  1418.547105:     555383 cycles:P: 
	    7cb3cbe80a8e [unknown] (/tmp/perf-1354.map)

llvmpipe-0    1405  1418.547147:     621911 cycles:P: 
	    7cb3cbe80244 [unknown] (/tmp/perf-1354.map)

llvmpipe-1    1406  1418.547324:     527185 cycles:P: 
	    7cb3cbe7e47c [unknown] (/tmp/perf-1354.map)

llvmpipe-0    1405  1418.547387:     599467 cycles:P: 
	    7cb3cbe80a94 [unknown] (/tmp/perf-1354.map)

llvmpipe-1    1406  1418.547535:     561513 cycles:P: 
	    7cb3cbe7e47c [unknown] (/tmp/perf-1354.map)

llvmpipe-0    1405  1418.547619:     628699 cycles:P: 
	    7cb3cbe7e40b [unknown] (/tmp/perf-1354.map)

llvmpipe-1    1406  1418.547756:     602575 cycles:P: 
	    7cb3cbe7fd05 [unknown] (/tmp/perf-1354.map)

llvmpipe-0    1405  1418.547862:     663275 cycles:P: 
	    7cb3cbe80a2d [unknown] (/tmp/perf-1354.map)

llvmpipe-1    1406  1418.548141:     650061 cycles:P: 
	    7cb3cbe7fa9f [unknown] (/tmp/perf-1354.map)

llvmpipe-0    1405  1418.548171:     708140 cycles:P: 
	    7cb3cbe7fdeb [unknown] (/tmp/perf-1354.map)

llvmpipe-1    1406  1418.548394:     639110 cycles:P: 
	    7cb3cbe7fcee [unknown] (/tmp/perf-1354.map)

llvmpipe-0    1405  1418.548445:     715168 cycles:P: 
	    7cb3cbe7d8de [unknown] (/tmp/perf-1354.map)

llvmpipe-1    1406  1418.548644:     664642 cycles:P: 
	    7cb3cbe801dd [unknown] (/tmp/perf-1354.map)

llvmpipe-0    1405  1418.548721:     734632 cycles:P: 
	    7cb3cbe7e295 [unknown] (/tmp/perf-1354.map)

llvmpipe-1    1406  1418.548907:     692295 cycles:P: 
	    7cb3cbe7c8ec [unknown] (/tmp/perf-1354.map)

llvmpipe-0    1405  1418.549021:     766722 cycles:P: 
	    7cb3cbe7ee22 [unknown] (/tmp/perf-1354.map)

llvmpipe-1    1406  1418.549198:     732591 cycles:P: 
	    7cb3cbe7e444 [unknown] (/tmp/perf-1354.map)

llvmpipe-0    1405  1418.549316:     777309 cycles:P: 
	    7cb3cbe7ee2e [unknown] (/tmp/perf-1354.map)

llvmpipe-1    1406  1418.549486:     745955 cycles:P: 
	    7cb3cbe7ebaa [unknown] (/tmp/perf-1354.map)

llvmpipe-0    1405  1418.549615:     789995 cycles:P: 
	    7cb3cbe7e3dd [unknown] (/tmp/perf-1354.map)

llvmpipe-1    1406  1418.549772:     760740 cycles:P: 
	    7cb3cbe8019c [unknown] (/tmp/perf-1354.map)

llvmpipe-0    1405  1418.549927:     807776 cycles:P: 
	    7cb3cbe7e7e5 [unknown] (/tmp/perf-1354.map)

llvmpipe-1    1406  1418.550085:     783640 cycles:P: 
	    7cb3cbe7dc61 [unknown] (/tmp/perf-1354.map)

llvmpipe-0    1405  1418.550239:     814474 cycles:P:
Comment 3 erdrick016 2024-10-10 20:46:56 UTC
Created attachment 174653 [details]
Hotspot - Bottom Up View

Here's my perf data as requested. LMK if it would be helpful for me to install debug symbols or something, or maybe you need a different view in Hotspot?
Comment 4 erdrick016 2024-10-10 21:03:05 UTC
Small data point: I upgraded from Neon 22.04 (Kernel: 6.8.0-40-generic) -> Neon 24.04 (Kernel: 6.8.0-45-generic) and things became slightly better. On 22.04, my 4x CPUs were pegged at 100%, all the time. Now, on 24.04, when nothing is changing on screen at all, they settle down to something akin to background noise. But even just simply typing this comment out makes my CPU usage jump all over the place.
Comment 5 frmdstryr 2024-10-12 14:04:27 UTC
Perhaps this is due to https://bugs.kde.org/493940  ? Looking at the commit for that, shouldn't the new timer also be stopped if a repaint is pending (eg after the if at line 251)?
Comment 6 Zamundaaa 2024-10-16 17:48:19 UTC

*** This bug has been marked as a duplicate of bug 493295 ***