Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 3 Dec 2009 09:14:33 GMT
From:      liujb <liujb@arraynetworks.com.cn>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   amd64/141130: rpc may causes high cpu usage
Message-ID:  <200912030914.nB39EXqf022520@www.freebsd.org>
Resent-Message-ID: <200912030920.nB39K4iw022801@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200912030914.nB39EXqf022520>