Xorg: first startup takes a long time

I have a strange problem on one machine; the first startup of Xorg (I use startxfce4, but have also tested with startx) takes a long time. From /var/log/messages:
Code:
Jun  4 23:26:57 kg-vm kernel: drm0: <ATI Radeon RS690 X1250 IGP> on vgapci0
Jun  4 23:26:57 kg-vm kernel: info: [drm] MSI enabled 1 message(s)
Jun  4 23:26:57 kg-vm kernel: info: [drm] Initialized radeon 1.31.0 20080613
Jun  4 23:50:59 kg-vm kernel: swap_pager: indefinite wait buffer: bufobj: 0, blkno: 465, size: 4096
Jun  4 23:50:59 kg-vm sshd[24977]: error: ssh_msg_send: write
Jun  4 23:55:05 kg-vm kernel: info: [drm] Setting GART location based on new memory map
Jun  4 23:55:05 kg-vm kernel: info: [drm] Loading RS690/RS740 Microcode
Jun  4 23:55:05 kg-vm kernel: info: [drm] Num pipes: 1
Jun  4 23:55:05 kg-vm kernel: info: [drm] writeback test succeeded in 1 usecs
Jun  4 23:55:05 kg-vm kernel: drm0: [ITHREAD]
(the message about ssh is irrelevant, ignore it).
However, if I exit Xorg and start it up again, things work normally:
Code:
Jun  5 23:40:27 kg-vm kernel: info: [drm] Setting GART location based on new memory map
Jun  5 23:40:27 kg-vm kernel: info: [drm] Loading RS690/RS740 Microcode
Jun  5 23:40:27 kg-vm kernel: info: [drm] Num pipes: 1
Jun  5 23:40:27 kg-vm kernel: info: [drm] writeback test succeeded in 1 usecs
Jun  5 23:40:27 kg-vm kernel: drm0: [ITHREAD]
Jun  5 23:40:40 kg-vm kernel: info: [drm] Num pipes: 1
The machine in question has an Asus M2A-VM HDMI mainboard, which has a Radeon X1250 built in.
Any hints on how to debug this?
 
Code:
swap_pager: indefinite wait buffer: bufobj: 0, blkno: 465, size: 4096
implies you may be out of swap or there may be some other swap problem. The long delay could be swapping things out to make room for X. Run top(1) before starting X and see what swap is used. How much memory and swap space does the system have?

Normally I'd ask to see /var/log/Xorg.0.log and xorg.conf, but this doesn't sound like an X problem.
 
I'm guessing the first delay is caused by the system needing to load the drm and perhaps i915 kernel modules.
 
Not certain to work, but if you can install the freecolor port, it seems to free up memory. I start Xorg on one machine in a script with freecolor right before it, since Xorg froze/crashed/fsck twice in a week, hasn't happened since then (needs a lot of memory to start.)
 
The system has 4 GB memory:
Code:
root@kg-vm# sysctl hw.physmem hw.usermem hw.realmem
hw.physmem: 4143890432
hw.usermem: 3521773568
hw.realmem: 4831838208
Swap is 4GB as well:
Code:
root@kg-vm# swapinfo -h
Device          1K-blocks     Used    Avail Capacity
/dev/ad4s1b       4194304     1.8M     4.0G     0%
I don't know why it should use swap when starting Xorg for the first time, it never did that while running FreeBSD 7.3 / 7.2 stable. The machine runs the same load (mainly setiathome) as it did under FreeBSD 7.3 / 7.2 stable.
 
tingo said:
I don't know why it should use swap when starting Xorg for the first time, it never did that while running FreeBSD 7.3 / 7.2 stable. The machine runs the same load (mainly setiathome) as it did under FreeBSD 7.3 / 7.2 stable.

It shouldn't need swap. But something else may be filling RAM.
 
The DRM code significantly changed between 7 and 8, so there could be big difference in how swap/ram is being allocated now.

Adam
 
adamk said:
The DRM code significantly changed between 7 and 8, so there could be big difference in how swap/ram is being allocated now.

Adam

Yes but;
- the machine has 4 GB memory (ok, setiathome is running, but it did so under FreeBSD 7.3 / 7.2 stable too)
- I have other machines running FreeBSD 8.2-stable, using the radeon driver for Xorg, and with drm, which do not exhibit this problem.
 
Which still doesn't mean it isn't related to swap/ram allocation going on from the radeon DRM. I'm not saying that's the cause, I'm just saying you can't dismiss that possibility.

Frankly, the DRM code in FreeBSD is in pretty bad shape, in my experience. Particularly when it comes to allocating memory.

Adam
 
tingo said:
Yes but;
- the machine has 4 GB memory (ok, setiathome is running, but it did so under FreeBSD 7.3 / 7.2 stable too)
- I have other machines running FreeBSD 8.2-stable, using the radeon driver for Xorg, and with drm, which do not exhibit this problem.

Run top before starting X and see what it says.
% script /tmp/top.log
% top -b -d20

And in another shell, start X.

Switch back to the top shell afterwards, type ctrl-D, and
% egrep 'Mem:|Swap:' /tmp/top.log | less
 
Back
Top