From patchwork Sat Nov 5 02:32:55 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Soltys X-Patchwork-Id: 123808 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 6E428B70BB for ; Sat, 5 Nov 2011 13:33:34 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753859Ab1KECd2 (ORCPT ); Fri, 4 Nov 2011 22:33:28 -0400 Received: from tha.ppgk.com.pl ([77.252.116.179]:2710 "EHLO tha.ppgk.com.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753603Ab1KECdL (ORCPT ); Fri, 4 Nov 2011 22:33:11 -0400 Received: from localhost.ppgk.com.pl (localhost [127.0.0.1]) by tha.ppgk.com.pl (Postfix) with ESMTP id D2B8E3762E; Sat, 5 Nov 2011 03:33:10 +0100 (CET) X-PPGK-Scanned: amavisd-new 2.6.4 (20090625) at ppgk.com.pl Received: from tha.ppgk.com.pl ([127.0.0.1]) by localhost.ppgk.com.pl (tha.ppgk.com.pl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id fItqhDI-tHAs; Sat, 5 Nov 2011 03:33:10 +0100 (CET) Received: from localhost.localdomain (89-68-135-233.dynamic.chello.pl [89.68.135.233]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by tha.ppgk.com.pl (Postfix) with ESMTPSA id 629D937621; Sat, 5 Nov 2011 03:33:05 +0100 (CET) From: Michal Soltys To: kaber@trash.net Cc: davem@davemloft.net, netdev@vger.kernel.org Subject: [PATCH 09/11] sch_hfsc.c: split update_vf() Date: Sat, 5 Nov 2011 03:32:55 +0100 Message-Id: <1320460377-8682-10-git-send-email-soltys@ziu.info> X-Mailer: git-send-email 1.7.7.1 In-Reply-To: <1320460377-8682-1-git-send-email-soltys@ziu.info> References: <1320460377-8682-1-git-send-email-soltys@ziu.info> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Split update_vf() into 2 spearate functions, one responsible for just updating the vt, and the other responsible for setting the class [and possibly parent nodes] passive. This is actually how it was once done in the past, but at some point it was merged into one larger function. Two functions are shorter and cleaner, and during normal update_vf() it has a bit less work to do. --- net/sched/sch_hfsc.c | 51 +++++++++++++++++-------------------------------- 1 files changed, 18 insertions(+), 33 deletions(-) diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c index e73d2e0..26cdfaa 100644 --- a/net/sched/sch_hfsc.c +++ b/net/sched/sch_hfsc.c @@ -800,15 +800,11 @@ static void update_vf(struct hfsc_class *cl, unsigned int len, u64 cur_time) { u64 f; /* , myf_bound, delta; */ - int go_passive = 0; - - if (cl->qdisc->q.qlen == 0 && cl->cl_flags & HFSC_FSC) - go_passive = 1; for (; cl->cl_parent != NULL; cl = cl->cl_parent) { cl->cl_total += len; - if (!(cl->cl_flags & HFSC_FSC) || cl->cl_nactive == 0) + if (!(cl->cl_flags & HFSC_FSC)) continue; /* update vt */ @@ -826,27 +822,6 @@ update_vf(struct hfsc_class *cl, unsigned int len, u64 cur_time) cl->cl_vt = cl->cl_parent->cl_cvtmin; } - if (go_passive && --cl->cl_nactive == 0) - go_passive = 1; - else - go_passive = 0; - - if (go_passive) { - /* no more active child, going passive */ - - /* update cl_cvtoff of the parent class */ - if (cl->cl_vt > cl->cl_parent->cl_cvtoff) - cl->cl_parent->cl_cvtoff = cl->cl_vt; - - /* remove this class from the vt tree */ - vttree_remove(cl); - - cftree_remove(cl); - update_cfmin(cl->cl_parent); - - continue; - } - /* update the vt tree */ vttree_update(cl); @@ -899,15 +874,27 @@ set_active(struct hfsc_class *cl, unsigned int len) static void set_passive(struct hfsc_class *cl) { + list_del(&cl->dlist); + if (cl->cl_flags & HFSC_RSC) eltree_remove(cl); - list_del(&cl->dlist); + if (cl->cl_flags & HFSC_FSC) + for (; cl->cl_parent != NULL; cl = cl->cl_parent) { + if (--cl->cl_nactive > 0) + break; - /* - * vttree is now handled in update_vf() so that update_vf(cl, 0, 0) - * needs to be called explicitly to remove a class from vttree. - */ + /* update cl_cvtoff of the parent class */ + if (cl->cl_vt > cl->cl_parent->cl_cvtoff) + cl->cl_parent->cl_cvtoff = cl->cl_vt; + + /* remove this class from the parent's vt & cf trees */ + vttree_remove(cl); + cftree_remove(cl); + + /* update cfmin of the parent, after removal */ + update_cfmin(cl->cl_parent); + } } static unsigned int @@ -1286,7 +1273,6 @@ hfsc_qlen_notify(struct Qdisc *sch, unsigned long arg) struct hfsc_class *cl = (struct hfsc_class *)arg; if (cl->qdisc->q.qlen == 0) { - update_vf(cl, 0, 0); set_passive(cl); } } @@ -1729,7 +1715,6 @@ hfsc_drop(struct Qdisc *sch) if (cl->qdisc->ops->drop != NULL && (len = cl->qdisc->ops->drop(cl->qdisc)) > 0) { if (cl->qdisc->q.qlen == 0) { - update_vf(cl, 0, 0); set_passive(cl); } else { list_move_tail(&cl->dlist, &q->droplist);