[Samba] Samba4 consumes more CPU

Thiago Fernandes Crepaldi tognado at gmail.com
Mon Sep 30 14:21:44 MDT 2013


Andrew, in my company we are also experiencing a higher CPU usage of Samba
4 (smbd) if compared to Samba 3.

In fact, it almost reaches 100% of CPU and uses all the memory during *dir
copies* (individual file copy is as good as samba 3's). I strongly believe
that this CPU usage is the responsible for a worse samba 4's throughput if
compared to Samba 3 tests.

Giving that, I would like to contribute with this investigation and share
my data regarding perf profiling on smbd (parent process)

Events: 7  cycles
-  90.01%  smbd  [kernel.kallsyms]  [k] copy_pte_range
     copy_pte_range
     __libc_fork
     smbd_accept_connection
-   9.77%  smbd  [kernel.kallsyms]  [k] handle_edge_irq
     handle_edge_irq
     smbd_accept_connection
-   0.22%  smbd  [kernel.kallsyms]  [k] perf_pmu_rotate_start.isra.57
     perf_pmu_rotate_start.isra.57
     __poll
-   0.00%  smbd  [kernel.kallsyms]  [k] native_write_msr_safe
     native_write_msr_safe
     __poll

My smb.conf is:

[Global]
available= yes
client signing= auto
server signing= auto
server string= LenovoEMCâ
                         ¢ px4-400r
Workgroup= WORKGROUP
security= user
domain master= auto
preferred master= auto
local master= yes
os level= 20
invalid users= bin daemon adm sync shutdown halt mail news uucp gopher
map to guest= Bad User
host msdfs= yes
restrict anonymous= 0
strict allocate= yes
encrypt passwords= yes
passdb backend= smbpasswd
printcap name= lpstat
printable= no
load printers= yes
max smbd processes= 500
getwd cache= yes
syslog= 0
use sendfile= yes
browse directory= /tmp/samba
winbind sequence directory= /tmp/samba
log level= 0
max log size= 50
unix extensions= no
veto files= /.AppleDouble/.AppleDB/.bin/.AppleDesktop/Network Trash
Folder/Temporary Items/:2eDS_Store/

[Printers]
path= /mnt/system/samba/spool
printable= yes
only guest= yes
use client driver= yes
comment= All Printers

[USB_UnkVend_USB_DISK_MOD_a_1]
path= /mnt/ext/USB_UnkVend_USB_DISK_MOD_a_1/
max connections= 150
directory mode= 0777
create mode= 0777
follow symlinks= yes
wide links= no
strict allocate= no
nt acl support= no
dos filemode= no
writeable= yes
public= yes
store dos attributes= yes
write list= guest

[Backups]
path= /mnt/pools/A/A0/Backups/
max connections= 150
directory mode= 0777
create mode= 0777
follow symlinks= yes
wide links= no
nt acl support= no
dos filemode= no
writeable= yes
public= yes
store dos attributes= yes
write list= guest

[Documents]
path= /mnt/pools/A/A0/Documents/
max connections= 150
directory mode= 0777
create mode= 0777
follow symlinks= yes
wide links= no
nt acl support= no
dos filemode= no
writeable= yes
public= yes
store dos attributes= yes
write list= guest

My samba 4.0.9 was compiled with the following options:
CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
-march=atom -O2 -pipe -fomit-frame-pointer" \
samba_cv_HAVE_GETTIMEOFDAY_TZ=yes \
samba_cv_HAVE_IFACE_IFCONF=yes \
samba_cv_HAVE_IFACE_IFREQ=yes \
ac_cv_have_setresuid=yes \
ac_cv_have_setresgid=yes \
ac_cv_file__proc_sys_kernel_core_pattern=yes \
samba_cv_USE_SETRESUID=yes \
samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes \
samba_cv_HAVE_WRFILE_KEYTAB=yes \
samba_cv_HAVE_OFF64_T=yes \
samba_cv_have_longlong=yes \
samba_cv_HAVE_MMAP=yes \
samba_cv_HAVE_INO64_T=yes \
samba_cv_CC_NEGATIVE_ENUM_VALUES=yes \
smb_krb5_cv_enctype_to_string_takes_krb5_context_arg=no \
smb_krb5_cv_enctype_to_string_takes_size_t_arg=yes \
./configure \
        --without-pie \
        --disable-cups \
        --disable-iprint \
        --with-configdir=/etc/samba \
        --with-logfilebase=/tmp/samba \
        --with-lockdir=/tmp/samba \
        --with-piddir=/tmp/samba \
        --with-privatedir=/etc/samba/private \
        --with-sendfile-support \
        --with-ldap \
        --with-ads \
        --with-pam \
        --with-pammodulesdir=/lib/x86_64-linux-gnu/security \
        --with-pam_smbpass \
        --with-winbind \
        --with-acl-support \
        --with-automount \
        --enable-pthreadpool \
        --with-dnsupdate \
        --with-shared-modules=idmap_ad,idmap_rid \
        --localstatedir=/var \
        --with-libiconv=/usr \
        --with-cachedir=/mnt/system/samba/system \
        --prefix=/usr/local/samba \
        --without-ad-dc \
        --without-swat \
        --without-quotas \
        --with-aio-support \
        --fail-immediately \
        --jobs=8 \
        --enable-debug \ # i added this to use with perf only #

Please, let me know if I can do help more !
Thiago


On Mon, Sep 2, 2013 at 5:50 PM, Andrew Bartlett <abartlet at samba.org> wrote:

> On Mon, 2013-08-26 at 22:39 +0530, Prema wrote:
> > Dear Andrew,
> >
> > As per your suggestion , I have attached the gdb log of the samba and
> smbd
> > process log running in the single server mode.
> > Also when I noted in the perf top, libndr.so consumes the maximum cpu.
> > I noticed that it happens soon after sometime the samba process is
> started
> > and the CPU is filled up.
> > Since the samba process occupies 100% atleast two or more CPUs out of 8
> CPU
> > , the clients are not able to get authenticate to the server.
> > Kindly go through the logs and suggest what can be done to lessen the CPU
> > consumption.
>
> Digging into the libndr issue some more:
>
> Sadly I can't use the perf.data without your full build tree, so I'm
> going to need you to do some more digging on this side of things.
>
> Can you show me what exact code in libndr is spinning?  (That is, dig
> into the perf screen)
>
> Then, can you re-run it under
>
> 'perf record -g -p <PID>'?
>
> And then show me the output of perf report -g, expanding the first
> function call stacks to find out what is the eventual high-level caller
> of the spinning routine.  This may give us the critical clues we need.
>
> Thanks,
>
> Andrew Bartlett
>
> --
> Andrew Bartlett
> http://samba.org/~abartlet/
> Authentication Developer, Samba Team           http://samba.org
> Samba Developer, Catalyst IT                   http://catalyst.net.nz
>
>
> --
> To unsubscribe from this list go to the following URL and read the
> instructions:  https://lists.samba.org/mailman/options/samba
>



-- 
Thiago Crepaldi


More information about the samba mailing list