From owner-svn-src-head@FreeBSD.ORG Thu Oct 29 17:40:33 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D1D78106566C; Thu, 29 Oct 2009 17:40:33 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B69538FC1A; Thu, 29 Oct 2009 17:40:33 +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 n9THeX54005158; Thu, 29 Oct 2009 17:40:33 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9THeXTs005156; Thu, 29 Oct 2009 17:40:33 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <200910291740.n9THeXTs005156@svn.freebsd.org> From: Michael Tuexen Date: Thu, 29 Oct 2009 17:40:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198621 - head/sys/netinet X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Oct 2009 17:40:34 -0000 Author: tuexen Date: Thu Oct 29 17:40:33 2009 New Revision: 198621 URL: http://svn.freebsd.org/changeset/base/198621 Log: Improve round robin stream scheduler and cleanup some code. Approved by: rrs (mentor) MFC after: 3 days Modified: head/sys/netinet/sctp_output.c Modified: head/sys/netinet/sctp_output.c ============================================================================== --- head/sys/netinet/sctp_output.c Thu Oct 29 17:34:02 2009 (r198620) +++ head/sys/netinet/sctp_output.c Thu Oct 29 17:40:33 2009 (r198621) @@ -5605,13 +5605,10 @@ sctp_insert_on_wheel(struct sctp_tcb *st if (holds_lock == 0) { SCTP_TCB_SEND_LOCK(stcb); } - if ((strq->next_spoke.tqe_next) || - (strq->next_spoke.tqe_prev)) { - /* already on wheel */ - goto outof_here; + if ((strq->next_spoke.tqe_next == NULL) && + (strq->next_spoke.tqe_prev == NULL)) { + TAILQ_INSERT_TAIL(&asoc->out_wheel, strq, next_spoke); } - TAILQ_INSERT_TAIL(&asoc->out_wheel, strq, next_spoke); -outof_here: if (holds_lock == 0) { SCTP_TCB_SEND_UNLOCK(stcb); } @@ -5624,19 +5621,26 @@ sctp_remove_from_wheel(struct sctp_tcb * int holds_lock) { /* take off and then setup so we know it is not on the wheel */ - if (holds_lock == 0) + if (holds_lock == 0) { SCTP_TCB_SEND_LOCK(stcb); - if (TAILQ_FIRST(&strq->outqueue)) { - /* more was added */ - if (holds_lock == 0) - SCTP_TCB_SEND_UNLOCK(stcb); - return; } - TAILQ_REMOVE(&asoc->out_wheel, strq, next_spoke); - strq->next_spoke.tqe_next = NULL; - strq->next_spoke.tqe_prev = NULL; - if (holds_lock == 0) + if (TAILQ_EMPTY(&strq->outqueue)) { + if (asoc->last_out_stream == strq) { + asoc->last_out_stream = TAILQ_PREV(asoc->last_out_stream, sctpwheel_listhead, next_spoke); + if (asoc->last_out_stream == NULL) { + asoc->last_out_stream = TAILQ_LAST(&asoc->out_wheel, sctpwheel_listhead); + } + if (asoc->last_out_stream == strq) { + asoc->last_out_stream = NULL; + } + } + TAILQ_REMOVE(&asoc->out_wheel, strq, next_spoke); + strq->next_spoke.tqe_next = NULL; + strq->next_spoke.tqe_prev = NULL; + } + if (holds_lock == 0) { SCTP_TCB_SEND_UNLOCK(stcb); + } } static void @@ -7185,7 +7189,7 @@ sctp_fill_outqueue(struct sctp_tcb *stcb struct sctp_nets *net, int frag_point, int eeor_mode, int *quit_now) { struct sctp_association *asoc; - struct sctp_stream_out *strq, *strqn, *strqt; + struct sctp_stream_out *strq, *strqn; int goal_mtu, moved_how_much, total_moved = 0, bail = 0; int locked, giveup; struct sctp_stream_queue_pending *sp; @@ -7261,11 +7265,10 @@ sctp_fill_outqueue(struct sctp_tcb *stcb break; } else { asoc->locked_on_sending = NULL; - strqt = sctp_select_a_stream(stcb, asoc); - if (TAILQ_FIRST(&strq->outqueue) == NULL) { + if (TAILQ_EMPTY(&strq->outqueue)) { if (strq == strqn) { /* Must move start to next one */ - strqn = TAILQ_NEXT(asoc->last_out_stream, next_spoke); + strqn = TAILQ_NEXT(strq, next_spoke); if (strqn == NULL) { strqn = TAILQ_FIRST(&asoc->out_wheel); if (strqn == NULL) { @@ -7278,7 +7281,7 @@ sctp_fill_outqueue(struct sctp_tcb *stcb if ((giveup) || bail) { break; } - strq = strqt; + strq = sctp_select_a_stream(stcb, asoc); if (strq == NULL) { break; }