PDA

View Full Version : "unloadagp" needs to be used several times



arctgx
02-26-2007, 03:33 PM
Hello! Sorry for my poor English;)

"Unloading unneeded AGP modules..." works not correctly on my machine. Function "unloadagp" is included in /etc/init.d/xsession. In order to completely cleaning kernel from unneeded modules I need to run it several times.
It is conclusion from an experiment presented below:

$ lsmod|grep agp intel_agp 27420 0
amd64_agp 16772 0
sis_agp 12676 0
amd_k7_agp 12812 0
ali_agp 11136 0
via_agp 13952 1
agpgart 36044 7 intel_agp,amd64_agp,sis_agp,amd_k7_agp,ali_agp,drm ,via_agp

I copied "while" loop from "unloadagp" and executed it as root.

$ su
# while read m relax; do
> case "$m" in *_agp) rmmod "$m" >/dev/null 2>&1; ;; esac
> done </proc/modules
# lsmod|grep agp
amd64_agp 16772 0
amd_k7_agp 12812 0
via_agp 13952 1
agpgart 36044 4 amd64_agp,amd_k7_agp,drm,via_agp

# while read m relax; do case "$m" in *_agp) rmmod "$m" >/dev/null 2>&1; ;; esac; done </proc/modules
# lsmod|grep agp
amd_k7_agp 12812 0
via_agp 13952 1
agpgart 36044 3 amd_k7_agp,drm,via_agp

# while read m relax; do case "$m" in *_agp) rmmod "$m" >/dev/null 2>&1; ;; esac; done </proc/modules
# lsmod|grep agp
via_agp 13952 1
agpgart 36044 2 drm,via_agp

Now it's OK, there is only AGP drivers for my chipset. Next running loop does nothing.

# while read m relax; do case "$m" in *_agp) rmmod "$m" >/dev/null 2>&1; ;; esac; done </proc/modules
# lsmod|grep agp
via_agp 13952 1
agpgart 36044 2 drm,via_agp



# lspci
00:00.0 Host bridge: VIA Technologies, Inc. VT8377 [KT400/KT600 AGP] Host Bridge
00:01.0 PCI bridge: VIA Technologies, Inc. VT8235 PCI Bridge
00:06.0 Multimedia audio controller: Creative Labs SB Live! EMU10k1 (rev 0a)
00:06.1 Input device controller: Creative Labs SB Live! Game Port (rev 0a)
00:10.0 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 80)
00:10.1 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 80)
00:10.2 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 80)
00:10.3 USB Controller: VIA Technologies, Inc. USB 2.0 (rev 82)
00:11.0 ISA bridge: VIA Technologies, Inc. VT8235 ISA Bridge
00:11.1 IDE interface: VIA Technologies, Inc. VT82C586A/B/VT82C686/A/B/VT823x/A/C PIPC Bus Master IDE (rev 06)
01:00.0 VGA compatible controller: ATI Technologies Inc Radeon RV250 If [Radeon 9000] (rev 01)
01:00.1 Display controller: ATI Technologies Inc Radeon RV250 [Radeon 9000] (Secondary) (rev 01)

# find /lib/modules/2.6.19/|grep agp
/lib/modules/2.6.19/kernel/drivers/char/agp
/lib/modules/2.6.19/kernel/drivers/char/agp/agpgart.ko
/lib/modules/2.6.19/kernel/drivers/char/agp/ali-agp.ko
/lib/modules/2.6.19/kernel/drivers/char/agp/amd-k7-agp.ko
/lib/modules/2.6.19/kernel/drivers/char/agp/amd64-agp.ko
/lib/modules/2.6.19/kernel/drivers/char/agp/ati-agp.ko
/lib/modules/2.6.19/kernel/drivers/char/agp/efficeon-agp.ko
/lib/modules/2.6.19/kernel/drivers/char/agp/intel-agp.ko
/lib/modules/2.6.19/kernel/drivers/char/agp/nvidia-agp.ko
/lib/modules/2.6.19/kernel/drivers/char/agp/sis-agp.ko
/lib/modules/2.6.19/kernel/drivers/char/agp/sworks-agp.ko
/lib/modules/2.6.19/kernel/drivers/char/agp/via-agp.ko


BTW, I discovered "pcimodules".

gizero
03-15-2007, 05:20 PM
Hi arctgx,

I also get into this today! While trying to optimize memory usage of my Knoppix 5.0.1, I realized that unloadagp() function in /etc/init.d/xsession was not doing the job well.

I suspect this is due to on-the-fly modification of /proc/modules while it is being scanned by the loop. In fact, while reading it you are running rmmod which in turn will affect the pseudo-file content.

I had no time to deeply review how read and bash redirection works in this case (is any guru out there with required wisdom?) but I think the file is not opened and closed at each iteration of the while loop causing the function to misbehave. To confirm this I made a copy of /proc/modules's content and run unloadagp() on it and, not surprisingly, what I got was the correct behaviour, with any unneeded _agp module behing removed from kernel.

I did't even have time to check if this has been fixed in new releases. I'll check and maybe post a bug report if appropriate.

Regards,

Andrea

gizero
03-15-2007, 05:31 PM
After some more googling I found it was already reported here for 4.0.2 with a reasonable fix.

http://www.knoppix.net/wiki/Bugs/4.0.2CD #22

Andrea

arctgx
04-13-2007, 09:36 AM
Hello! Script modified by chris_startx works on my 5.1.0!

In /cdrom/knoppix.sh I added command
patch /etc/init.d/xsession.sh /usr/local/share/arctgx/unneeded_agp.patch
where unneeded_agp.patch is earlier extracted also by knoppix.sh from my arctgx.tbz (for myconfig=/dev/cdrom in kernel commandline) and consists of following lines:

96c96,98
< done </proc/modules
---
> done <<EOT
> $(lsmod | grep _agp)
> EOT

It is output of diff between original and changed (by chris_startx) xsession (for Knoppix 5.1.0) script.

Great thanks!
arctgx