smbd holds 70% cpu

Anthony Liguori aliguor at
Thu Jul 31 14:39:12 GMT 2003

> And Linux gurus, what the heck is ERESTARTNOHAND? I
> can't find it in /usr/include... I did find ERESTART,
> which is standard...

ERESTARTNOHAND is a kernel specific errno (in a kernel tree look for 
include/linux/errno.h).  ERESTARTNOHAND signals the caller that they 
should restart if there is no handler.  A userspace app should never see 
this (I don't know if it's even supposed to show up at the libc level).

This leads to an interesting question, if libc is looping hard on select 
w/ERESTARTNOHAND then perhaps the loop is in libc (which seems unlikely). 
I think a better thing than strace would be to kill -SEGV the process when 
it's looping hard and see what the back trace is.

Anthony Liguori
Linux/Active Directory Interoperability
Linux Technology Center (LTC) - IBM Austin
E-mail: aliguor at
Phone: (512) 838-1208
Tie Line: 678-1208

David Collier-Brown -- Customer Engineering <David.Collier-Brown at Sun.COM>
Sent by: at
31/07/2003 08:36 AM

        To:     Nir Livni <nirl at>
        cc:     samba-technical at
        Subject:        Re: smbd holds 70% cpu

Nir Livni wrote:
>>int select(int  nfds,  fd_set  *readfds,  fd_set  *writefds,
>>       fd_set *errorfds, struct timeval *timeout);
>>               Firstly, see how often it's happening, either by
>>               reading the contents of the timeval or just counting  
>>               seconds (;-))
>>               Next llok at the return value: -1 for an error (check 
>>               0 for a timeout, and a non-zero number if at elast one
>>               fd reorted something.
> Does this one look like a reasonable select ?
> select(1024, [29 30], NULL, NULL, NULL) = ? ERESTARTNOHAND (To be
> restarted).

                 Ok, it's saying that FDs 29 and 30 have data,
                 but it returned -1 and errno == ERESTARTNOHAND

                 LSOF will tell you what 29 and 30 are, but
                 the interesting thing is ERESTARTNOHAND...
                 The standard says that legal errnos are
                 EBADF, EINTR and EINVAL, and glibc adds ENOMEM.

                 Looking at the code, the select calls are
C symbol: select

   File        Function   Line
1 types.h     <global>    94 #define select _abi_select
6 select.c    sys_select  94 ret =
7 system.c    sys_usleep  71 select(0,NULL,NULL,NULL,&tval);
1 wb_common.c write_sock 200 if (select(winbindd_fd + 1, &r_fds,
                  NULL, NULL, &tv) == -1) {

                 The likely (but not guaranteed) call is in sys_select,
                 which passes a timeval of 0 instead of NULL...

                 Ok, samba gurus, assuming this looping was in sys_select,
                 what would happen if errno was set to something 

                 And Linux gurus, what the heck is ERESTARTNOHAND? I
                 can't find it in /usr/include... I did find ERESTART,
                 which is standard...
David Collier-Brown,           | Always do right. This will gratify
Sun Microsystems DCMO          | some people and astonish the rest.
Toronto, Ontario               |
(905) 415-2849 or x52849       | davecb at

More information about the samba-technical mailing list