这两天发现用VMware装的Fedora10,长时间编译程序时CPU使用率极高,打开系统监视器查看进程也没有发现CPU使用率较高的进程。在终端使用top命令查看,发现Xorg进程CPU使用率在90%多。
top - 16:21:18 up 3:02, 3 users, load average: 0.92, 0.96, 0.79
Tasks: 133 total, 2 running, 131 sleeping, 0 stopped, 0 zombie
Cpu(s): 59.2%us, 2.4%sy, 0.0%ni, 37.8%id, 0.0%wa, 0.3%hi, 0.3%si, 0.0%st
Mem: 510624k total, 504304k used, 6320k free, 41496k buffers
Swap: 1048568k total, 51840k used, 996728k free, 269460k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1788 root 20 0 58188 23m 6672 R 56.9 4.8 30:14.76 Xorg
5977 hzy 20 0 74020 16m 10m S 3.3 3.4 1:52.75 gnome-terminal
2139 hzy 20 0 164m 4248 3048 S 0.3 0.8 1:24.82 pulseaudio
2340 hzy 20 0 10068 2960 2340 S 0.3 0.6 0:14.88 ibus-daemon
23882 hzy 20 0 9064 1756 1496 S 0.3 0.3 0:00.99 wget
1 root 20 0 1964 576 484 S 0.0 0.1 0:01.35 init
2 root 15 -5 0 0 0 S 0.0 0.0 0:00.00 kthreadd
3 root RT -5 0 0 0 S 0.0 0.0 0:00.00 migration/0
4 root 15 -5 0 0 0 S 0.0 0.0 0:00.01 ksoftirqd/0
5 root RT -5 0 0 0 S 0.0 0.0 0:00.00 watchdog/0
6 root 15 -5 0 0 0 S 0.0 0.0 0:00.00 cpuset
7 root 15 -5 0 0 0 S 0.0 0.0 0:00.03 events/0
8 root 15 -5 0 0 0 S 0.0 0.0 0:00.00 work_on_cpu/0
9 root 15 -5 0 0 0 S 0.0 0.0 0:00.00 khelper
10 root 15 -5 0 0 0 S 0.0 0.0 0:00.00 netns
11 root 15 -5 0 0 0 S 0.0 0.0 0:00.00 kintegrityd/0
12 root 15 -5 0 0 0 S 0.0 0.0 0:03.34 kblockd/0
google了一下发现时ATI的显卡和Xorg的兼容问题。原文如下:(http://www.linuxinsight.com/your-ati-radeon-very-slow-on-xorg-x-server-1.3.html)
This one has bothered me for a long time. The solution is, of course, simple. But, I still don't understand why was it necessary to force users to search so hard for this piece of information, where all the older X server releases worked OK out of the box?
If you find that after upgrading to X.Org 7.3 your display becomes very slow, and you own ATI Radeon, all you need to do is to put this line in the Device section of your xorg.conf
:
Option "MigrationHeuristic" "greedy"
After that, your display should return to the normal speed, and X server will stop burning CPU cycles during such simple tasks like moving windows or switching workspaces.
This is my whole xorg.conf
Device section, with some other tuneups which you might find useful (depending on your card):
Section "Device"
Identifier "ATI Radeon"
Driver "ati"
Option "AccelMethod" "EXA"
Option "MigrationHeuristic" "greedy"
Option "AccelDFS" "true"
Option "EnablePageFlip" "true"
Option "EnableDepthMoves" "true"
EndSection
估计是因为编译程序时终端打印的信息过多,才导致问题的出现。
另一个解决方案:(http://ubuntuforums.org/showthread.php?t=1130582)
Overview
Some users are experiencing performance issues with Intel integrated graphics chips in Jaunty (9.04) for several possible reasons:
- The current driver in our repository has some performance issues with the EXA acceleration method. Users will notice 2D performance is poor due to the default "migration heuristic" employed by EXA (to "always" migrate pixmaps), but this causes performance issues for many users. Setting the heuristic to "greedy" alleviates this problem somewhat. See "man exa".
- The new and faster acceleration method (UXA) is not enabled by default, due to issues reported by many users. This code is being actively developed, and many stability and performance issues have been resolved in the latest drivers (specifically within the intel driver, libdrm, mesa and kernel 2.6.29.4 or later). Unfortunately, Jaunty will not include the latest versions necessary to improve performance.
- 3D performance has regressed compared to the Intrepid release, possibly due to major code changes that have resulted from the introduction to the new acceleration and memory management code (UXA, GEM, DRI2). Due to these changes, there seems to be some regressions in the "legacy" DRI acceleration.
- Either Xorg or the "intel" driver seems to be suffering from a bug in which the memory (MTRR) region allocated for the graphics card is not set up with the proper type of caching. This results in jerky video playback of almost any content (from 720p media, all the way down to simple 320x240 mpeg content), and a potential loss of performance for other 2D and 3D operations.
Safe Configuration
- For this configuration, you will upgrade to the latest stable Xorg drivers (via the X-Updates PPA), enable UXA acceleration and create a workaround for the MTRR bug. This is the solution recommended for users who possess hardware devices that depend on a restricted driver. If you don't know what this means, then this is the solution you should use.
- This configuration is identical to "Safe", but includes the 2.6.30.9 kernel. Using this kernel will improve 3D performance for many users, but you will lose access to restricted kernel drivers. This configuration yields the best results for my system (an 855GM chipset), but of course, your experience may differ.
- This configuration is the most risky. This will enable repository which contains bleeding-edge mesa & Xorg drivers which are continually updated (via the xorg-edgers PPA), enable UXA acceleration, create a workaround for the MTRR bug and install kernel 2.6.30.9. This configuration is not necessarily the fastest (in fact, the Optimal configuration is fastest for my hardware), and is recommended only for users who want to test the latest Xorg code.
Note: As per the PPA maintainer's wish, you are instructed to read the instructions here, since the Bleeding-Edge repository is prone to breakage and important instructions may be added. Don't request support for these packages (and don't be surprised if questions are left unanswered).
Warning: Do not switch between the Safe/Optimal and Bleeding-Edge solutions unless you have followed the steps to revert changes beforehand. For example, if you try the Bleeding-Edge method, and then decide to try the Optimal configuration, you will still be using the Bleeding-Edge drivers (because the xorg-edgers PPA contains newer drivers than the X-Updates PPA, which are not downgraded automatically).
Once you have decided on the configuration that suits you, begin by following Part A below:
Part A - Common Instructions (Safe/Optimal/Bleeding-Edge)
All users must follow this part.
0. Optional: If there is no xorg.conf file present on your system, the following command will create a minimal configuration (which you can customize later):
$ sudo dpkg-reconfigure -phigh xserver-xorg
1. Edit your xorg.conf:
$ gksudo gedit /etc/X11/xorg.conf
Section "Device" Identifier "Configured Video Device" Option "AccelMethod" "uxa" Option "EXAOptimizeMigration" "true" Option "MigrationHeuristic" "greedy" Option "Tiling" "true" # i8xx users: see note in guide EndSection
2. Download Bartec's fixmtrr.sh script and make it executable:
$ sudo wget http://launchpadlibrarian.net/26193373/fixmtrr.sh -O /usr/local/bin/fixmtrr.sh $ sudo chmod +x /usr/local/bin/fixmtrr.sh
$ sudo ln -s /usr/local/bin/fixmtrr.sh /etc/gdm/PostLogin/Default
4. If you want the Safe/Optimal configuration, continue to Part B. For Bleeding-Edge, skip to Part C.
Part B (Safe/Optimal)
Users who wish to try the Safe or Optimal configurations must follow this part.
1. Add the X Updates PPA to your sources.list:
Edit /etc/apt/sources.list:
$ gksudo gedit /etc/apt/sources.list
deb http://ppa.launchpad.net/ubuntu-x-swat/x-updates/ubuntu jaunty main #X-Updates PPA deb-src http://ppa.launchpad.net/ubuntu-x-swat/x-updates/ubuntu jaunty main #X-Updates PPA
$ sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com AF1CDFA9 $ sudo apt-get update $ sudo apt-get dist-upgrade
3. If you want to use the Safe configuration, you're finished - proceed to the Important Note section. If you want the Optimal configuration, continue to Part C.
Part C (Optimal/Bleeding-Edge)
Users who desire the Optimal or Bleeding-Edge configurations should follow this section.
1. Download & install the 2.6.30.9 kernel according to your architecture:
i386 users:
$ wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.30.9/linux-headers-2.6.30-02063009-generic_2.6.30-02063009_i386.deb http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.30.9/linux-headers-2.6.30-02063009_2.6.30-02063009_all.deb http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.30.9/linux-image-2.6.30-02063009-generic_2.6.30-02063009_i386.deb $ sudo dpkg -i linux-headers-2.6.30-02063009-generic_2.6.30-02063009_i386.deb linux-headers-2.6.30-02063009_2.6.30-02063009_all.deb linux-image-2.6.30-02063009-generic_2.6.30-02063009_i386.deb
$ wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.30.9/linux-headers-2.6.30-02063009-generic_2.6.30-02063009_amd64.deb http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.30.9/linux-headers-2.6.30-02063009_2.6.30-02063009_all.deb http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.30.9/linux-image-2.6.30-02063009-generic_2.6.30-02063009_amd64.deb $ sudo dpkg -i linux-headers-2.6.30-02063009-generic_2.6.30-02063009_amd64.deb linux-headers-2.6.30-02063009_2.6.30-02063009_all.deb linux-image-2.6.30-02063009-generic_2.6.30-02063009_amd64.deb
Part D (Bleeding-Edge)
Users who desire the Bleeding-Edge configuration should follow this section.
1. Add the xorg-edgers PPA to your sources.list:
Edit /etc/apt/sources.list:
$ gksudo gedit /etc/apt/sources.list
deb http://ppa.launchpad.net/xorg-edgers/ppa/ubuntu jaunty main #xorg-edgers PPA deb-src http://ppa.launchpad.net/xorg-edgers/ppa/ubuntu jaunty main #xorg-edgers PPA
$ sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 8844C542 $ sudo apt-get update $ sudo apt-get dist-upgrade
2. You're finished. However, before rebooting into the new kernel, read the Important Note section.
Important Notes (Safe/Optimal/Bleeding-Edge)
Reporting Bugs
If you choose the Safe or Optimal configuration, you will be using the stable (but unofficial) X-Updates drivers. From the repository description:
While Ubuntu-X does not officially support these packages, if you discover problems when installing these debs please feel free to report bugs to launchpad. However, please make sure to clearly state that you are running packages from this PPA so we know the fixes need to come here. |
If you are using the Bleeding-Edge configuration, you can also report bugs to Launchpad as long as you explicitly state that you are using the xorg-edgers drivers. Please keep in mind that the purpose of the xorg-edgers repository is to package semi-daily snapshots of upstream's code, and Launchpad may not the appropriate place to file bugs (since there are going to be days where stuff is expected to break, and filing a bug is a waste of time). Alternatively, you can report issues to the upstream bug tracker, but you are expected to submit detailed reports. Don't expect support for the xorg-edgers drivers in this thread!
Remember to use the ubuntu-bug tool to ensure the required information gets submitted to your bug report:
$ ubuntu-bug xserver-xorg-video-intel
The purpose of the fixmtrr.sh script is to workaround a bug in the intel driver and/or kernel and ensure your graphics card's memory region gets set to the correct type of caching (write-combining). If your memory region is not set with the proper type of caching, you will experience video stuttering and reduced 3D performance.
Note: If you are using Kubuntu or a custom distribution of Ubuntu that does not use the GNOME Display Manager (GDM), you need to execute the fixmtrr.sh script each time X (re)starts. Therefore, executing this script in your rc.local script is not sufficient.
Interpreting Performance Gains
Do. Not. Trust. Glxgears.
Seriously. Your glxgears score may reduce after following this guide and enabling UXA acceleration (i.e., when the DRI2 framework is activated), but it does *not* mean things are worse.
The glxgears application was never an accurate benchmark of 3D performance, and developers have pleaded for users to understand this fact for a long, long time. See this page for an explanation.
I suggest you find a better tool to benchmark performance - in my case, I settled on PlanetPenguin racer (enabling the FPS counter in the options).
For comparison's sake, here's a rough outline of my performance results on my Inspiron 510m laptop with a Pentium M 1.5Ghz, 768MB ram and Intel 855GM chipset:
Intrepid: glxgears = ~1000fps, ppracer = ~23fps.
Jaunty (default configuration): glxgears = ~300fps, ppracer = ~19fps
Jaunty (with Optimal configuration): glxgears = ~340fps, ppracer = ~30fps
As you can see, glxgears does not accurately portray the improvement gained from testing the latest DRI2/UXA code.
To Revert Settings
If these configurations didn't work for you, this is how to revert changes.
- Edit your sources.list:
Code:$ gksudo gedit /etc/apt/sources.list
- Downgrade packages:
Code:$ sudo apt-get install libdrm-dev/jaunty libdrm2/jaunty libdrm-intel1/jaunty libdrm-radeon1/jaunty xserver-xorg-video-intel/jaunty libdrm-nouveau1/jaunty libgl1-mesa-dri/jaunty libgl1-mesa-glx/jaunty libgl1-mesa-dev/jaunty libglu1-mesa/jaunty mesa-common-dev/jaunty mesa-utils/jaunty xserver-common/jaunty xserver-xorg-core/jaunty xserver-xorg-input-evdev/jaunty xserver-xorg-input-evdev/jaunty xserver-xorg-input-synaptics/jaunty xserver-xorg-video-ati/jaunty xserver-xorg-video-nv/jaunty xserver-xorg-video-openchrome/jaunty xserver-xorg-video-radeon/jaunty
- Remove the 2.6.30.9 kernel:
Code:$ sudo dpkg -r linux-headers-2.6.30-02063009 linux-headers-2.6.30-02063009-generic linux-image-2.6.30-02063009-generic
- Reset your xorg.conf to defaults:
Code:$ sudo dpkg-reconfigure xserver-xorg
- Optional: remove the fixmtrr.sh script and GDM PostLogin hook:
Code:$ sudo rm /usr/local/bin/fixmtrr.sh /etc/gdm/PostLogin/Default
Changelog
v1.1 - 12/05/09 - Complete re-write.
v1.2 - 12/05/09 - Modified instructions to allow automatic startup of fixmtrr.sh script (Part A, step 3).
v1.3 - 19/05/09 - Updated Bleeding-Edge section to fetch -rc6 kernel.
v1.4 - 24/05/09 - Updated Bleeding-Edge section to fetch -rc7 kernel.
v1.5 - 01/06/09 - Updated Optimal section to fetch 2.6.29.4 kernel, added Bleeding-Edge note.
v1.6 - 02/06/09 - Added some warnings to guide.
v1.7 - 03/06/09 - Updated Bleeding-Edge section to fetch -rc8 kernel.
v1.8 - 11/06/09 - Updated Optimal and Bleeding-Edge sections to fetch final 2.6.30 kernel.
v1.9 - 15/06/09 - Added information regarding bug reporting policy to Important Note section.
v2.0 - 24/06/09 - Clarified bug reporting policy.
v2.1 - 22/07/09 - Updated guide to use 2.6.30.2 kernel.
v2.2 - 28/07/09 - Updated guide to use 2.6.30.3 kernel.
v2.3 - 15/09/09 - Updated guide to use 2.6.30.9 kernel.