Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 361847 - net-print/hplip-3.11* - backend "hp" eat 100% cpu with a lot of ioctl
Summary: net-print/hplip-3.11* - backend "hp" eat 100% cpu with a lot of ioctl
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: Daniel Pielmeier
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-03 23:06 UTC by Maxim Britov
Modified: 2012-01-25 18:53 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge --info (emerge-info.txt,6.16 KB, text/plain)
2011-04-04 21:00 UTC, Maxim Britov
Details
patch by Daniel Gnoutcheff (hplip-fast-pp.patch,21.26 KB, patch)
2012-01-24 22:42 UTC, Andreas K. Hüttel
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Maxim Britov 2011-04-03 23:06:19 UTC
I have hplj1100 and check net-print/hplip-3.11.1/3a
When I print some I have 100% cpu usage.
strace show a lot of:
...
ioctl(6, PPFCONTROL, 0x7fff72b78cd0)    = 0
ioctl(6, PPRSTATUS, 0x7fff72b78c80)     = 0
ioctl(6, PPFCONTROL, 0x7fff72b78cd0)    = 0
ioctl(6, PPRSTATUS, 0x7fff72b78c80)     = 0
ioctl(6, PPWDATA, 0x7fff72b78cff)       = 0
ioctl(6, PPFCONTROL, 0x7fff72b78cd0)    = 0
...

$ wc -l delme/hp.trace.log 
7519734 delme/hp.trace.log
$ fgrep -v ioctl delme/hp.trace.log|wc -l
193

I believe it's a bug.

Reproducible: Always
Comment 1 Maxim Britov 2011-04-03 23:38:08 UTC
Found two "while (1)" in hplip-3.11.3a/io/hpmud/pp.c with ioctl inside for parallel port. I believe it too fast for lpt.
Comment 2 Jeroen Roovers (RETIRED) gentoo-dev 2011-04-04 11:40:57 UTC
Please post your `emerge --info' too.
Comment 3 Maxim Britov 2011-04-04 21:00:46 UTC
Created attachment 268517 [details]
emerge --info
Comment 4 Daniel Pielmeier gentoo-dev 2011-04-04 21:17:55 UTC
I don't own a parallel port printer but you can try patching io/hpmud/pp.c by setting higher values for the while loops and test if this fixes the problem.

This is no ebuild problem and I can not fix it so I would like to ask if you can open a bug upstream at https://bugs.launchpad.net/hplip and report the bug number here.
Comment 5 Maxim Britov 2011-04-04 22:03:26 UTC
https://bugs.launchpad.net/hplip/+bug/750796
Comment 6 Andreas K. Hüttel archtester gentoo-dev 2012-01-24 22:42:07 UTC
Created attachment 299791 [details, diff]
patch by Daniel Gnoutcheff

From the upstream bug:

-----------------------------

Daniel Gnoutcheff (gnoutchd) wrote on 2011-07-14: 	#15

    hplip-fast-pp.patch (21.3 KiB, text/plain)

The parallel port code is quite CPU intensive. That, I think, is what we're seeing here. On my (admittedly rather old) system, the CPU is the bottleneck for parallel port I/O, and it's a very severe bottleneck indeed. Trying to scan something with an OfficeJet R80 takes so long that it is unusable.

The problem is that, for reasons that aren't clear to me, HPLIP implements ECP in userspace via ppdev ioctls. Because of this, we make something like 5-10 system calls for every byte sent over the wire. That's a staggeringly huge overhead, and I don't think it's necessary. The Linux parallel port subsystem already has IEEE1284 support, and since that code lives in kernel space, it avoids the huge syscall overhead. ppdev allows us to use this code via the usual read/write functions.

I've attached a patch that makes hplip use ppdev reads and writes. I've successfully tested this against the aforementioned OfficeJet, and it massively reduces CPU usage (and dramatically improves scan speed). As a nice side-effect, the code is shortened by 389 lines.

I've seen some comments suggesting that ppdev read and writes are less reliable than what we do now. Having looked at the source code of the Linux parallel port subsystem, I'm not sure how this could be the case. By default, the parport code implements ECP via software emulation, just like hplip does now. Indeed, The code does include some support for hardware acceleration, but on PC's at least, this support is disabled by default.
Comment 7 Daniel Pielmeier gentoo-dev 2012-01-25 18:53:48 UTC
+*hplip-3.11.12-r2 (25 Jan 2012)
+
+  25 Jan 2012; Daniel Pielmeier <billie@gentoo.org> +hplip-3.11.12-r2.ebuild,
+  +files/hplip-3.11.12-fast-pp.patch:
+  Fix bug #361847. Thanks to ungift-ed for the report, Daniel Gnoutcheff for
+  the patch provided at the upstream bug and Andreas K. Hüttel for reminding
+  me about the patch.