From owner-svn-src-user@FreeBSD.ORG Tue Jan 26 16:47:34 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ACEA31065692; Tue, 26 Jan 2010 16:47:34 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 841A18FC1F; Tue, 26 Jan 2010 16:47:34 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o0QGlYB2046250; Tue, 26 Jan 2010 16:47:34 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o0QGlYli046248; Tue, 26 Jan 2010 16:47:34 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201001261647.o0QGlYli046248@svn.freebsd.org> From: Luigi Rizzo Date: Tue, 26 Jan 2010 16:47:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203035 - user/luigi/ipfw3-head/sys/netinet/ipfw X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jan 2010 16:47:34 -0000 Author: luigi Date: Tue Jan 26 16:47:34 2010 New Revision: 203035 URL: http://svn.freebsd.org/changeset/base/203035 Log: fix two bugs in the scheduler Submitted by: Riccardo Panicucci Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_wf2q.c Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_wf2q.c ============================================================================== --- user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_wf2q.c Tue Jan 26 16:18:45 2010 (r203034) +++ user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_wf2q.c Tue Jan 26 16:47:34 2010 (r203035) @@ -182,7 +182,20 @@ wf2qp_dequeue(struct new_sch_inst *_si) idle_check(si, 1, 0); /* drain something from the idle heap */ /* make sure at least one element is eligible, bumping V - * and moving entries that have become eligible + * and moving entries that have become eligible. + * We need to repeat the first part twice, before and + * after extracting the candidate, or enqueue() will + * find the data structure in a wrong state. + */ + pkt = NULL; + for(;;) { + /* + * Compute V = max(V, min(S_i)). Remember that all elements + * in sch have by definition S_i <= V so if sch is not empty, + * V is surely the max and we must not update it. Conversely, + * if sch is empty we only need to look at neh. + * We don't need to move the queues, as it will be done at the + * next enqueue */ if (sch->elements == 0 && neh->elements > 0) { si->V = MAX64(si->V, HEAP_TOP(neh)->key); @@ -190,10 +203,12 @@ wf2qp_dequeue(struct new_sch_inst *_si) while (neh->elements > 0 && DN_KEY_LEQ(HEAP_TOP(neh)->key, si->V)) { q = HEAP_TOP(neh)->object; - alg_fq = (struct wf2qp_queue *)q; + alg_fq = (struct wf2qp_queue *)(q + 1); heap_extract(neh, NULL); heap_insert(sch, alg_fq->F, q); } + if (pkt) /* pkt found in previous iteration */ + break; /* ok we have at least one eligible pkt */ q = HEAP_TOP(sch)->object; alg_fq = (struct wf2qp_queue *)(q + 1); @@ -213,18 +228,7 @@ wf2qp_dequeue(struct new_sch_inst *_si) heap_insert(neh, alg_fq->S, q); } } - - /* - * Now compute V = max(V, min(S_i)). Remember that all elements - * in sch have by definition S_i <= V so if sch is not empty, - * V is surely the max and we must not update it. Conversely, - * if sch is empty we only need to look at neh. - * We don't need to move the queues, as it will be done at the - * next enqueue - */ - if (sch->elements == 0 && neh->elements > 0) { - si->V = MAX64(si->V, HEAP_TOP(neh)->key); - } + } return pkt; }