smbd: High CPU usage

Vadim Lazovskiy vadim.lazovskiy at gmail.com
Wed Jul 18 13:30:06 UTC 2018


Hello.

I've encountered the issue in samba4. I'm totally convinced it is a bug.
In *some* cases with *some* clients smbd process hogs the CPU.
Attaching strace to such process shows huge amount sendfile() syscall
that's trying to write to non-blocking socket while write is actually would
block:

sendfile(37, 34, [320625896], 238360)   = -1 EAGAIN (Resource temporarily
unavailable)
sendfile(37, 34, [320625896], 238360)   = -1 EAGAIN (Resource temporarily
unavailable)
sendfile(37, 34, [320625896], 238360)   = -1 EAGAIN (Resource temporarily
unavailable)
sendfile(37, 34, [320625896], 238360)   = -1 EAGAIN (Resource temporarily
unavailable)
sendfile(37, 34, [320625896], 238360)   = -1 EAGAIN (Resource temporarily
unavailable)

Among this flood there are some rare successful writes:
sendfile(37, 34, [320497416] => [320561656], 366840) = 64240

37 is the network descriptor
34 is the file descriptor.

I've faced this issue several years ago when upgraded samba to 4.0. Then
I've decided to downgrade to 3.5. But now there is no way to stay at 3.x.

Of course it is possible to completely disable sendfile using "use sendfile
= no", then samba starts to use read and write syscalls but it would show
some performance decline.

Sure there is an improper/lack event handling for network descriptor.

Any suggestions?

Thank you!

My smb.conf:

[global]
map to guest = bad user
unix extensions = no
load printers = no
show add printer wizard = no
netbios name = video
workgroup = WORKGROUP
server string = Video

log level = 3
max log size = 0
socket options = SO_SNDBUF=131072
interfaces = 10.0.11.20/32
bind interfaces only = yes
deadtime = 2

dos charset = 866
unix charset = KOI8-R

use sendfile = yes
kernel change notify = no

syslog only = yes
oplocks = yes
fake oplocks = yes

[video]
   wide links = yes
   comment = video
   path = /disks/links/v-links
   public = yes
   writable = no
   wide links = yes


-- 
WBR,
Vadim Lazovskiy


More information about the samba-technical mailing list