From owner-freebsd-amd64@FreeBSD.ORG Thu Dec 3 09:20:04 2009 Return-Path: Delivered-To: freebsd-amd64@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A6BD710656BA for ; Thu, 3 Dec 2009 09:20:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 6C2758FC20 for ; Thu, 3 Dec 2009 09:20:04 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id nB39K4qw022802 for ; Thu, 3 Dec 2009 09:20:04 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id nB39K4iw022801; Thu, 3 Dec 2009 09:20:04 GMT (envelope-from gnats) Resent-Date: Thu, 3 Dec 2009 09:20:04 GMT Resent-Message-Id: <200912030920.nB39K4iw022801@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-amd64@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, liujb Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4253E106566C for ; Thu, 3 Dec 2009 09:14:34 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 321638FC1A for ; Thu, 3 Dec 2009 09:14:34 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id nB39EXxe022521 for ; Thu, 3 Dec 2009 09:14:33 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id nB39EXqf022520; Thu, 3 Dec 2009 09:14:33 GMT (envelope-from nobody) Message-Id: <200912030914.nB39EXqf022520@www.freebsd.org> Date: Thu, 3 Dec 2009 09:14:33 GMT From: liujb To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 X-Mailman-Approved-At: Thu, 03 Dec 2009 12:23:26 +0000 Cc: Subject: amd64/141130: rpc may causes high cpu usage X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Dec 2009 09:20:04 -0000 >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: