Bug 407191

Summary: Video playback stops and mouse cursor is laggy while partition manager creates and formats partitions
Product: [Applications] partitionmanager Reporter: Matej Mrenica <matejm98mthw>
Component: generalAssignee: Andrius Štikonas <andrius>
Status: RESOLVED FIXED    
Severity: normal CC: matejm98mthw
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=413973
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Log

Description Matej Mrenica 2019-05-03 19:04:03 UTC
STEPS TO REPRODUCE
1. Open a youtube video in browser
2. Make Partitionmanager create and format a partition (on a USB drive or somewhere else, shouldn't matter)

OBSERVED RESULT
While the operation is being done, video playback including sound stops and the whole system becomes so unresponsive that the mouse cursor barely moves. When the operation is done everything works 100% again.

EXPECTED RESULT
Partition operations don't affect the rest of the system.

SOFTWARE/OS VERSIONS
Partition manager 4.0.0
KDE Plasma Version: 5.15.4
KDE Frameworks Version: 5.57
Qt Version: 5.13.0beta1
Comment 1 Andrius Štikonas 2019-05-03 20:36:34 UTC
Did you notice anything else unusual? E.g. CPU usage went up to 100% or maybe system started swapping. 

I never observed anything like that and nobody else reported this. As it stands, I'm not even sure where to start with this bug.

You might want to try running some of the same commands that partition manager runs to see if any of them cause slowdowns (if you start partitionmanager from terminal with "KPMCORE_DEBUG=1 partitionmanager" it will print list of commands that it is running), although, a few commands require input which is not printed.
Comment 2 Matej Mrenica 2019-05-04 07:52:49 UTC
Yes, CPU usage went to 100% for a while but the most "demanding" processes (acording to htop) were: Xorg, Upowerd, Plasmashell and kglobalaccel5.

On my second try I used Plasma wayland, and the mouse movement was fixed also my youtube video playback didn't stop nor did it drop a lot of frames (it would drop almost all the frames on Xorg). The only process using noticably more cpu was Upowerd.
Comment 3 Matej Mrenica 2019-05-04 08:41:58 UTC
Log from "KPMCORE_DEBUG=1 partitionmanager":
...
"Applying operations..."
Command input: "label: gpt\nwrite\n"
"Command: sfdisk /dev/sdb"
"Command: udevadm settle --timeout=10"
"Command: blockdev --rereadpt /dev/sdb"
"Command: udevadm trigger"
Command input: "start=2048 size=61462528\nwrite\n"
"Command: sfdisk --force --append /dev/sdb"
"Command: udevadm settle --timeout=10"
"Command: blockdev --rereadpt /dev/sdb"
"Command: udevadm trigger"
"Command: udevadm settle --timeout=10"
"Command: blockdev --rereadpt /dev/sdb"
"Command: udevadm trigger"
"Command: mkfs.fat -F32 -I -v /dev/sdb1"
"Command: sfdisk --part-type /dev/sdb 1 EBD0A0A2-B9E5-4433-87C0-68B6B72699C7"
"Command: udevadm settle --timeout=10"
"Command: blockdev --rereadpt /dev/sdb"
"Command: udevadm trigger"
"Command: udevadm settle --timeout=10"
"Command: blockdev --rereadpt /dev/sdb"
"Command: udevadm trigger"
"Command: fatlabel /dev/sdb1 MTHW"
"Command: udevadm settle --timeout=10"
"Command: blockdev --rereadpt "
"Command: udevadm trigger"
"Command: udevadm settle --timeout=10"
"Command: blockdev --rereadpt "
"Command: udevadm trigger"
"Command: fsck.fat -a -w -v /dev/sdb1"
"Using backend plugin: pmsfdiskbackendplugin (1)"
"Scanning devices..."
...
Comment 4 Andrius Štikonas 2019-05-04 08:48:49 UTC
Try running some of these commands manually to see if anything triggers high CPU usage.

Maybe udevadm triggers it?
Comment 5 Matej Mrenica 2019-05-04 09:15:43 UTC
(In reply to Andrius Štikonas from comment #4)
> Try running some of these commands manually to see if anything triggers high
> CPU usage.
> 
> Maybe udevadm triggers it?

Yes it seems to be caused by "udevadm trigger"
Comment 6 Andrius Štikonas 2019-05-04 09:34:52 UTC
Ok, so that's not partition manager bug.

Something else is broken on your system and triggering udev rules triggers CPU usage. This should not happen.

Hmm, maybe you can figure out what is wrong by enabling udev debugging.

https://wiki.archlinux.org/index.php/udev#Debug_output

Hmm, maybe open Arch bug that "udevadm trigger" causes this?
Comment 7 Matej Mrenica 2019-05-04 10:12:19 UTC
Created attachment 119836 [details]
Log

I opened a bug on Arch bugtracker: https://bugs.archlinux.org/task/62543
I also attached a log there from "journalctl -xb | grep udev" using "udev.log-priority=debug" boot parameter. The log is more than 5000 lines and I don't know what to look for, maybe you could also look at it?
Comment 8 Andrius Štikonas 2019-05-04 10:35:10 UTC
Yes, I'll take a look at it too.

I'll close this bug in the meantime as it's not something I can fix in partition manager. But you can still comment here.
Comment 9 Andrius Štikonas 2019-05-04 10:47:06 UTC
You can also try some Live CDs to see if you can reproduce it there.
Comment 10 Andrius Štikonas 2019-11-22 20:42:58 UTC
(In reply to Andrius Štikonas from comment #8)
> Yes, I'll take a look at it too.
> 
> I'll close this bug in the meantime as it's not something I can fix in
> partition manager. But you can still comment here.

I might try to do some workaround in partition manager for this. There might be an option to only trigger udev events for certain subsystem, instead of the whole system.
Comment 11 Andrius Štikonas 2019-12-02 22:03:03 UTC
Workaround added to git.