LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 11-07-2006, 09:24 AM   #1
1337_penguin
Member
 
Registered: Jul 2005
Location: Brighton, UK
Distribution: Mainly Debian and Mepis, but also Slackware, Arch and Mandriva
Posts: 73

Rep: Reputation: 15
Samba CPU usage


Hi

I'm running Samba under Debian Sarge on a P2-350 box with 64MB RAM. When copying files from a Windows box, the CPU usage quickly jumps to around 10% and continues to increase until it usually hovers at about 30% until the transfer is complete, although on occasions it has been as high as 60-70% (and load averages of around 4) just copying 1 file. Generally when there is heavy disk usage, the system becomes less responsive. (e.g. copying files via samba whilst playing stuff with mpd causes the sound to stutter) I've checked to make sure DMA is enabled using hdparm and also enabled pther options including 'unmask IRQ' which reportedly should lower CPU consumption, to no avail.

EDIT: I've also tried copying files via FTP, which resulted in vsftpd using between 40-98% CPU. I know this isn't a powerful box, but this still seems excessive.

Idle:
Code:
top - 23:41:10 up  5:32,  1 user,  load average: 0.00, 0.00, 0.00
Tasks:  46 total,   1 running,  45 sleeping,   0 stopped,   0 zombie
Cpu(s):   0.0% user,   0.7% system,   0.0% nice,  99.3% idle
Mem:     62556k total,    60280k used,     2276k free,     5592k buffers
Swap:   177400k total,     1344k used,   176056k free,    39796k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 3014 root      18   0  1044 1044  848 R  0.7  1.7   0:00.40 top
    1 root       8   0   504  504  448 S  0.0  0.8   0:02.31 init [2]
    2 root       8   0     0    0    0 S  0.0  0.0   0:00.00 [keventd]
    3 root      19  19     0    0    0 S  0.0  0.0   0:00.05 [ksoftirqd_CPU0]
    4 root       9   0     0    0    0 S  0.0  0.0   0:02.34 [kswapd]
    5 root       9   0     0    0    0 S  0.0  0.0   0:00.60 [bdflush]
    6 root       9   0     0    0    0 S  0.0  0.0   0:00.00 [kupdated]
   99 root       9   0     0    0    0 S  0.0  0.0   0:00.25 [kjournald]
  240 root       9   0     0    0    0 S  0.0  0.0   0:00.98 [kjournald]
  428 root       9   0     0    0    0 S  0.0  0.0   0:00.00 [khubd]
  771 daemon     9   0   452  452  384 S  0.0  0.7   0:00.00 /sbin/portmap
  935 root       9   0   808  808  704 S  0.0  1.3   0:00.09 /sbin/syslogd
  938 root       9   0  1236 1232  480 S  0.0  2.0   0:00.29 /sbin/klogd
  972 Debian-e   9   0  1728 1724 1480 S  0.0  2.8   0:00.00 /usr/sbin/exim4 -b
  978 root       9   0   720  720  652 S  0.0  1.2   0:00.00 /usr/sbin/inetd
  983 lp         9   0   864  864  752 S  0.0  1.4   0:00.00 /usr/sbin/lpd -s
  987 root       9   0  1944 1944 1476 S  0.0  3.1   0:00.13 /usr/sbin/nmbd -D
Samba:
Code:
top - 23:43:50 up  5:35,  1 user,  load average: 0.08, 0.02, 0.01
Tasks:  46 total,   3 running,  43 sleeping,   0 stopped,   0 zombie
Cpu(s):   2.3% user,  48.7% system,   0.0% nice,  49.0% idle
Mem:     62556k total,    61276k used,     1280k free,     1432k buffers
Swap:   177400k total,     1408k used,   175992k free,    44916k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 2937 nobody    19   0  3228 3088 2528 R 31.8  4.9   1:24.11 /usr/sbin/smbd -D
    4 root       9   0     0    0    0 S  1.3  0.0   0:02.50 [kswapd]
    5 root       9   0     0    0    0 S  0.7  0.0   0:00.74 [bdflush]
  240 root       9   0     0    0    0 S  0.7  0.0   0:01.09 [kjournald]
 3015 root      11   0  1044 1044  848 R  0.7  1.7   0:00.38 top
    1 root       8   0   504  504  448 S  0.0  0.8   0:02.31 init [2]
    2 root       8   0     0    0    0 S  0.0  0.0   0:00.00 [keventd]
    3 root      19  19     0    0    0 S  0.0  0.0   0:00.05 [ksoftirqd_CPU0]
    6 root       9   0     0    0    0 S  0.0  0.0   0:00.00 [kupdated]
   99 root       9   0     0    0    0 S  0.0  0.0   0:00.25 [kjournald]
  428 root       9   0     0    0    0 S  0.0  0.0   0:00.00 [khubd]
  771 daemon     9   0   452  452  384 S  0.0  0.7   0:00.00 /sbin/portmap
  935 root       9   0   808  808  704 S  0.0  1.3   0:00.09 /sbin/syslogd
  938 root       9   0  1236 1232  480 S  0.0  2.0   0:00.29 /sbin/klogd
  972 Debian-e   9   0  1728 1724 1480 S  0.0  2.8   0:00.00 /usr/sbin/exim4 -b
  978 root       9   0   720  720  652 S  0.0  1.2   0:00.00 /usr/sbin/inetd
  983 lp         9   0   864  864  752 S  0.0  1.4   0:00.00 /usr/sbin/lpd -s
vsftpd:
Code:
top - 23:45:27 up  5:37,  1 user,  load average: 0.30, 0.11, 0.03
Tasks:  48 total,   3 running,  45 sleeping,   0 stopped,   0 zombie
Cpu(s):   7.3% user,  90.4% system,   0.0% nice,   2.3% idle
Mem:     62556k total,    61112k used,     1444k free,     1472k buffers
Swap:   177400k total,     1436k used,   175964k free,    44328k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 3018 ownage    16   0  1248 1248 1100 R 93.0  2.0   0:03.23 /usr/sbin/vsftpd
 3015 root      11   0  1044 1044  848 R  0.7  1.7   0:01.02 top
    5 root       9   0     0    0    0 D  0.3  0.0   0:00.96 [bdflush]
 2864 ownage     9   0  1900 1820 1628 R  0.3  2.9   0:00.85 sshd: ownage@pts/0
    1 root       8   0   504  504  448 S  0.0  0.8   0:02.31 init [2]
    2 root       8   0     0    0    0 S  0.0  0.0   0:00.00 [keventd]
    3 root      19  19     0    0    0 S  0.0  0.0   0:00.05 [ksoftirqd_CPU0]
    4 root       9   0     0    0    0 S  0.0  0.0   0:02.97 [kswapd]
    6 root       9   0     0    0    0 S  0.0  0.0   0:00.00 [kupdated]
   99 root       9   0     0    0    0 S  0.0  0.0   0:00.26 [kjournald]
  240 root       9   0     0    0    0 S  0.0  0.0   0:01.45 [kjournald]
  428 root       9   0     0    0    0 S  0.0  0.0   0:00.00 [khubd]
  771 daemon     9   0   452  452  384 S  0.0  0.7   0:00.00 /sbin/portmap
  935 root       9   0   808  808  704 S  0.0  1.3   0:00.09 /sbin/syslogd
  938 root       9   0  1236 1232  480 S  0.0  2.0   0:00.29 /sbin/klogd
  972 Debian-e   9   0  1728 1724 1480 S  0.0  2.8   0:00.00 /usr/sbin/exim4 -b
  978 root       9   0   720  720  652 S  0.0  1.2   0:00.00 /usr/sbin/inetd
Does anyone have any idea what could be causing the CPU usage to be so high?

Thanks in advance.

1337_penguin

Last edited by 1337_penguin; 11-07-2006 at 04:45 PM.
 
Old 11-08-2006, 03:33 AM   #2
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,552

Rep: Reputation: 103Reputation: 103
Hmm at first glance I would have said DMA, but you seem sure this isn't the problem.

I had exactly the same problem on my setup (2.6.9 on FC3 on an old P4 3.0gHZ machine) because the 2.6.9 kernel was incapable of using DMA on my particular motherboard. I upgraded to 2.6.14.3 which was capable of using DMA on my motherboard.

E. g. are you SURE DMA isn't the issue here? The exact symptoms you describe is word for word what I was experiencing with Samba on my "DMA-less" old kernel...

One thing you can try (though it might slow down your file transfer to a great degree) is to simply renice the samba processes to have a lower priority - which might help a bit, though maybe not much if something -else- is awry, or some kind of IO bottleneck is present. I've seen this in particular when copying files off an old (300mHz) P2 I've got here, under my DMA-less kernel. Copying from faster machines user Samba choked mine down quite a bit (slow apparent GUI reponse, etc) while copying from the slower machine didn't have that great an effect... Guess it was because the old machine couldn't "shoot" as fast as the newer, faster ones, giving my DMA-less system a bit of a breather since the CPU wasn't off doing the transfer the whole time.

On the other hand, you are using a very minimal system there. Are you using a GUI or running in text mode? If you are running in text mode (runlevel 3) then this shouldn't be such a problem (I used such a system successfully as a development server a while back) but if you are running a GUI this could be a problem, since you will quickly run out of phyiscal RAM. Maybe your system is just slow in general paging out to disk, especially if you start copying huge files?
 
Old 11-08-2006, 07:23 AM   #3
th_dan
LQ Newbie
 
Registered: Nov 2006
Location: UK
Distribution: Debian 3.1
Posts: 18

Rep: Reputation: 0
Hi Guys,

I have a 1.3 ghz 1gig ram box running debian 3.1 as a file server. If I transfer large files to the box the cpu usuage can go upto 30% to 40%. It will then go down after the transfer has finished.

Thats just the way it is. The system will slow down a little depending on the spec.

Hopefully this helps

Dan
 
Old 11-08-2006, 12:41 PM   #4
1337_penguin
Member
 
Registered: Jul 2005
Location: Brighton, UK
Distribution: Mainly Debian and Mepis, but also Slackware, Arch and Mandriva
Posts: 73

Original Poster
Rep: Reputation: 15
Hi

dmesg shows that the BIOS detects the drives as PIO, however it seems that it's able to enable DMA anyway: it reports hda as DMA, and hdb as UDMA33 so I assume that the kernel supports DMA (I'm using the stock 2.4.27-386 kernel, but have also tried 2.4.27-686 and 2.6.8-386 and 686 ones.

Code:
[root@lilah ~]# dmesg | grep DMA
  DMA zone: 4096 pages, LIFO batch:1
    ide0: BM-DMA at 0xf000-0xf007, BIOS settings: hda:pio, hdb:pio
    ide1: BM-DMA at 0xf008-0xf00f, BIOS settings: hdc:pio, hdd:pio
hda: 2503872 sectors (1281 MB) w/256KiB Cache, CHS=2484/16/63, DMA
hdb: 39102336 sectors (20020 MB) w/2048KiB Cache, CHS=38792/16/63, UDMA(33)
hdd: Disabling (U)DMA for SAMSUNG CD-ROM SC-148F (blacklisted)
[root@lilah ~]# dmesg | grep ^hd
hda: WDC AC11200L, ATA DISK drive
hdb: ST320410A, ATA DISK drive
hda: max request size: 128KiB
hda: 2503872 sectors (1281 MB) w/256KiB Cache, CHS=2484/16/63, DMA
hdb: max request size: 128KiB
hdb: 39102336 sectors (20020 MB) w/2048KiB Cache, CHS=38792/16/63, UDMA(33)
hdd: SAMSUNG CD-ROM SC-148F, ATAPI CD/DVD-ROM drive
hdd: Disabling (U)DMA for SAMSUNG CD-ROM SC-148F (blacklisted)
hdd: ATAPI 48X CD-ROM drive, 128kB Cache
[root@lilah ~]#
This is just the base install, to which I added Samba, Apache, vsftpd, mpd, etc. I'm running it headless and access it via SSH.

1337_penguin

Last edited by 1337_penguin; 11-08-2006 at 04:15 PM.
 
Old 11-08-2006, 01:20 PM   #5
1337_penguin
Member
 
Registered: Jul 2005
Location: Brighton, UK
Distribution: Mainly Debian and Mepis, but also Slackware, Arch and Mandriva
Posts: 73

Original Poster
Rep: Reputation: 15
I've done a bit more testing (creating a 1GB file with dd, and then copying it locally (ie. cp 1GB-file 1GB-file_copy), which used up on average about 25% CPU, so it seems the problem isn't actually to do with Samba, but as far as I can tell DMA is enabled and stuff

1337_penguin

Last edited by 1337_penguin; 11-08-2006 at 03:34 PM.
 
Old 11-08-2006, 02:32 PM   #6
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
Problems like this one are often caused by cheapo NIC's. Difference between an Intel PRO and some junk card is incredibly huge.
 
Old 11-08-2006, 03:48 PM   #7
1337_penguin
Member
 
Registered: Jul 2005
Location: Brighton, UK
Distribution: Mainly Debian and Mepis, but also Slackware, Arch and Mandriva
Posts: 73

Original Poster
Rep: Reputation: 15
Well, I swapped out the card (a Realtek 8139) for an Intel Pro 100 card I had lying around, but the CPU usage is still pretty much the same. As I stated, it also happens when copying files locally (ie. not over the network) (so doesn't appear to be an issue with networking), despite the fact that DMA appears to be enabled. 25% seems rather high for just copying a file, on an otherwise idle box.
 
Old 11-09-2006, 08:10 AM   #8
ARC1450
Member
 
Registered: Jun 2005
Location: Odenton, MD
Distribution: Gentoo
Posts: 290

Rep: Reputation: 30
It will use CPU, but considering I've got a K6-450 with 192MB of RAM running Shoutcast, Samba (PDC), DNS, Syslog, Squid, NFS, CUPS, Apache, and IRC on that box. . .yeah. . .you shouldn't be encountering skips while playing an MP3 if I don't. I have to try to make mine skip, and that's by doing something I KNOW will bog it down (like run Shoutcast and a Q3 server at the same time).

What type of hard drive are you using? Just because the kernel detects something as DMA, doesn't mean it auto sets it to use DMA. Do an hdparm /dev/hd(x) and see what pops up, and try hdparm -i /dev/hd(x). I had an issue with one kernel dropping DMA occasionally even though I turned it on. But even in that case, crap never skipped. The slowest hard drive I ever put in my system was an ATA/66 drive, but the chipset still maxes out at about 7MB/s transfer to and fro (the -i will tell you the disk read speed). You may need to tweak up your hard drive (multicount, DMA, unmask, IO Support) and see if that helps a little. Heck, you may simply just need 128MB of RAM and everything will be fine, too. Although, I'd whole-heartedly suggest the RAM upgrade anyway, since everything your computer does hits memory before doing anything else.
 
Old 11-10-2006, 01:57 PM   #9
1337_penguin
Member
 
Registered: Jul 2005
Location: Brighton, UK
Distribution: Mainly Debian and Mepis, but also Slackware, Arch and Mandriva
Posts: 73

Original Poster
Rep: Reputation: 15
Here's the output for each of the drives:

Code:
[root@lilah /home/ownage]# hdparm /dev/hda

/dev/hda:
 multcount    = 16 (on)
 IO_support   =  0 (default 16-bit)
 unmaskirq    =  0 (off)
 using_dma    =  1 (on)
 keepsettings =  0 (off)
 readonly     =  0 (off)
 readahead    =  8 (on)
 geometry     = 621/64/63, sectors = 2503872, start = 0
[root@lilah /home/ownage]# hdparm -i /dev/hda

/dev/hda:

 Model=WDC AC11200L, FwRev=23.38D25, SerialNo=WD-WT3460219242
 Config={ HardSect NotMFM HdSw>15uSec SpinMotCtl Fixed DTR>5Mbs FmtGapReq }
 RawCHS=2484/16/63, TrkSize=57600, SectSize=600, ECCbytes=22
 BuffType=DualPortCache, BuffSize=256kB, MaxMultSect=16, MultSect=16
 CurCHS=2484/16/63, CurSects=2503872, LBA=yes, LBAsects=2503872
 IORDY=on/off, tPIO={min:160,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes:  pio0 pio1 pio2 pio3 pio4
 DMA modes:  mdma0 mdma1 *mdma2
 AdvancedPM=no
 Drive conforms to: device does not report version:  1 2 3

 * signifies the current active mode

[root@lilah /home/ownage]# hdparm /dev/hdb

/dev/hdb:
 multcount    = 16 (on)
 IO_support   =  0 (default 16-bit)
 unmaskirq    =  0 (off)
 using_dma    =  1 (on)
 keepsettings =  0 (off)
 readonly     =  0 (off)
 readahead    =  8 (on)
 geometry     = 2434/255/63, sectors = 39102336, start = 0
[root@lilah /home/ownage]# hdparm -i /dev/hdb

/dev/hdb:

 Model=ST320410A, FwRev=3.34, SerialNo=3FG1LS4X
 Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs RotSpdTol>.5% }
 RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=4
 BuffType=unknown, BuffSize=2048kB, MaxMultSect=16, MultSect=16
 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=39102336
 IORDY=on/off, tPIO={min:240,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes:  pio0 pio1 pio2 pio3 pio4
 DMA modes:  mdma0 mdma1 mdma2
 UDMA modes: udma0 udma1 *udma2 udma3 udma4 udma5
 AdvancedPM=yes: unknown setting WriteCache=enabled
 Drive conforms to: device does not report version:

 * signifies the current active mode

[root@lilah /home/ownage]#
According to http://wdc.custhelp.com/cgi-bin/wdc....i=&p_topview=1, hda supports UDMA2, although from the hdparm output it seems to be using MDMA2. Attempting to set it to UDMA2 produces the following error:
Code:
[root@lilah /home/ownage]# hdparm -X udma2 /dev/hda

/dev/hda:
 setting xfermode to 66 (UltraDMA mode2)
 HDIO_DRIVE_CMD(setxfermode) failed: Input/output error
I've tried various options with hdparm (such as -c3 -m16 -d1 -u1) but nothing really seems to make a difference. I also added an extra 128MB of RAM, but likewise that doesn't seem to help either.

Last edited by 1337_penguin; 11-10-2006 at 02:20 PM.
 
Old 11-13-2006, 08:07 AM   #10
ARC1450
Member
 
Registered: Jun 2005
Location: Odenton, MD
Distribution: Gentoo
Posts: 290

Rep: Reputation: 30
That's weird. Here's an output from my little K6-III box:

Code:
Apollo arcruea # hdparm -I /dev/hda

/dev/hda:

ATA device, with non-removable media
        Model Number:       ST320011A
        Serial Number:      3HT3ALXN
        Firmware Revision:  3.75
Standards:
        Supported: 5 4 3 2
        Likely used: 6
Configuration:
        Logical         max     current
        cylinders       16383   16383
        heads           16      16
        sectors/track   63      63
        --
        CHS current addressable sectors:   16514064
        LBA    user addressable sectors:   39102336
        device size with M = 1024*1024:       19092 MBytes
        device size with M = 1000*1000:       20020 MBytes (20 GB)
Capabilities:
        LBA, IORDY(can be disabled)
        bytes avail on r/w long: 4      Queue depth: 1
        Standby timer values: spec'd by Standard
        R/W multiple sector transfer: Max = 16  Current = 16
        Recommended acoustic management value: 128, current value: 128
        DMA: mdma0 mdma1 mdma2 udma0 udma1 *udma2 udma3 udma4 udma5
             Cycle time: min=120ns recommended=120ns
        PIO: pio0 pio1 pio2 pio3 pio4
             Cycle time: no flow control=240ns  IORDY flow control=120ns
Commands/features:
        Enabled Supported:
           *    READ BUFFER cmd
           *    WRITE BUFFER cmd
           *    Host Protected Area feature set
           *    Look-ahead
           *    Write cache
           *    Power Management feature set
                Security Mode feature set
           *    SMART feature set
                Device Configuration Overlay feature set
           *    Automatic Acoustic Management feature set
                SET MAX security extension
           *    DOWNLOAD MICROCODE cmd
Security:
        Master password revision code = 65534
                supported
        not     enabled
        not     locked
        not     frozen
        not     expired: security count
        not     supported: enhanced erase
HW reset results:
        CBLID- above Vih
        Device num = 1
Checksum: correct
Apollo arcruea #
Just curious, did you compile your own kernel? If so, there may be some modules missing that are needed, most notably like the DMA and generic motherboard support.

I can tell you, though, you shouldn't have skipping problems with Samba unless you're weighing that thing down heavier than hell.
 
Old 11-14-2006, 02:43 PM   #11
1337_penguin
Member
 
Registered: Jul 2005
Location: Brighton, UK
Distribution: Mainly Debian and Mepis, but also Slackware, Arch and Mandriva
Posts: 73

Original Poster
Rep: Reputation: 15
I'm just using Debian's default 2.4.27-386 kernel, but have also tried with the 2.4.27-686 and 2.6.8 386 and 686 ones (acquired via apt-get). I assume all those would include the necessary modules. (considering that dmesg and hdaprm seems to suggest that DMA is enabled and lsmod shows 'piix' in the list)

I haven't had much luck compiling kernels in the past - I tend to get to building stage, but it just produces loads of errors and I have no idea where to start looking in order to fix them.

1337_penguin
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
getting realtime info on memory usage-cpu and harddrive usage steering Linux - Newbie 5 03-03-2005 08:43 PM
how to determine cpu usage, memory usage, I/O usage by a particular user logged on li rags2k Programming 4 08-21-2004 04:45 AM
Controlling CPU usage & memory usage Saravana babu Linux - Software 0 02-18-2004 05:55 AM
CPU Usage Jehos Programming 3 11-30-2003 05:46 AM
CPU usage in X jhaiduce Linux - Software 2 09-20-2003 12:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 05:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration