amd64/141130: rpc may causes high cpu usage

liujb liujb at arraynetworks.com.cn
Thu Dec 3 09:20:04 UTC 2009


>Number:         141130
>Category:       amd64
>Synopsis:       rpc may causes high cpu usage
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    freebsd-amd64
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Dec 03 09:20:04 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     liujb
>Release:        FreeBSD7.0
>Organization:
array networks
>Environment:
FreeBSD 7.0-RELEASE 
>Description:
In svc_getreqset function, high-number fd will not be handled.
Data is still in receiving buffer, so rpc lib will be called 
frequently, which leads high cpu usage.  

It's because fd_mask is unsinged long, which is 64-bits in amd64,
but ffs only handles 32bit int. The high fd will be ingored, 
and jump out of the second for loop.

Please read my comments in the following source code.

void
svc_getreqset(readfds)
        fd_set *readfds;
{
        int bit, fd;
        fd_mask mask, *maskp;
        int sock;

        assert(readfds != NULL);

        maskp = readfds->fds_bits;
        for (sock = 0; sock < FD_SETSIZE; sock += NFDBITS) {
            for (mask = *maskp++; (bit = ffs(mask)) != 0;    
                                         -->should be ffsl
                mask ^= (1 << (bit - 1))) {                  
                         -->1 should be (long)1
                /* sock has input waiting */
                fd = sock + bit - 1;
                svc_getreq_common(fd);
            }
        }
}

>How-To-Repeat:
Open a rpc connection with a high number file description.
>Fix:
The fix should be take care of the long type of fd_mask in i386 and amd64, 
also should pay attention to other places using ffs.

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-amd64 mailing list