# high CPU load from X with intel graphics

## jyoung

Hi Folks,

I'm running XFCE on a machine with intel graphics, and I'm getting a fairly high cpu load on X, usually 15-20%. I also sometimes get a high cpu load from xfwm4, which XFCE forums suggest is an issue with the graphics driver.

I've been working from this wiki

wiki.gentoo.org/wiki/Intel

But no luck so far. Any thoughts?

----------

## NeddySeagoon

jyoung,

Please post your 

```
lspci -nnk
```

so thot we can see your hardware.

Put your /var/log/Xorg.0.log onto a pastebin site, so we can see what Xorg does when it starts.

Put your dmesg output onto a pastebin, so we can check for missing firmware, among other things.

Lastly, you kernel .config on a pastebin would be good in case you need to change it.

----------

## jyoung

I've posted those items. The one weird thing I'm seeing is in Xorg.0.log, an error which is repeated too many times for pastebin which says 

```

[    76.313] (EE) modeset(0): Failed to get GBM bo for flip to new front.

[    76.313] (EE) modeset(0): present flip failed

```

dmesg output

www.pastebin.com/U8kBtAiQ

/var/log/Xorg.0.log

www.pastebin.com/CDBLNS4i

lspci -nnk

www.pastebin.com/br6SZNTv

/usr/src/linux/.config

www.pastebin.com/KiwEwZDj

----------

## mike155

The lines below in dmesg look suspicious:

```
[    1.013449] i915 0000:00:02.0: Direct firmware load for i915/kbl_dmc_ver1_04.bin failed with error -2

[    1.013452] i915 0000:00:02.0: Failed to load DMC firmware i915/kbl_dmc_ver1_04.bin. Disabling runtime power management.

[    1.014181] [drm] Reducing the compressed framebuffer size. This may lead to less power savings than a non-reduced-size. Try to increase stolen memory size if available in BIOS.
```

----------

## Banana

have a look here: https://wiki.gentoo.org/wiki/Intel#Firmware

There is a section which show an error like the one in the dmesg about the failed bin to load

----------

## NeddySeagoon

jyoung,

This is your system mounting root read only. That's fine. Its the timestamp that is of interest.

```
[    4.548500] EXT2-fs (sda7): error: couldn't mount because of unsupported optional features (2c0)

[    4.552710] EXT4-fs (sda7): mounted filesystem with ordered data mode. Opts: (null)
```

Earlier it tries to load firmware.

```
[    1.013449] i915 0000:00:02.0: Direct firmware load for i915/kbl_dmc_ver1_04.bin failed with error -2

[    1.013452] i915 0000:00:02.0: Failed to load DMC firmware i915/kbl_dmc_ver1_04.bin. Disabling runtime power management.
```

As that firmware load is before root is mounted it fails unless its built into the kernel. More on that later.

It appears that you don't have the WiFi regulatory datbase installed.

```
[    8.897658] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2

[    8.897660] cfg80211: failed to load regulatory.db
```

as that is after root is mounted, it suggests that you don't have linux-firmware installed.

You are using i915drmfb for your console driver. 

```
[    1.105752] Console: switching to colour frame buffer device 320x90

[    1.123740] i915 0000:00:02.0: fb0: i915drmfb frame buffer device
```

Thats good. It suggests that your kernel is correct in the drm department.

Firmware is not required for that.

Xorg goes straight to the modeset video driver. The log is missing the list of preferred drivers that the auto detect produces.

The intel driver is normally top of the list with modeset second.

modeset relies on 

```
[    73.573] (**) modeset(0): Option "AccelMethod" "glamor"
```

for any acceleration. 

That Option keyword says its in a configuration file somewhere.

This Red Hat Bug suggests using

```
Option "PageFlip" off
```

but that will be ugly.

Normally, Xorg draws in one pixel buffer while another is being read to to the display. A "PageFlip" occurs in the blank time between frames.

The buffers are swapped then so there are no visual artefacts.

WIth PageFlip off, Xorg draws in the buffer on display. You will see 'tearing'.

lspci looks mostly harmless.

```
00:14.2 Signal processing controller [1180]: Intel Corporation 200 Series PCH Thermal Subsystem [8086:a2b1]

    Subsystem: Dell 200 Series PCH Thermal Subsystem [1028:07a3]

00:16.0 Communication controller [0780]: Intel Corporation 200 Series PCH CSME HECI #1 [8086:a2ba]

    Subsystem: Dell 200 Series PCH CSME HECI [1028:07a3]
```

These devices should have kernel drivers.

Looking at your kernel, the path names of built in firmware go in  

```
CONFIG_EXTRA_FIRMWARE=""
```

When you edit that field with make menuconfig, a new entry will become visible.

Its all on the Wiki

You will need linux-firmware to provide the firmware before you build it into the kernel.

```
# CONFIG_INTEL_PCH_THERMAL is not set
```

is needed for 

```
00:14.2 Signal processing controller [1180]: Intel Corporation 200 Series PCH Thermal Subsystem [8086:a2b1]
```

I can't find the other kernel option.

----------

## jyoung

linux-firmware was installed a while ago, but I'd missed the firmware lines .config

```
CONFIG_EXTRA_FIRMWARE="i915/skl_dmc_ver1_27.bin"

CONFIG_EXTRA_FIRMWARE_DIR="/lib/firmware"
```

And intel thermal:

```
CONFIG_INTEL_PCH_THERMAL=y
```

But I'm still getting some issues with loading the firmware:

```
[    1.013182] i915 0000:00:02.0: Direct firmware load for i915/kbl_dmc_ver1_04.bin failed with error -2

[    1.013185] i915 0000:00:02.0: Failed to load DMC firmware i915/kbl_dmc_ver1_04.bin. Disabling runtime power management.
```

And the cpu load from X is still very high.

----------

## NeddySeagoon

jyoung,

```
i915/kbl_dmc_ver1_04.bin
```

is in my /lib/firmware.

Its missing from your kernel 

```
CONFIG_EXTRA_FIRMWARE="i915/skl_dmc_ver1_27.bin" 
```

list.

CONFIG_EXTRA_FIRMWARE is a space separated list of files to include in the kernel relative to CONFIG_EXTRA_FIRMWARE_DIR=

The driver is still looking for i915/kbl_dmc_ver1_04.bin, it won't use i915/skl_dmc_ver1_27.bin.

You can try the intel driver if you wish.

modeset has no hardware acceleration.

The kernel Option I couldn't find is 

```
CONFIG_INTEL_MEI_ME
```

Thats the out of band remote management interface on your chipset.

Its best left off unless you know you need it. Its a corporate thing with security holes.

You also need CONFIG_I2C_I801 for your 

```
00:1f.4 SMBus [0c05]: Intel Corporation 200 Series/Z370 Chipset Family SMBus Controller [8086:a2a3]
```

----------

## jyoung

I'm unclear on what the different files in /lib/firmware/i915 mean. The intel graphics wiki suggests the skl files, but you're using the kbl files?

The intel driver does seem like a good choice. I initially moved away from it because the intel graphics wiki said that it has been slowly deprecating, but I think I want the hardware acceleration. It would just a change to the configuration in xorg.config.d, yes?

----------

## NeddySeagoon

jyoung,

The driver works out the files it needs and tries to load them.

When they are missing it complains in dmesg with the file name that failed to load.

I'm just copying file names from your dmesg.

There is a downside. It may want several files but it will only tell you about one at a time per driver.

 *Quote:*   

> It would just a change to the configuration in xorg.config.d

 

If you already have intel in your VIDEO_CARDS, then yes.

If support for the driver is not installed, you need to add it. The kernel supports both as is.

----------

## jyoung

I'm still getting a high load on X.

I have 

```
VIDEO_CARDS="intel i965"
```

The dmesg output has changed, but still producing a firmware error:

```
dmesg | grep firmware

[    0.135774] Spectre V2 : Enabling Restricted Speculation for firmware calls

[    1.013599] [drm] Finished loading DMC firmware i915/kbl_dmc_ver1_04.bin (v1.4)

[    8.431110] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
```

My xorg.conf.d/20-intel.conf file is the same as the wiki:

```
Section "Device"

    Identifier  "Intel Graphics"

    Driver      "intel"

    Option      "AccelMethod"    "sna"

EndSection
```

----------

## mike155

 *Quote:*   

> 
> 
> ```
> [    1.013599] [drm] Finished loading DMC firmware i915/kbl_dmc_ver1_04.bin (v1.4)
> 
> ...

 

That's much better !

 *Quote:*   

> 
> 
> ```
> [    8.431110] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
> ```
> ...

 

That's probably your wifi driver, not your graphics driver.  :Smile: 

 *Quote:*   

> My xorg.conf.d/20-intel.conf file is the same as the wiki:
> 
> ```
> Section "Device"
> 
> ...

 

You may want to switch to the modesetting driver, which is now the default driver on newer Intel graphics chipsets for Gentoo:

```
Section "Device"

    Identifier  "Intel Graphics"

    Driver      "modesetting"

    Option      "AccelMethod"    "glamor"

    Option      "DRI"            "3"

EndSection
```

Please look at: https://wiki.gentoo.org/wiki/Intel#Modesetting_DDX. Don't forget to enable USE flag 'glamor' (as shown in the Wiki article) and to run 'emerge --ask --changed-use --deep @world' after you enabled the USE flag 'glamor'.

----------

## NeddySeagoon

mike155,

modesetting and glamour is where we came from. I didn't check DDX though.

```
[    8.431110] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
```

is indeed wifi related.

However,  8.431110 seconds is well after root is mounted and linux-firmware is installed which provides regulatory.db and regulatory.db.p7s so I don't understand why that doesn't load.

----------

## jyoung

As an experiment, I just now tried swapping the intel configuration file in xorg.conf.d for the modesetting file (both copied from the wiki). It seemed worth trying again since some of the firmware issues are resolved. But, the load from X seems to be about the same, around 15-20%. Just to confirm, that's kind of high, right? I'm just running a web browser and a terminal. It does get down into the few percent when I'm not doing anything, but when I move the mouse around it spikes.

----------

## mike155

I have a machine with an Intel Ivy Bridge CPU (4 cores) and on chip GPU. I use the Intel modesetting driver.

Below is what I see. I started Firefox, LibreOffice and a terminal window. 'top' is running in the terminal window.

When I do nothing, top reports a 'load average' between 0.05 and 0.1 and 99.9% 'CPU idle'.

When I start to move the mouse around over the LibreOffice window, the 'load average' increases to 0.2, 'CPU idle' goes down to 98% and I see that the 'soffice.bin' process consumes 5% CPU.

When I start to move the mouse around over the Firefox window, the 'load average' increases to 0.2, 'CPU idle' goes down to 98% and I see that the 'firefox' process consumes 10% CPU.Everything is alright if you get a similar result.   :Smile: 

----------

## NeddySeagoon

jyoung,

Install x11-apps/mesa-progs if you don't have it.

That provides glxgears which is pretty to look at but not much use for anything else.

It also provides glxinfo, which will tell about your direct renderering, that might me very interesting.

What does  

```
glxinfo | head -n10
```

 tell?

We mostly care about 

```
direct rendering: Yes
```

If yours says No there, are you a member of the video group?

You normal user needs access to the files in /dev/dri/

Without that, you get indirect rendering which is very slow.

----------

## jyoung

No clues on those two threads. The normal user is in video, and 

```
glxinfo | head -n10
```

returns

```

name of display: :0.0

display: :0  screen: 0

direct rendering: Yes

server glx vendor string: SGI

server glx version string: 1.4

server glx extensions:

    GLX_ARB_create_context, GLX_ARB_create_context_no_error, 

    GLX_ARB_create_context_profile, GLX_ARB_create_context_robustness, 

    GLX_ARB_fbconfig_float, GLX_ARB_framebuffer_sRGB, GLX_ARB_multisample, 

    GLX_EXT_create_context_es2_profile, GLX_EXT_create_context_es_profile, 

```

When I did this test, I was running (or trying to run) the modesetting driver.

----------

## jyoung

I just rebooted with the intel configuration file in xorg.conf.d, and the results were about the same. What's the best way to get more information from/about the driver in use, or from X?

```
grep EE /var/log/Xorg.0.log
```

 doesn't return anything

----------

